Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add periodic check on base URL #192

Merged
merged 2 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/incorrect-base-url.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: New specs for review
assignees: tidoust, dontcallmedom
labels: bug
---
[check-base-url](../blob/master/src/check-base-url.js) has detected that the base URL of the following specifications is not the expected one:

{{ env.check_list }}

Please review the above list. For each specification, consider updating the URL in [specs.json](../blob/master/specs.json) or fixing the info at the source (the W3C API, Specref, or the spec itself). If the discrepancy seems warranted, the specification should be hardcoded as an exception to the rule in the [check-base-url](../blob/master/src/check-base-url.js) script.
23 changes: 23 additions & 0 deletions .github/workflows/check-base-url.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check base URL

on:
schedule:
- cron: '30 0 * * 1'
jobs:
find-specs:
name: Check base URL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm install
- run: node src/check-base-url.js # sets check_list env variable
- uses: JasonEtco/create-an-issue@v2
if: ${{ env.check_list }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/incorrect-base-url.md
28 changes: 28 additions & 0 deletions src/check-base-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* CLI tool that parses the generated index of specifications to make sure that
* the base URL either matches the release URL if there is one, or the nightly
* URL otherwise.
*
* The CLI tool returns Markdown that can typically be used to create an issue.
* It also sets a check_list environment variable that can be used in GitHub
* actions.
*
* No content is returned when everything looks good.
*/

const core = require("@actions/core");
const specs = require("../index.json");

const problems = specs
.filter(s => (s.release && s.url !== s.release.url) || (!s.release && s.url !== s.nightly.url))
.map(s => {
const expected = s.release ? "release" : "nightly";
const expectedUrl = s.release ? s.release.url : s.nightly.url;
return `- [ ] [${s.title}](${s.url}): expected ${expected} URL ${expectedUrl} but base URL is ${s.url}`;
});

if (problems.length > 0) {
const res = problems.join("\n");
core.exportVariable("check_list", res);
console.log(res);
}