Skip to content

Commit

Permalink
Lint the ultimate HTML generated for the site (#1235)
Browse files Browse the repository at this point in the history
* Lint generated HTML

* Freeze Linter version

* Correct Linter command

* Fix linter version

* Fix cleanup

* Code cleanup

* Change to new node version syntax
  • Loading branch information
tunetheweb authored Aug 21, 2020
1 parent 3f06faa commit 770621b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate_chapters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/[email protected]
with:
version: 12.x
node-version: 12.x
- name: Set up Python 3.7
uses: actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: |
echo "::set-env name=VALIDATE_ALL_CODEBASE::false"
- name: Lint Code Base
uses: docker://github/super-linter:v3
uses: github/super-linter@v3.7.0
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test_website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/[email protected]
with:
version: 12.x
node-version: 12.x
- name: Set up Python 3.7
uses: actions/[email protected]
with:
python-version: '3.7'
- name: Run the website
run: ./src/tools/scripts/run_and_test_website.sh
- name: Lint Generated HTML
uses: github/[email protected]
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_HTML: true
3 changes: 2 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.vscode/
node_modules/
node_modules/
static/html/
8 changes: 8 additions & 0 deletions src/tools/test/test_status_codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const default_year = 2019;
const default_language = 'en';
const base_url = "http://127.0.0.1:8080";

const output_dir = `static/html`;

let failures = 0;
let passes = 0;

Expand Down Expand Up @@ -44,6 +46,12 @@ const test_status_code = async (page, status, location) => {
if (response.status === status && response.headers.get('location') === location) {
console.log('Success - expected:', status, 'got:',response.status, 'for page:', page);
passes++;
if (status === 200 && response.headers.get('content-type').startsWith('text/html')) {
if (page.slice(-1) === '/') page = page + 'index';
page = page + '.html';
const body = await response.text();
await fs.outputFile(output_dir + page, body, 'utf8');
}
} else {
console.error('Failed - expected:', status, 'got:',response.status, 'for page:', page, 'location:', location);
failures++;
Expand Down

0 comments on commit 770621b

Please sign in to comment.