@@ -61,20 +61,29 @@ jobs:
6161 npx playwright install --with-deps
6262 npx puppeteer browsers install chrome
6363 - name : Run tests
64+ id : tests
6465 run : npm run test:all
65- - name : Generate coverage report info
66- if : github.actor != 'dependabot[bot]'
67- id : coverage-info
66+ - name : Generate coverage info
67+ if : >
68+ !cancelled() && github.actor != 'dependabot[bot]' && (
69+ steps.tests.conclusion == 'failure' ||
70+ steps.tests.outcome == 'success'
71+ )
72+ id : coverage
6873 run : |
74+ SOURCE='./coverage/lcov-report/'
75+ if [ ! -f "$SOURCE/index.html" ]; then
76+ echo "No coverage report found."
77+ exit 1
78+ fi
6979 COMMON_PATH="$GITHUB_REPOSITORY/$GITHUB_RUN_ID/$GITHUB_RUN_ATTEMPT/$GITHUB_JOB"
7080 DESTINATION="s3://test-reporting-coverage/$COMMON_PATH/"
71- SOURCE='./coverage/lcov-report/'
7281 URL="https://test-reporting.d2l.dev/coverage/$COMMON_PATH/"
7382 echo "destination=$DESTINATION" >> $GITHUB_OUTPUT
7483 echo "source=$SOURCE" >> $GITHUB_OUTPUT
7584 echo "url=$URL" >> $GITHUB_OUTPUT
7685 - name : Assume role
77- if : github.actor != 'dependabot[bot] '
86+ if : (!cancelled()) && steps.coverage.outputs.source != ''
7887 uses : Brightspace/third-party-actions@aws-actions/configure-aws-credentials
7988 with :
8089 aws-access-key-id : ${{secrets.AWS_ACCESS_KEY_ID}}
@@ -83,51 +92,65 @@ jobs:
8392 aws-region : us-east-1
8493 role-to-assume : arn:aws:iam::427469055187:role/github+Brightspace+test-reporting-node
8594 role-duration-seconds : 3600
86- - name : Upload code coverage
87- if : github.actor != 'dependabot[bot] '
95+ - name : Upload coverage
96+ if : (!cancelled()) && steps.coverage.outputs.source != ''
8897 uses : BrightspaceUI/actions/publish-to-s3@main
8998 with :
90- bucket-path : ${{steps.coverage-info .outputs.destination}}
91- publish-directory : ${{steps.coverage-info .outputs.source}}
99+ bucket-path : ${{steps.coverage.outputs.destination}}
100+ publish-directory : ${{steps.coverage.outputs.source}}
92101 - name : Generate test summary
93- id : test-summary
102+ id : summary
103+ if : >
104+ !cancelled() && (
105+ steps.tests.conclusion == 'failure' ||
106+ steps.tests.outcome == 'success'
107+ )
94108 uses : Brightspace/third-party-actions@actions/github-script
95109 with :
96110 script : |
97111 const { env } = await import('node:process');
98- const { COVERAGE_REPORT_URL: coverageReportUrl } = env;
112+ const {
113+ COVERAGE_REPORT_URL: coverageReportUrl,
114+ REPORT_VALIDATION_RESULTS: reportValidationResultsPath
115+ } = env;
99116 const { summary } = core;
100117 summary.clear();
118+ summary.addHeading('Coverage Report', 3);
101119 if (coverageReportUrl) {
102- summary.addHeading('Coverage report', 3);
103120 summary.addLink('Report', coverageReportUrl);
121+ } else {
122+ summary.addRaw('No coverage report generated.', true);
123+ summary.addEOL();
104124 }
105- summary.addHeading('Generated reports', 3);
106- const reporters = [{
107- name: 'mocha',
108- path: './d2l-test-report-mocha.json'
109- }, {
110- name: 'playwright',
111- path: './d2l-test-report-playwright.json'
112- }, {
113- name: '@web/test-runner',
114- path: './d2l-test-report-web-test-runner.json'
115- }, {
116- name: 'webdriverio',
117- path: './d2l-test-report-webdriverio.json'
118- }];
119- for (const { name, path } of reporters) {
120- let report = require(path);
121- report = JSON.stringify(report, null, 2);
122- report = `\n\n\`\`\`json\n${report}\n\`\`\`\n\n`;
123- summary.addDetails(name, report);
125+ summary.addHeading('Report Validation', 3);
126+ const validationResults = require(reportValidationResultsPath);
127+ for (const [framework, result] of Object.entries(validationResults)) {
128+ const { path, exists, schema, contents } = result;
129+ const failed = !exists || !schema || !contents;
130+ const headerIcon = failed ? ':red_circle:' : ':green_circle:';
131+ const header = `${framework} ${headerIcon}`;
132+ let body = '<br/>\n\n';
133+ if (exists) {
134+ const schemaIcon = schema ? ':green_circle:' : ':red_circle:';
135+ body += `Schema: ${schemaIcon}\n`;
136+ const contentsIcon = contents ? ':green_circle:' : ':red_circle:';
137+ body += `Contents: ${contentsIcon}\n\n`;
138+ const reportContents = JSON.stringify(require(path), null, 2);
139+ body += `\`\`\`json\n${reportContents}\n\`\`\``;
140+ } else {
141+ body += 'No report generated :warning:';
142+ }
143+ body += '\n\n';
144+ summary.addDetails(header, body);
124145 }
125146 summary.write({ overwrite: true });
126147 core.setOutput('report', summary.stringify());
127148 env :
128- COVERAGE_REPORT_URL : ${{steps.coverage-info.outputs.url}}
149+ COVERAGE_REPORT_URL : ${{steps.coverage.outputs.url}}
150+ REPORT_VALIDATION_RESULTS : ./report-validation-results.json
129151 - name : Leave comment
152+ if : (!cancelled()) && steps.summary.outcome == 'success'
130153 uses : BrightspaceUI/actions/comment-on-pr@main
131154 with :
132- message : ${{steps.test- summary.outputs.report}}
155+ message : ${{steps.summary.outputs.report}}
133156 post-mode : hide-previous
0 commit comments