Merge pull request #17505 from github/parallelize-link-check-workflows
Parallelize link check workflows
This commit is contained in:
57
.github/workflows/link-check-dotcom.yml
vendored
Normal file
57
.github/workflows/link-check-dotcom.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: 'Link Checker: Dotcom'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
see_if_should_skip:
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
# Map a step output to a job output
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
||||
steps:
|
||||
- id: skip_check
|
||||
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
|
||||
with:
|
||||
cancel_others: 'false'
|
||||
github_token: ${{ github.token }}
|
||||
paths: '[".github/workflows/link-check-dotcom.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
|
||||
build:
|
||||
needs: see_if_should_skip
|
||||
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
|
||||
steps:
|
||||
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
|
||||
# Even if if doesn't do anything
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Checkout
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Setup node
|
||||
uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e
|
||||
with:
|
||||
node-version: 14.x
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Install
|
||||
run: npm ci
|
||||
|
||||
## TODO
|
||||
# - if: ${{ github.repository == 'github/docs-internal' && needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
# name: Clone early access
|
||||
# run: npm run heroku-postbuild
|
||||
# env:
|
||||
# DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
|
||||
# GIT_BRANCH: ${{ github.ref }}
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Build
|
||||
run: npm run build
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: 'Link check: Dotcom'
|
||||
env:
|
||||
DOCS_VERSION: 'dotcom'
|
||||
run: npm run link-check
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Link Checker
|
||||
name: 'Link Checker: GitHub AE'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
with:
|
||||
cancel_others: 'false'
|
||||
github_token: ${{ github.token }}
|
||||
paths: '[".github/workflows/link-check-test.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
|
||||
paths: '[".github/workflows/link-check-ghae.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
|
||||
build:
|
||||
needs: see_if_should_skip
|
||||
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
|
||||
@@ -51,5 +51,7 @@ jobs:
|
||||
run: npm run build
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Link check
|
||||
name: 'Link check: GitHub AE'
|
||||
env:
|
||||
DOCS_VERSION: 'github-ae'
|
||||
run: npm run link-check
|
||||
57
.github/workflows/link-check-ghes.yml
vendored
Normal file
57
.github/workflows/link-check-ghes.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: 'Link Checker: Enterprise Server'
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
see_if_should_skip:
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
# Map a step output to a job output
|
||||
outputs:
|
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
||||
steps:
|
||||
- id: skip_check
|
||||
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
|
||||
with:
|
||||
cancel_others: 'false'
|
||||
github_token: ${{ github.token }}
|
||||
paths: '[".github/workflows/link-check-ghes.yml", "assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
|
||||
build:
|
||||
needs: see_if_should_skip
|
||||
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
|
||||
steps:
|
||||
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
|
||||
# Even if if doesn't do anything
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Checkout
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Setup node
|
||||
uses: actions/setup-node@c46424eee26de4078d34105d3de3cc4992202b1e
|
||||
with:
|
||||
node-version: 14.x
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Install
|
||||
run: npm ci
|
||||
|
||||
## TODO
|
||||
# - if: ${{ github.repository == 'github/docs-internal' && needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
# name: Clone early access
|
||||
# run: npm run heroku-postbuild
|
||||
# env:
|
||||
# DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
|
||||
# GIT_BRANCH: ${{ github.ref }}
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: Build
|
||||
run: npm run build
|
||||
|
||||
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
||||
name: 'Link check: Enterprise Server'
|
||||
env:
|
||||
DOCS_VERSION: 'enterprise-server'
|
||||
run: npm run link-check
|
||||
@@ -2,14 +2,16 @@
|
||||
|
||||
const linkinator = require('linkinator')
|
||||
const checker = new linkinator.LinkChecker()
|
||||
const { deprecated } = require('../lib/enterprise-server-releases')
|
||||
const { deprecated, latest } = require('../lib/enterprise-server-releases')
|
||||
const englishRoot = 'http://localhost:4002/en'
|
||||
const allowedVersions = ['dotcom', 'enterprise-server', 'github-ae']
|
||||
|
||||
// [start-readme]
|
||||
//
|
||||
// This script runs in CI via GitHub Action to check all *internal* links in English content,
|
||||
// not including deprecated Enterprise Server content. This is different from script/check-english-links.js,
|
||||
// which checks *all* links in the site, both internal and external, and is much slower.
|
||||
// This script runs in CI via GitHub Action to check all *internal* links in English content for a
|
||||
// given version, not including deprecated Enterprise Server content. This is different from
|
||||
// script/check-english-links.js, which checks *all* links in the site, both internal and external,
|
||||
// and is much slower.
|
||||
//
|
||||
// If you want to run it locally, you must have a local server running. You can use `npm run link-check`.
|
||||
//
|
||||
@@ -31,14 +33,34 @@ const config = {
|
||||
// Skip dist files
|
||||
'/dist/index.*',
|
||||
// Skip deprecated Enterprise content
|
||||
`enterprise(-server@|/)(${deprecated.join('|')})/?`
|
||||
`enterprise(-server@|/)(${deprecated.join('|')})(/|$)`
|
||||
]
|
||||
}
|
||||
|
||||
// Customize config for specific versions
|
||||
if (process.env.DOCS_VERSION === 'dotcom') {
|
||||
// If Dotcom, skip Enterprise Server and GitHub AE links
|
||||
config.linksToSkip.push('^.*/enterprise-server@.*$', '^.*/enterprise/.*$', '^.*/github-ae@latest.*$')
|
||||
} else if (process.env.DOCS_VERSION === 'enterprise-server') {
|
||||
// If Enterprise Server, skip links that are not Enterprise Server links
|
||||
config.path = `${englishRoot}/enterprise-server@${latest}`
|
||||
config.linksToSkip.push('^((?!enterprise-server@).)*$')
|
||||
} else if (process.env.DOCS_VERSION === 'github-ae') {
|
||||
// If GitHub AE, skip links that are not GitHub AE links
|
||||
config.path = `${englishRoot}/github-ae@latest`
|
||||
config.linksToSkip.push('^((?!github-ae@latest).)*$')
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
async function main () {
|
||||
process.env.DOCS_VERSION && allowedVersions.includes(process.env.DOCS_VERSION)
|
||||
? console.log(`Checking internal links for version ${process.env.DOCS_VERSION}!\n`)
|
||||
: console.log('Checking internal links for all versions!\n')
|
||||
|
||||
console.time('check')
|
||||
const result = (await checker.check(config)).links
|
||||
console.timeEnd('check')
|
||||
|
||||
const brokenLinks = result
|
||||
.filter(link => link.state === 'BROKEN')
|
||||
|
||||
Reference in New Issue
Block a user