-
Notifications
You must be signed in to change notification settings - Fork 0
Stabilize Codecov coverage and test-result reporting in CI #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
|
|
@@ -23,10 +24,34 @@ jobs: | |
| run: dotnet restore EasySourceGenerators.sln | ||
|
|
||
| - name: Test | ||
| run: dotnet test EasySourceGenerators.sln --no-restore --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage | ||
| run: dotnet test EasySourceGenerators.sln --no-restore --verbosity normal --collect:"XPlat Code Coverage" --logger "trx;LogFilePrefix=test-results" --results-directory ./coverage | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| directory: ./coverage | ||
| use_oidc: true | ||
| fail_ci_if_error: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Convert TRX to JUnit XML | ||
| if: ${{ !cancelled() }} | ||
| run: | | ||
| if dotnet tool list --global | grep -q '^trx2junit '; then | ||
| dotnet tool update --global trx2junit --version 2.1.0 | ||
| else | ||
| dotnet tool install --global trx2junit --version 2.1.0 | ||
| fi | ||
| TRX_FILES="$(find ./coverage -type f -name '*.trx')" | ||
| if [ -n "$TRX_FILES" ]; then | ||
| trx2junit $TRX_FILES | ||
| else | ||
| echo "No TRX files found in ./coverage." | ||
| fi | ||
|
|
||
| - name: Upload test results to Codecov | ||
| if: ${{ !cancelled() }} | ||
| uses: codecov/test-results-action@v1 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: ./coverage/*.xml | ||
| disable_search: true | ||
|
Comment on lines
+51
to
+57
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step relies on
secrets.CODECOV_TOKEN, but onpull_requestworkflows secrets are not provided to runs from forked repositories. If a fork PR triggers this workflow, the token will be empty and the action may fail. Consider guarding the step with a token-present condition (or switching to an auth method that works for fork PRs).