Skip to content

Cache step results while steps are executing instead of caching all of them at the end#709

Merged
BolajiOlajide merged 10 commits into
mainfrom
bo/cache-individual-steps
Mar 10, 2022
Merged

Cache step results while steps are executing instead of caching all of them at the end#709
BolajiOlajide merged 10 commits into
mainfrom
bo/cache-individual-steps

Conversation

@BolajiOlajide

@BolajiOlajide BolajiOlajide commented Mar 4, 2022

Copy link
Copy Markdown
Contributor

Test plan

We adjusted the test suite to ensure that tasks are cached after execution of all steps, but the steps are cached immediately the individual execution is done.

We also tested this change on the UI by taking the following steps:

  • Create a batch spec that'll fail at a particular step
name: testerr
description: Add Hello World to READMEs

# Find all repositories that contain a README.md file.
on:
  - repositoriesMatchingQuery: file:README.md count:100

# In each repository, run this command. Each repository's resulting diff is captured.
steps:
  - run: echo Hello World 123 | tee -a $(find -name README.md)
    container: ubuntu:18.04
  - run: exit 1
    container: ubuntu:18.04

# Describe the changeset (e.g., GitHub pull request) you want for each repository.
changesetTemplate:
  title: Hello World
  body: My first batch change!
  branch: hello-world # Push the commit to this branch.
  commit:
    message: Append Hello World to all README.md files
  • Ensure it fails, then retry the batch spec run and checking the previous passing steps was cached.

Closes #27564

@BolajiOlajide BolajiOlajide requested a review from a team March 4, 2022 16:41
@BolajiOlajide BolajiOlajide self-assigned this Mar 4, 2022

@LawnGnome LawnGnome left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM — nice work! I have a question about a modified test, and a vague note about having n os.Environ() calls, but nothing blocking.

Comment thread internal/batches/executor/coordinator.go Outdated
Comment thread internal/batches/executor/coordinator_test.go

@eseliger eseliger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR and an amazing FIRST PR! Congrats on your first, very meaningful even, contribution! 🚀

Comment thread internal/batches/executor/coordinator.go Outdated
Comment thread internal/batches/executor/coordinator.go Outdated
Comment thread internal/batches/executor/executor.go Outdated

@courier-new courier-new left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for added tests!

Made one more suggestion in line with the same renaming Erik suggested about writeToCache vs. writeStepCacheResult, but otherwise I'm excited for this improvement with server-side execution!

Comment thread internal/batches/executor/run_steps.go Outdated
BolajiOlajide and others added 2 commits March 7, 2022 21:31
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>

@LawnGnome LawnGnome left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes!

@BolajiOlajide BolajiOlajide merged commit 9387b19 into main Mar 10, 2022
@BolajiOlajide BolajiOlajide deleted the bo/cache-individual-steps branch March 10, 2022 11:33
scjohns pushed a commit that referenced this pull request Apr 24, 2023
…f them at the end (#709)

* feat: cache build steps individually

* feat: add tests for individual step caching

* chore: remove unused method

* Update internal/batches/executor/coordinator.go

Co-authored-by: Erik Seliger <erikseliger@me.com>

* Update internal/batches/executor/executor.go

Co-authored-by: Erik Seliger <erikseliger@me.com>

* feat: update callback method in executor

* feat: optimize writeToCache callback

* chore: fix failing tests

* Update internal/batches/executor/run_steps.go

Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>

* fix: resolve failing tests

Co-authored-by: Erik Seliger <erikseliger@me.com>
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache step results while steps are executing instead of caching all of them at the end

4 participants