CI: resolve the NuGet cache key once, so the post step never walks the tree - #3231
Merged
Merged
Conversation
…e tree
The Windows job has been failing at teardown with
The template is not valid. .github/workflows/CI.yml (Line: 86, Col: 16):
hashFiles('Directory.Packages.props, global.json, **/*.csproj') failed.
Fail to hash files under directory 'D:\a\StackExchange.Redis\StackExchange.Redis'
after every real step had already passed - build, tests and all. The failing
step is "Post Cache NuGet packages": actions/cache re-evaluates `key` in its post
step to decide what to save, and that runs at the end of the job rather than the
beginning.
#3209 moved the hash ahead of the redis servers so the restore would see a still
tree, and that half works - the restore step passes. But the post step re-walks
the workspace once sixteen redis processes have been writing through DrvFs and
every project has grown bin/ and obj/ across six target frameworks, which is the
same "enumerating a tree that is changing underneath you" the existing comment
describes, only worse.
Resolve the expression once into a step output and hand actions/cache a plain
string. The glob then runs exactly where it is safe - straight after checkout -
and the post step has nothing left to enumerate.
Left in pwsh to match the rest of the job, which has no defaults.run.shell and
so inherits the Windows runner's default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Windows job has been failing at teardown, after everything real has already passed:
Which step
Not the one the line number suggests. From the failing job on #3228:
actions/cachere-evaluateskeyin its post step to decide what to save, and that runs at jobteardown. Both evaluations point at line 86, which is why the error reads as though the restore failed.
Why #3209 did not finish the job
That change moved the hash ahead of the redis servers so the restore would see a still tree, and that half
works — step 4 passes. But the post step re-walks the workspace after sixteen redis processes have been
writing through DrvFs and every project has grown
bin/andobj/across six target frameworks. Same"enumerating a tree that is changing underneath you" the existing comment describes, at the point where the
churn is worst.
The change
Resolve the expression once into a step output and hand
actions/cachea plain string:The glob now runs exactly where it is safe — straight after checkout — and the post step has nothing left to
enumerate. Cache behaviour is otherwise unchanged: same key, same
restore-keys.Left in pwsh to match the rest of the job, which has no
defaults.run.shelland inherits the Windowsrunner's default.
Notes
The failure is intermittent, so a green run here does not by itself prove the fix — what does is that the
post step no longer evaluates
hashFilesat all, which is visible in the diff rather than in a result. TheCompute NuGet cache keystep appearing beforeCache NuGet packages, and the post step no longer failing,are the things to look for.
The alternative would be
continue-on-error: trueon the cache step, which hides the symptom and silentlystops saving the cache; this removes the cause.