Skip to content

Commit

Permalink
add linkchecking to test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenFluin committed Jul 20, 2021
1 parent 6a27b21 commit db151be
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ jobs:
- name: Install Dependencies
run: yarn
- name: Build
run: yarn build
run: yarn build
- name: Check Links
run: yarn linkcheck
36 changes: 36 additions & 0 deletions _tools/linkcheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { platform, exit } from 'process';
import { spawn } from 'child_process';

const server = spawn('yarn', ['serve'], {
stdio: ['ignore', 'pipe', 'ignore'],
});

let output = '';
server.stdout.on('data', (data) => {
console.log(data.toString());
output = output + data.toString();
if (output.indexOf('Serving files from') !== -1) {
let program;
if (platform === 'linux') {
program = 'linkcheck-linux';
} else if (platform === 'darwin') {
program = 'linkcheck';
} else {
program = 'linkcheck-win';
}
const checker = spawn(program, [':4200'], {
stdio: ['ignore', 'pipe', 'ignore'],
});
checker.stdout.on('data', (checkerData) => {
console.log(checkerData.toString());
});
checker.on('exit', (code, other) => {
console.log('linkcheck finished');
server.stdout.destroy();
server.kill();
checker.stdout.destroy();
checker.kill();
exit(code);
});
}
});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"serve": "NODE_ENV=development npx @11ty/eleventy --serve --port=4200",
"build": "rm -rf _site && npx @11ty/eleventy",
"deploy": "yarn build && firebase deploy",
"process": "yarn ts-node --skip-project _tools/process-data.ts"
"process": "yarn ts-node --skip-project _tools/process-data.ts",
"linkcheck": "yarn ts-node --skip-project _tools/linkcheck.ts"
},
"keywords": [
"chainlink",
Expand All @@ -21,6 +22,7 @@
"@readme/markdown": "^6.26.6",
"@readme/variable": "^13.0.0",
"@types/node": "^14.14.39",
"dart-linkcheck": "^2.0.15",
"date-fns": "^2.21.1",
"eleventy-plugin-youtube-embed": "^1.6.2",
"firebase-tools": "^9.8.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,11 @@ d@1, d@^1.0.1:
es5-ext "^0.10.50"
type "^1.0.1"

dart-linkcheck@^2.0.15:
version "2.0.15"
resolved "https://registry.yarnpkg.com/dart-linkcheck/-/dart-linkcheck-2.0.15.tgz#cd581c804cdea94194557b48a0a654341097f762"
integrity sha512-ZMvxkAyEpBTvBFk+DPjcK0ObNy8GM4gmrGG1qIu0EXb/zj25vjRWNnhLHKZw4JlOLo02oWlwDeqo98GuBlJcIg==

dashdash@^1.12.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
Expand Down

0 comments on commit db151be

Please sign in to comment.