diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 61c9de2..2a0737c 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -37,6 +37,8 @@ jobs: validate: name: Validate job uses: ./.github/workflows/validate-task.yml + # Thread CODECOV_TOKEN through so the unit-test job can upload coverage. + secrets: inherit # Build, version, validate, push, and release the triggering branch. Grants the write scopes # build-release-task needs (it declares none, so the read-only smoke caller is not forced to over-grant). diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index a8a55ff..df5e561 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -26,6 +26,8 @@ jobs: name: Validate job if: ${{ !github.event.deleted }} uses: ./.github/workflows/validate-task.yml + # Thread CODECOV_TOKEN through so the unit-test job can upload coverage. + secrets: inherit # Build and pack the library in its branch configuration to prove it ships, publishing nothing. Runs on # every push, so a change to build-release-task is exercised head-resolved in the PR that makes it. diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 1d7f589..151cbfb 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -24,8 +24,18 @@ jobs: uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 # Builds with TreatWarningsAsErrors, so analyzer and code-style warnings fail here. + # --collect drives coverlet.collector to emit Cobertura XML into ./coverage//. - name: Run unit tests step - run: dotnet test + run: dotnet test --collect:"XPlat Code Coverage" --results-directory ./coverage + + # 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 + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 + with: + directory: ./coverage + fail_ci_if_error: false + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # The same checks the editor runs interactively, enforced in CI from the same config files: CSharpier # formatting, dotnet format style (EditorConfig), markdownlint, cspell on the user-facing docs, and diff --git a/Directory.Packages.props b/Directory.Packages.props index 242e3e7..91b1f2c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,6 +1,7 @@ + diff --git a/LanguageTagsTests/LanguageTagsTests.csproj b/LanguageTagsTests/LanguageTagsTests.csproj index f43478d..2e9dfc3 100644 --- a/LanguageTagsTests/LanguageTagsTests.csproj +++ b/LanguageTagsTests/LanguageTagsTests.csproj @@ -12,6 +12,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +