Skip to content

fix(csharp-ci): make dotnet-coverage install idempotent on shared runners#31

Merged
monsieurleberre merged 1 commit into
devfrom
fix/dotnet-coverage-install-idempotent
Jul 9, 2026
Merged

fix(csharp-ci): make dotnet-coverage install idempotent on shared runners#31
monsieurleberre merged 1 commit into
devfrom
fix/dotnet-coverage-install-idempotent

Conversation

@monsieurleberre

Copy link
Copy Markdown
Contributor

Summary

Root-caused a csharp-ci CI failure on daml-codegen-csharp-internal PR #580: Install dotnet-coverage ran dotnet 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 update will not downgrade. On a shared self-hosted runner (the Hetzner pool, which matrix-mode: cheap deliberately routes multiple repos' coverage jobs onto), this happens whenever one repo pins a newer Microsoft.Testing.Extensions.CodeCoverage than 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.

  • Add 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 — install doesn't have update's directionality restriction).
  • csharp-ci.yaml's Install dotnet-coverage step now calls this script instead of running tool update inline.
  • New test/install-dotnet-coverage_test.sh (wired into build-and-test.yaml's shell-test step) stubs dotnet and 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 case
  • bash test/push-nuget_test.sh, bash test/normalize-ci-matrix_test.sh, python3 -m unittest discover -s test -p '*_test.py' — unaffected, all green
  • actionlint clean on both modified workflow files

…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.
@monsieurleberre monsieurleberre merged commit d90fb66 into dev Jul 9, 2026
2 checks passed
@monsieurleberre monsieurleberre deleted the fix/dotnet-coverage-install-idempotent branch July 9, 2026 14:13
monsieurleberre added a commit that referenced this pull request Jul 10, 2026
The v2.3.2 (go-ci sudo fix, #29) and v2.3.3 (csharp-ci coverage-install
idempotency fix, #31) tags already exist on origin but their entries
were still sitting under Unreleased. Split them into proper dated
sections matching the tags.
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.

1 participant