Skip to content

Commit

Permalink
Add Junit report for Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
itavero committed Jan 5, 2025
1 parent c25fbb1 commit d12f859
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 10 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
-Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }}
-Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }}
- name: Publish Code Coverage
- name: Publish Coverage to Codecov
uses: codecov/codecov-action@v4
with:
override_pr: ${{ steps.pr.outputs.number }}
Expand All @@ -96,6 +96,16 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Publish Test Results to Codecov
uses: codecov/test-results-action@v1
with:
override_pr: ${{ steps.pr.outputs.number }}
override_commit: ${{ steps.pr.outputs.head_sha }}
files: ./reports/junit.xml
flags: tests
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Add comment to PR if job fails
if: ${{ failure() }}
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
coverage/lcov.info
coverage/clover.xml
reports/tests.xml
reports/junit.xml
- name: SonarCloud (on push)
uses: sonarsource/sonarcloud-github-action@v2
Expand All @@ -80,3 +81,12 @@ jobs:
flags: tests
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Codecov Test Results (on push)
uses: codecov/test-results-action@v1
if: github.event_name == 'push' && matrix.node-version == env.node-version-analysis
with:
files: ./reports/junit.xml
flags: tests
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 20 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ module.exports = {
testEnvironment: 'node',
setupFilesAfterEnv: ['jest-chain'],
coverageReporters: ['json', 'lcov', 'text', 'clover'],
collectCoverageFrom : [
'src/**/*.ts',
'!src/docgen/*.ts',
collectCoverageFrom: ['src/**/*.ts', '!src/docgen/*.ts'],
reporters: [
'default',
[
'jest-sonar',
{
outputDirectory: 'reports',
outputName: 'tests.xml',
reportedFilePath: 'relative',
},
],
[
'jest-junit',
{
outputDirectory: 'reports',
outputName: 'junit.xml',
reportedFilePath: 'relative',
},
],
],
reporters: ['default', ['jest-sonar', {
outputDirectory: 'reports',
outputName: 'tests.xml',
reportedFilePath: 'relative',
}]],
};
};
79 changes: 79 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"jest": "^29.7.0",
"jest-chain": "^1.1.6",
"jest-each": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-mock-extended": "^3.0.5",
"jest-sonar": "^0.2.16",
"jest-when": "^3.6.0",
Expand Down

0 comments on commit d12f859

Please sign in to comment.