From 46c701b8638815d9c880c3361eaa27fe45c453ad Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 13 Jun 2022 08:59:16 -0400 Subject: [PATCH] DISABLE_REWRITE_ASSET_URLS for some Actions (#28165) --- .github/workflows/check-all-english-links.yml | 2 ++ .github/workflows/link-check-all.yml | 6 ++++++ lib/render-content/create-processor.js | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-all-english-links.yml b/.github/workflows/check-all-english-links.yml index 75294e403d..ef7c53818a 100644 --- a/.github/workflows/check-all-english-links.yml +++ b/.github/workflows/check-all-english-links.yml @@ -56,6 +56,8 @@ jobs: # The default is 10s. But because this runs overnight, we can # be a lot more patient. REQUEST_TIMEOUT: 20000 + # Don't care about CDN caching image URLs + DISABLE_REWRITE_ASSET_URLS: true # The default is 300 which works OK on a fast macbook pro # but so well in Actions. LINKINATOR_CONCURRENCY: 100 diff --git a/.github/workflows/link-check-all.yml b/.github/workflows/link-check-all.yml index c8fa5c9075..8cbdac109d 100644 --- a/.github/workflows/link-check-all.yml +++ b/.github/workflows/link-check-all.yml @@ -49,6 +49,9 @@ jobs: run: cat $HOME/files.json - name: Link check (warnings, changed files) + env: + # Don't care about CDN caching image URLs + DISABLE_REWRITE_ASSET_URLS: true run: | ./script/rendered-content-link-checker.mjs \ --language en \ @@ -59,6 +62,9 @@ jobs: --list $HOME/files.json - name: Link check (critical, all files) + env: + # Don't care about CDN caching image URLs + DISABLE_REWRITE_ASSET_URLS: true run: | ./script/rendered-content-link-checker.mjs \ --language en \ diff --git a/lib/render-content/create-processor.js b/lib/render-content/create-processor.js index 4adafd2169..1bb588a24a 100644 --- a/lib/render-content/create-processor.js +++ b/lib/render-content/create-processor.js @@ -25,6 +25,14 @@ import wrapInElement from './plugins/wrap-in-element.js' import doctocatLinkIcon from './doctocat-link-icon.js' const graphql = HighlightjsGraphql.definer +// The rewrite-asset-urls plugin is nice because it makes the `` +// tags use unique URLs so they can be aggressively cached in the +// CDN. But it might not always make sense to bother. For example, in +// some CI where you're rendering lots of content and don't care +// about aggressive CDN caching at all. E.g. Actions that do link checking +// on rendered HTML. +const DISABLE_REWRITE_ASSET_URLS = JSON.parse(process.env.DISABLE_REWRITE_ASSET_URLS || 'false') + export default function createProcessor(context) { return unified() .use(process.env.COMMONMARK ? markdownNext : markdown) @@ -46,7 +54,7 @@ export default function createProcessor(context) { .use(raw) .use(rewriteLegacyAssetPaths, context) .use(wrapInElement, { selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' }) - .use(rewriteImgSources) + .use(DISABLE_REWRITE_ASSET_URLS ? null : rewriteImgSources) .use(rewriteLocalLinks, { languageCode: context.currentLanguage, version: context.currentVersion,