Skip to content

Commit 02c9fc4

Browse files
committed
reporting in ci
1 parent 28b6e82 commit 02c9fc4

5 files changed

Lines changed: 39 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
branches:
99
- main
1010

11+
permissions:
12+
contents: read
13+
actions: read
14+
checks: write
15+
1116
jobs:
1217
test:
1318
runs-on: ubuntu-latest
@@ -49,19 +54,34 @@ jobs:
4954
- name: Build packages
5055
run: pnpm -r run build
5156

52-
- name: Run tests and lint
53-
run: pnpm -r run test
57+
- name: Run SDK tests
58+
id: sdk-test
59+
working-directory: packages/b2c-tooling-sdk
60+
run: pnpm run test:ci && pnpm run lint
61+
62+
- name: Run CLI tests
63+
id: cli-test
64+
if: always() && steps.sdk-test.conclusion != 'cancelled'
65+
working-directory: packages/b2c-cli
66+
run: pnpm run test:ci && pnpm run lint
67+
68+
- name: Test Report
69+
uses: dorny/test-reporter@fe45e9537387dac839af0d33ba56eed8e24189e8 # v2.3.0
70+
if: always() && steps.sdk-test.conclusion != 'cancelled'
71+
with:
72+
name: Test Results (Node ${{ matrix.node-version }})
73+
path: 'packages/*/test-results.json'
74+
reporter: mocha-json
5475

5576
- name: Generate coverage summary
56-
if: always()
77+
if: always() && steps.sdk-test.conclusion != 'cancelled'
5778
run: |
58-
echo "## Code Coverage Report (Node ${{ matrix.node-version }})" >> $GITHUB_STEP_SUMMARY
79+
echo "## Coverage (Node ${{ matrix.node-version }})" >> $GITHUB_STEP_SUMMARY
5980
echo "" >> $GITHUB_STEP_SUMMARY
6081
6182
# SDK Coverage
6283
if [ -f "packages/b2c-tooling-sdk/coverage/lcov.info" ]; then
6384
echo "### @salesforce/b2c-tooling-sdk" >> $GITHUB_STEP_SUMMARY
64-
echo "" >> $GITHUB_STEP_SUMMARY
6585
echo '```' >> $GITHUB_STEP_SUMMARY
6686
cd packages/b2c-tooling-sdk && pnpm c8 report --reporter=text-summary 2>/dev/null | tail -n 6 >> $GITHUB_STEP_SUMMARY
6787
cd ../..
@@ -72,9 +92,18 @@ jobs:
7292
# CLI Coverage
7393
if [ -f "packages/b2c-cli/coverage/lcov.info" ]; then
7494
echo "### @salesforce/b2c-cli" >> $GITHUB_STEP_SUMMARY
75-
echo "" >> $GITHUB_STEP_SUMMARY
7695
echo '```' >> $GITHUB_STEP_SUMMARY
7796
cd packages/b2c-cli && pnpm c8 report --reporter=text-summary 2>/dev/null | tail -n 6 >> $GITHUB_STEP_SUMMARY
7897
cd ../..
7998
echo '```' >> $GITHUB_STEP_SUMMARY
8099
fi
100+
101+
- name: Upload coverage reports
102+
if: always() && steps.sdk-test.conclusion != 'cancelled'
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: coverage-reports-node-${{ matrix.node-version }}
106+
path: |
107+
packages/b2c-tooling-sdk/coverage/
108+
packages/b2c-cli/coverage/
109+
retention-days: 30

packages/b2c-cli/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/tmp
88
/node_modules
99
/coverage
10+
test-results.json
1011
oclif.manifest.json
1112

1213

packages/b2c-cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"prepack": "oclif manifest && oclif readme",
119119
"pretest": "tsc --noEmit -p test",
120120
"test": "c8 env OCLIF_TEST_ROOT=. mocha --forbid-only \"test/**/*.test.ts\"",
121+
"test:ci": "c8 env OCLIF_TEST_ROOT=. mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
121122
"test:unit": "env OCLIF_TEST_ROOT=. mocha --forbid-only \"test/**/*.test.ts\"",
122123
"coverage": "c8 report",
123124
"version": "oclif readme && git add README.md",

packages/b2c-tooling-sdk/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/tmp
77
/node_modules
88
/coverage
9+
test-results.json
910

1011

1112
yarn.lock

packages/b2c-tooling-sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
"format:check": "prettier --check src",
165165
"pretest": "tsc --noEmit -p test",
166166
"test": "c8 mocha --forbid-only \"test/**/*.test.ts\"",
167+
"test:ci": "c8 mocha --forbid-only --reporter json --reporter-option output=test-results.json \"test/**/*.test.ts\"",
167168
"test:unit": "mocha --forbid-only \"test/**/*.test.ts\"",
168169
"coverage": "c8 report",
169170
"posttest": "pnpm run lint"

0 commit comments

Comments
 (0)