fix(csharp-ci): make dotnet-coverage install idempotent on shared runners#31
Merged
Merged
Conversation
…ners dotnet tool update refuses to downgrade a global tool, so a shared self-hosted runner that already has a newer dotnet-coverage installed (left behind by a different repo's pin) hard-fails every job pinned to an older version, with no recovery short of luck on a rerun landing on a different runner. Replace the inline `tool update` with a script that checks the installed version first and uninstalls-then-reinstalls only when it differs from the pin, in either direction.
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.
Summary
Root-caused a
csharp-ciCI failure ondaml-codegen-csharp-internalPR #580:Install dotnet-coveragerandotnet tool update -g dotnet-coverage --version "$DOTNET_COVERAGE_VERSION", which fails outright with "The requested version X is lower than existing version Y" whenever the runner's global tool is already ahead of the caller's pin —dotnet tool updatewill not downgrade. On a shared self-hosted runner (the Hetzner pool, whichmatrix-mode: cheapdeliberately routes multiple repos' coverage jobs onto), this happens whenever one repo pins a newerMicrosoft.Testing.Extensions.CodeCoveragethan another. It isn't transient — reruns keep failing until they happen to land on a runner nobody's bumped yet, or someone manually clears the box's global tool cache.scripts/install-dotnet-coverage.sh: checks the currently-installed global tool version first; no-ops if it already matches the pin, otherwise uninstalls then reinstalls at the pinned version (handles both upgrade and downgrade —installdoesn't haveupdate's directionality restriction).csharp-ci.yaml'sInstall dotnet-coveragestep now calls this script instead of runningtool updateinline.test/install-dotnet-coverage_test.sh(wired intobuild-and-test.yaml's shell-test step) stubsdotnetand covers: not installed, installed older, installed newer (the actual regression), and already-current (no-op, no unnecessary reinstall).Test plan
bash test/install-dotnet-coverage_test.sh— all cases pass, including the newer-than-pin regression casebash test/push-nuget_test.sh,bash test/normalize-ci-matrix_test.sh,python3 -m unittest discover -s test -p '*_test.py'— unaffected, all greenactionlintclean on both modified workflow files