diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index d06e1df89b..e7e993e92a 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -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: @@ -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 diff --git a/content/about/coverage-and-quality/coverage-and-quality-report.html b/content/about/coverage-and-quality/coverage-and-quality-report.html index 4665cbffaa..d64352d9a3 100644 --- a/content/about/coverage-and-quality/coverage-and-quality-report.html +++ b/content/about/coverage-and-quality/coverage-and-quality-report.html @@ -17,6 +17,7 @@

Coverage and Quality Reports

+

Page last updated: February 13, 2024

About These Reports

diff --git a/package.json b/package.json index 9eab3e4b02..de39f188dc 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": { diff --git a/scripts/coverage-report.js b/scripts/coverage-report.js index 2244b571da..c11b240c53 100644 --- a/scripts/coverage-report.js +++ b/scripts/coverage-report.js @@ -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('', '\n') .replace( '', '\n' + ) + .replace( + '

Page last updated:

', + `

Page last updated: ${formattedDate}

` ); fs.writeFile(coverageReportPath, result, function (err) { diff --git a/scripts/coverage-report.template b/scripts/coverage-report.template index d575bdc47c..c4529e6edf 100644 --- a/scripts/coverage-report.template +++ b/scripts/coverage-report.template @@ -18,6 +18,7 @@

Coverage and Quality Reports

+

Page last updated:

About These Reports