ci: show test reports in job summary

This commit is contained in:
Il Harper 2024-04-06 03:11:22 +08:00
parent 312b01acff
commit 9a0c50521d
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
4 changed files with 57 additions and 2 deletions

View File

@ -5,6 +5,11 @@ on:
pull_request:
workflow_dispatch:
permissions:
contents: read
actions: read
checks: write
jobs:
test:
name: test
@ -21,15 +26,27 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.3.1'
node-version: '20.12.0'
- name: Test
- name: Build Packages
run: |
corepack enable
yarn install --immutable
yarn build
shell: bash
- name: Test
run: |
yarn test
shell: bash
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Chronocat Unit Tests
path: coverage/jest-junit.xml # Path to test results
reporter: jest-junit # Format of test results
- name: Upload Coverage Reports to Codecov
uses: codecov/codecov-action@v3

View File

@ -17,6 +17,23 @@ const config: JestConfigWithTsJest = {
collectCoverage: true,
coverageDirectory: 'coverage',
coverageProvider: 'v8',
reporters: [
'default',
[
'jest-junit',
{
suiteName: 'Chronocat Unit Tests',
outputDirectory: 'coverage',
outputName: 'jest-junit.xml',
ancestorSeparator: ' ',
uniqueOutputName: 'false',
suiteNameTemplate: '{filepath}',
classNameTemplate: '{classname}',
titleTemplate: '{title}',
},
],
],
}
// eslint-disable-next-line import/no-default-export

View File

@ -36,6 +36,7 @@
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.3",
"jest-junit": "^16.0.0",
"prettier": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",

View File

@ -6405,6 +6405,7 @@ __metadata:
eslint-plugin-import: "npm:^2.28.1"
eslint-plugin-prettier: "npm:^5.0.0"
jest: "npm:^29.6.3"
jest-junit: "npm:^16.0.0"
prettier: "npm:^3.0.2"
ts-jest: "npm:^29.1.1"
ts-node: "npm:^10.9.1"
@ -10988,6 +10989,18 @@ __metadata:
languageName: node
linkType: hard
"jest-junit@npm:^16.0.0":
version: 16.0.0
resolution: "jest-junit@npm:16.0.0"
dependencies:
mkdirp: "npm:^1.0.4"
strip-ansi: "npm:^6.0.1"
uuid: "npm:^8.3.2"
xml: "npm:^1.0.1"
checksum: 10c0/d813d4d142341c2b51b634db7ad6ceb9849514cb58f96ec5e7e4cf4031a557133490452710c2d9dec9b1dd546334d9ca663e042d3070c3e8f102ce6217bd8e2e
languageName: node
linkType: hard
"jest-leak-detector@npm:^29.7.0":
version: 29.7.0
resolution: "jest-leak-detector@npm:29.7.0"
@ -18017,6 +18030,13 @@ __metadata:
languageName: node
linkType: hard
"xml@npm:^1.0.1":
version: 1.0.1
resolution: "xml@npm:1.0.1"
checksum: 10c0/04bcc9b8b5e7b49392072fbd9c6b0f0958bd8e8f8606fee460318e43991349a68cbc5384038d179ff15aef7d222285f69ca0f067f53d071084eb14c7fdb30411
languageName: node
linkType: hard
"xtend@npm:^4.0.0, xtend@npm:^4.0.1, xtend@npm:~4.0.1":
version: 4.0.2
resolution: "xtend@npm:4.0.2"