diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 6dd21b7..a204f6d 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -62,9 +62,18 @@ jobs: - name: Check EditorConfig step run: docker run --rm -v "$PWD":/check --workdir /check mstruebing/editorconfig-checker:latest - # --collect drives coverlet.collector to emit Cobertura XML into ./coverage//. + # global.json opts into the native Microsoft.Testing.Platform runner, so the VSTest bridge + # (and its --collect data collector) is gone. + # --coverage-output stays unset because pinning one filename gives every test project in the solution the same path, and the last to finish overwrites the rest. + # The default .cobertura.xml written instead is a name codecov-cli's finder does not match, so each report is prefixed rather than renamed, keeping the guid that makes it unique. - name: Run unit tests step - run: dotnet test --collect:"XPlat Code Coverage" --results-directory ./coverage + run: | + set -Eeuo pipefail + dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage + for report in ./coverage/*.cobertura.xml; do + [ -e "$report" ] || continue + mv "$report" "./coverage/coverage-$(basename "$report")" + done # Report-only: fail_ci_if_error is false so a Codecov hiccup or an absent token never fails the gate. - name: Upload coverage to Codecov step diff --git a/.gitignore b/.gitignore index e255b63..67a587d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,9 @@ .artifacts .DS_Store *.user + +# Coverage output (dotnet Microsoft.Testing.Extensions.CodeCoverage) +coverage/ +[Tt]est[Rr]esults/ +*.cobertura.xml +*.coverage diff --git a/AGENTS.md b/AGENTS.md index 94e6ff6..1a0fb71 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,6 +40,12 @@ For comprehensive coding and formatting standards, follow: - `version --versionpath=./Make/Version.json`. - `matrix --versionpath=./Make/Version.json --matrixpath=./Make/Matrix.json --updateversion`. - `make --versionpath=./Make/Version.json --makedirectory=./Make --dockerdirectory=./Docker --versionlabel=Beta`. +- Tests run on the native Microsoft.Testing.Platform runner, opted into by `global.json`. Locally that is + plain `dotnet test`; CI adds coverage with + `dotnet test --coverage --coverage-output-format cobertura --results-directory ./coverage`, then prefixes + each report to `coverage-.cobertura.xml` so codecov-cli's file finder matches it. Running an + MTP-based test project through the VSTest target is what fails, so the old + `--collect:"XPlat Code Coverage"` form is an error here specifically because this project opted in. - Formatting and style checks are enforced by Husky.Net and VS Code tasks. - Required tasks are documented in `CODESTYLE.md` and `.husky/task-runner.json`. - C# code should be formatted with CSharpier, then verified with `dotnet format` (style). diff --git a/CreateMatrixTests/CreateMatrixTests.csproj b/CreateMatrixTests/CreateMatrixTests.csproj index 8152695..fe1756a 100644 --- a/CreateMatrixTests/CreateMatrixTests.csproj +++ b/CreateMatrixTests/CreateMatrixTests.csproj @@ -8,18 +8,14 @@ net10.0 - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +}