Skip to content

Commit 16dbe83

Browse files
nschonniariellalgilmoremcking65
authored
Infrastructure: Workflow to auto-generate coverage and quality report on merge (#2122)
Closes #2061 * Updates github workflow * Adds last update date to report page --------- Co-authored-by: ariellalgilmore <[email protected]> Co-authored-by: Matt King <[email protected]>
1 parent e032502 commit 16dbe83

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

.github/workflows/examples.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ on:
99
- ".github/workflows/examples.yml"
1010
- "content/**/examples/**"
1111
- "scripts/reference-tables.*"
12+
- "scripts/coverage-report.*"
13+
- "coverage/**"
1214
pull_request:
1315
paths:
1416
- "package*.json"
1517
- ".github/workflows/examples.yml"
1618
- "content/**/examples/**"
1719
- "scripts/reference-tables.*"
20+
- "scripts/coverage-report.*"
21+
- "coverage/**"
1822

1923
jobs:
2024
examples:
@@ -36,3 +40,23 @@ jobs:
3640

3741
- name: Ensure no git changes
3842
run: git diff --exit-code
43+
44+
coverage:
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- uses: actions/checkout@v2
49+
50+
- name: Set up Node.js
51+
uses: actions/setup-node@v2
52+
with:
53+
cache: npm
54+
55+
- name: Install dependencies
56+
run: npm ci
57+
58+
- name: Generate coverage files
59+
run: npm run coverage-report
60+
61+
- name: Ensure no git changes
62+
run: git diff --exit-code

content/about/coverage-and-quality/coverage-and-quality-report.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<body>
1818
<main>
1919
<h1>Coverage and Quality Reports</h1>
20+
<p>Page last updated: February 13, 2024</p>
2021
<section>
2122
<h2>About These Reports</h2>
2223
<p>

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"lint:html": "npm run htmlhint && npm run vnu-jar",
1818
"lint:spelling": "cspell \"**/*.*\"",
1919
"link-checker": "node ./scripts/link-checker.js",
20+
"coverage-report": "node scripts/coverage-report.js",
2021
"reference-tables": "node scripts/reference-tables.js",
2122
"regression": "ava --timeout=1m",
2223
"regression-report": "node test/util/report",
@@ -69,7 +70,9 @@
6970
],
7071
"content/patterns/**/examples/*.html": [
7172
"npm run reference-tables",
72-
"git add content/index/index.html"
73+
"git add content/index/index.html",
74+
"npm run coverage-report",
75+
"git add coverage/"
7376
]
7477
},
7578
"ava": {

scripts/coverage-report.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,12 +1138,26 @@ $('#example_summary_prototype').html(countPrototype);
11381138
$('#example_summary_mouse').html(countMouse);
11391139
$('#example_summary_pointer').html(countPointer);
11401140

1141+
// Create a new Date object
1142+
var currentDate = new Date();
1143+
1144+
// Format the date as a string
1145+
const formattedDate = currentDate.toLocaleDateString('en-US', {
1146+
day: 'numeric',
1147+
month: 'long',
1148+
year: 'numeric',
1149+
});
1150+
11411151
// cheerio seems to fold the doctype lines despite the template
11421152
const result = $.html()
11431153
.replace('<!DOCTYPE html>', '<!DOCTYPE html>\n')
11441154
.replace(
11451155
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">',
11461156
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">\n'
1157+
)
1158+
.replace(
1159+
'<p>Page last updated: </p>',
1160+
`<p>Page last updated: ${formattedDate}</p>`
11471161
);
11481162

11491163
fs.writeFile(coverageReportPath, result, function (err) {

scripts/coverage-report.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<body>
1919
<main>
2020
<h1>Coverage and Quality Reports</h1>
21+
<p>Page last updated: </p>
2122
<section>
2223
<h2>About These Reports</h2>
2324
<p>

0 commit comments

Comments
 (0)