Skip to content

fix(csharp-ci): install dotnet-coverage per job, not into the shared global tools dir - #41

Merged
monsieurleberre merged 1 commit into
devfrom
fix/dotnet-coverage-per-job-tool-path
Sep 29, 2026
Merged

monsieurleberre merged 1 commit into
devfrom
fix/dotnet-coverage-per-job-tool-path

Conversation

@monsieurleberre

@monsieurleberre monsieurleberre commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Install dotnet-coverage step in csharp-ci.yaml installed the tool globally with dotnet tool install -g. On a self-hosted host that runs several runner slots as the same Unix user, every slot shares one ~/.dotnet/tools. Consumers pin different versions through Microsoft.Testing.Extensions.CodeCoverage, and since #31 each job uninstalls and reinstalls the global tool whenever its pin differs from the version already there.

This was measured on 2026-09-28 on two slots of one host:

  • 22:12:21.8994Z: a job pinned to 18.11.0 logged dotnet-coverage 18.11.2 installed, want 18.11.0 — reinstalling and uninstalled 18.11.2.
  • 22:12:21.9037Z: another repo's dotnet-coverage merge step on a different slot, pinned to 18.11.2, crashed with a Microsoft.CodeCoverage.Instrumentation FileNotFoundException (exit 134).

Consumers currently pin at least four different versions (18.9.0 to 18.11.2), so these overlaps are routine.

Fix

scripts/install-dotnet-coverage.sh now installs the pinned version with --tool-path "$RUNNER_TEMP/dotnet-coverage-<version>" and prepends that directory to GITHUB_PATH. RUNNER_TEMP is private to the runner slot and wiped between jobs, which is the same precedent #33 set for go-ci. Because the global tool is never touched, no job can pull a binary out from under another job. GITHUB_PATH entries go ahead of the runner's PATH, so a stale global dotnet-coverage left in ~/.dotnet/tools is shadowed rather than used. The script fails loud if RUNNER_TEMP or GITHUB_PATH is unset.

This needs no change on the runner host.

Verification

  • test/install-dotnet-coverage_test.sh was rewritten for the new contract. It checks the job-private tool path, the GITHUB_PATH line, a separate path per pin, an install failure leaving GITHUB_PATH untouched, and a usage error and missing RUNNER_TEMP making no dotnet call.
  • Real smoke test with dotnet: the script installed 18.11.2 into the temp tool path, dotnet-coverage --version resolved to it through the emitted path, and a dotnet-coverage merge -f cobertura exited 0. A second run in the same job is idempotent.

Rollout

All callers use csharp-ci.yaml@v2, so the fix reaches them only after a maintainer tags a release (v2.4.2) and moves v2. Nothing has been tagged.

…global tools dir

Every runner slot on a shared self-hosted host runs as one Unix user and
shared ~/.dotnet/tools. A job whose pin differed uninstalled the global
dotnet-coverage while another slot's dotnet-coverage merge was running,
crashing it with a Microsoft.CodeCoverage.Instrumentation
FileNotFoundException (exit 134). Install into $RUNNER_TEMP with
--tool-path and prepend it to GITHUB_PATH instead.
@monsieurleberre
monsieurleberre marked this pull request as ready for review September 28, 2026 23:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T23:45:23.560663Z 7c64521 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@monsieurleberre
monsieurleberre merged commit f8001ea into dev Sep 29, 2026
2 checks passed
@monsieurleberre
monsieurleberre deleted the fix/dotnet-coverage-per-job-tool-path branch September 29, 2026 08:13
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