diff --git a/.github/actions/rendered-content-link-checker.js b/.github/actions/rendered-content-link-checker.js index d2b49b5524..f60324e8b5 100755 --- a/.github/actions/rendered-content-link-checker.js +++ b/.github/actions/rendered-content-link-checker.js @@ -140,6 +140,7 @@ if (import.meta.url.endsWith(process.argv[1])) { * verbose {boolean} - Set to true for more verbose logging * random {boolean} - Randomize page order for debugging when true * patient {boolean} - Wait longer and retry more times for rate-limited external URLS + * bail {boolean} - Throw an error on the first page (not permalink) that has >0 flaws * */ async function main(core, octokit, uploadArtifact, opts = {}) { @@ -529,7 +530,7 @@ function getPages(pageList, languages, filters, files, max) { } async function processPage(core, page, pageMap, redirects, opts) { - const { verbose, verboseUrl } = opts + const { verbose, verboseUrl, bail } = opts const allFlawsEach = await Promise.all( page.permalinks.map((permalink) => { @@ -543,6 +544,13 @@ async function processPage(core, page, pageMap, redirects, opts) { if (verbose) { printFlaws(core, allFlaws, { verboseUrl }) } + + if (bail) { + if (!verbose) { + console.warn('Use --verbose to see the flaws before it exits') + } + throw new Error(`More than one flaw in ${page.relativePath}`) + } } return allFlaws diff --git a/lib/excluded-links.js b/lib/excluded-links.js index 0f659d66c4..0f80af68d3 100644 --- a/lib/excluded-links.js +++ b/lib/excluded-links.js @@ -14,6 +14,13 @@ export default [ new RegExp('https://github\\.com/search\\?'), new RegExp('https://github\\.com/github/gitignore/search\\?'), + // https://github.com/contact always redirects to support.github.com that + // is heavily protected by rate limiting. + new RegExp('https://github\\.com/contact'), + // All support.github.com links are currently firewalled and you get a + // "403 Forbidden" every time. + new RegExp('https://support\\.github\\.com'), + // These links require auth. new RegExp('https://github\\.com/settings/profile'), new RegExp('https://github\\.com/github/docs/edit'), diff --git a/script/rendered-content-link-checker.js b/script/rendered-content-link-checker.js index 92bd80ea59..afa54806c1 100755 --- a/script/rendered-content-link-checker.js +++ b/script/rendered-content-link-checker.js @@ -66,6 +66,7 @@ program .option('--debug', "Loud about everything it's doing") .option('--patient', 'Give external link checking longer timeouts and more retries') .option('--random', 'Load pages in a random order (useful for debugging)') + .option('--bail', 'Exit on the first possible flaw') .option('--verbose-url ', 'Print the absolute URL if set') .option('--fail-on-flaw', 'Throw error on link flaws (default: false)') .option('--max ', 'integer argument (default: none)', (value) => {