Skip to content

Commit

Permalink
Infrastructure: Workflow to auto-generate coverage and quality report…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
3 people authored Feb 20, 2024
1 parent e032502 commit 16dbe83
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ on:
- ".github/workflows/examples.yml"
- "content/**/examples/**"
- "scripts/reference-tables.*"
- "scripts/coverage-report.*"
- "coverage/**"
pull_request:
paths:
- "package*.json"
- ".github/workflows/examples.yml"
- "content/**/examples/**"
- "scripts/reference-tables.*"
- "scripts/coverage-report.*"
- "coverage/**"

jobs:
examples:
Expand All @@ -36,3 +40,23 @@ jobs:

- name: Ensure no git changes
run: git diff --exit-code

coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
cache: npm

- name: Install dependencies
run: npm ci

- name: Generate coverage files
run: npm run coverage-report

- name: Ensure no git changes
run: git diff --exit-code
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<body>
<main>
<h1>Coverage and Quality Reports</h1>
<p>Page last updated: February 13, 2024</p>
<section>
<h2>About These Reports</h2>
<p>
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint:html": "npm run htmlhint && npm run vnu-jar",
"lint:spelling": "cspell \"**/*.*\"",
"link-checker": "node ./scripts/link-checker.js",
"coverage-report": "node scripts/coverage-report.js",
"reference-tables": "node scripts/reference-tables.js",
"regression": "ava --timeout=1m",
"regression-report": "node test/util/report",
Expand Down Expand Up @@ -69,7 +70,9 @@
],
"content/patterns/**/examples/*.html": [
"npm run reference-tables",
"git add content/index/index.html"
"git add content/index/index.html",
"npm run coverage-report",
"git add coverage/"
]
},
"ava": {
Expand Down
14 changes: 14 additions & 0 deletions scripts/coverage-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,12 +1138,26 @@ $('#example_summary_prototype').html(countPrototype);
$('#example_summary_mouse').html(countMouse);
$('#example_summary_pointer').html(countPointer);

// Create a new Date object
var currentDate = new Date();

// Format the date as a string
const formattedDate = currentDate.toLocaleDateString('en-US', {
day: 'numeric',
month: 'long',
year: 'numeric',
});

// cheerio seems to fold the doctype lines despite the template
const result = $.html()
.replace('<!DOCTYPE html>', '<!DOCTYPE html>\n')
.replace(
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">',
'<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">\n'
)
.replace(
'<p>Page last updated: </p>',
`<p>Page last updated: ${formattedDate}</p>`
);

fs.writeFile(coverageReportPath, result, function (err) {
Expand Down
1 change: 1 addition & 0 deletions scripts/coverage-report.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<body>
<main>
<h1>Coverage and Quality Reports</h1>
<p>Page last updated: </p>
<section>
<h2>About These Reports</h2>
<p>
Expand Down

0 comments on commit 16dbe83

Please sign in to comment.