Skip to content

Commit

Permalink
build: Unit test summary (#211)
Browse files Browse the repository at this point in the history
DH-18524: Fixed unit test report path that was breaking GH action

---------

Co-authored-by: Mike Bender <[email protected]>
  • Loading branch information
bmingles and mofojed authored Jan 29, 2025
1 parent 976e07d commit 2c06df8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
"overrides": [
{
"files": ["*.ts"],
// Since parserOptions.project is used, can't include files outside of
// Since parserOptions.project is used, we can't include files outside of
// the listed tsconfig files and seems silly to add a tsconfig just for
// the one file. It will still be linted by the base config above. It just
// won't be included in this overrides section.
"excludedFiles": ["vitest.config.ts"],
// a few vitest files. These files will still be linted by the base config
// above. They just won't be included in this overrides section.
"excludedFiles": ["__mocks__/**/*.ts", "vitest.config.ts"],
"parserOptions": {
"project": [
"./tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This action orchestrates CI actions that can be run in parallel. This action
# can be listed by any actions that use `workflow_run` as a trigger that depend
# on all orchestrated actions being completed (e.g. pr-comment.yml).
name: 'Orchestrator'
name: 'CI Tests'
on:
push:
branches:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: End-to-end PR Comment
# access to secrets
on:
workflow_run:
workflows: ['Orchestrator']
workflows: ['CI Tests']
types:
- completed

Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ jobs:
npm run report:ctrfsummary
sed -i 's/<h3>Test Summary<\/h3>/<h3>Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY
npm run report:prcomment
# The junit-to-ctrf npm package exits with a 0 status code even if
# it fails to parse the JUnit report, so check for the file manually
# and explicilty exit with a non-zero status code if it's not found.
# We do this after npm run report:prcomment so that the PR number can
# still be associated in subsequent steps.
if [ ! -e test-reports/vitest.junit.xml ]; then
echo "No JUnit report found at test-reports/vitest.junit.xml"
exit 1
fi
- name: Save PR Number
if: ${{ always() }}
run: echo ${{ github.event.number }} > pr-comment/PR-number.txt
Expand Down
4 changes: 3 additions & 1 deletion src/__mocks__/vscode.ts → __mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/**
* Mock `vscode` module. Note that `vi.mock('vscode')` has to be explicitly
* called in any test module needing to use this mock. It will not be loaded
* automatically.
* automatically. This module also needs to be located under the `__mocks__`
* directory under the project root to be found when `vi.mock('vscode')` is
* called.
*/
import { vi } from 'vitest';

Expand Down
2 changes: 1 addition & 1 deletion vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vite';

export default defineConfig({
test: {
root: 'src',
dir: 'src',
server: {
deps: {
// Imports of .js files without extensions fail without this
Expand Down

0 comments on commit 2c06df8

Please sign in to comment.