Skip to content

Commit

Permalink
Infrastructure: Format PR comments containing regression coverage rep…
Browse files Browse the repository at this point in the history
…orts with markdown (pull #1562)

The regression test coverage report lists keyboard commands, roles, and states missing tests.
It runs against pull requests and adds a comment containing the report.
This commit implements formatting of those PR comments using markdown.

Co-authored-by: Matt King <[email protected]>
  • Loading branch information
spectranaut and mcking65 authored Oct 22, 2020
1 parent a9bb774 commit c4d8d14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const commentBody = '```' + fs.readFileSync('coverage.log', 'utf8') + '```';
const commentBody = fs.readFileSync('coverage.log', 'utf8');
if (commentBody.length === 0) {
return
Expand Down
27 changes: 15 additions & 12 deletions test/util/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,32 +235,32 @@ for (let example in exampleCoverage) {
let exampleName = example;

if (existingTestIds === missingTests) {
examplesWithNoTestsReport += exampleName + '\n';
examplesWithNoTestsReport += '- ' + exampleName + '\n';
examplesWithNoTests++;
} else if (missingTests) {
examplesMissingSomeTestsReport += exampleName + ':\n';
examplesMissingSomeTestsReport += '- ' + exampleName + ':\n';

for (let testId of exampleCoverage[example].missingTests) {
examplesMissingSomeTestsReport += ' ' + testId + '\n';
examplesMissingSomeTestsReport += ' - ' + testId + '\n';
}

examplesMissingSomeTests += 1;
missingTestIds += missingTests;
}

if (missingKeys || missingAttrs) {
missingTestIdsReport += exampleName + '\n';
missingTestIdsReport += '- ' + exampleName + '\n';
if (missingKeys) {
missingTestIdsReport += ' "Keyboard Support" table(s):\n';
missingTestIdsReport += ' - "Keyboard Support" table(s):\n';
for (let row of exampleCoverage[example].missingKeys) {
missingTestIdsReport += ' ' + row + '\n';
missingTestIdsReport += ' - ' + row + '\n';
}
}

if (missingAttrs) {
missingTestIdsReport += ' "Attributes" table(s):\n';
missingTestIdsReport += ' - "Attributes" table(s):\n';
for (let row of exampleCoverage[example].missingAttrs) {
missingTestIdsReport += ' ' + row + '\n';
missingTestIdsReport += ' - ' + row + '\n';
}
}
}
Expand All @@ -277,14 +277,17 @@ fs.readdirSync(testsPath).forEach(function (testFile) {
}
});

console.log('\nExamples without any regression tests:\n');
console.log('\n#### Regression test coverage:\n');
console.log('\n#### Examples without any regression tests:\n');
console.log(examplesWithNoTestsReport || 'None found.\n');
console.log('\nExamples missing some regression tests:\n');
console.log('\n#### Examples missing some regression tests:\n');
console.log(examplesMissingSomeTestsReport || 'None found.\n');
console.log('\nExamples documentation table rows without data-test-ids:\n');
console.log(
'\n#### Example pages with Keyboard or Attribute table rows that do not have data-test-ids:\n'
);
console.log(missingTestIdsReport || 'None found.\n');

console.log('SUMMARTY:\n');
console.log('#### SUMMARY:\n');
console.log(' ' + exampleFiles.length + ' example pages found.');
console.log(
' ' + examplesWithNoTests + ' example pages have no regression tests.'
Expand Down

0 comments on commit c4d8d14

Please sign in to comment.