Repository navigation
Let the link exclusions expire when the repositories ship #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ChesterHsu
merged 3 commits into
main
from
fix/let-the-link-exclusions-expire-when-the-repos-ship
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "comment": [ | ||
| "Repositories the documentation already describes and links to, that are not", | ||
| "public yet. Their links 404 for a reader today, which is why the external", | ||
| "link check excludes them.", | ||
| "", | ||
| "The exclusion is meant to expire. check-unpublished-links.mjs fails once a", | ||
| "repository here answers publicly, because at that moment the exclusion is", | ||
| "hiding a link that works and the docs should be checked against it again.", | ||
| "", | ||
| "Removing a repository from this list means removing its --exclude from the", | ||
| "lychee step in .github/workflows/seo.yml at the same time." | ||
| ], | ||
| "repositories": [ | ||
| { | ||
| "owner": "flytohub", | ||
| "name": "flyto-flow", | ||
| "reason": "Flow CE source-available publication is prepared but paused" | ||
| }, | ||
| { | ||
| "owner": "flytohub", | ||
| "name": "flyto-warroom", | ||
| "reason": "Warroom CE publication is prepared but paused" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Expire the external-link exclusions once the repositories behind them ship. | ||
| * | ||
| * The docs describe Flow CE and Warroom CE ahead of their publication, so those | ||
| * repository links 404 for a reader today and the lychee step excludes them. An | ||
| * exclusion that outlives its reason is worse than the 404 it hid: the day the | ||
| * repositories go public, nothing checks those links again and nobody | ||
| * remembers the flag is there. | ||
| * | ||
| * So this fails in exactly that case. While a repository is still private it | ||
| * says so and passes; the moment it answers publicly it fails and asks for the | ||
| * exclusion to be removed. | ||
| */ | ||
| import { readFileSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const configPath = path.join(root, 'config', 'unpublished-repos.json'); | ||
| const workflowPath = path.join(root, '.github', 'workflows', 'seo.yml'); | ||
|
|
||
| const config = JSON.parse(readFileSync(configPath, 'utf8')); | ||
| const repositories = config.repositories ?? []; | ||
| const workflow = readFileSync(workflowPath, 'utf8'); | ||
|
|
||
| const failures = []; | ||
| const notes = []; | ||
|
|
||
| // GitHub's own shape for an owner or repository name. Interpolating anything | ||
| // else would let an edit to the config file choose where this script sends a | ||
| // request -- a path traversal, or a whole other host smuggled through a name. | ||
| const SLUG = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,98}[A-Za-z0-9])?$/; | ||
|
|
||
| async function isPublic(owner, name) { | ||
| if (!SLUG.test(owner) || !SLUG.test(name)) { | ||
| throw new Error(`not a repository slug: ${JSON.stringify(`${owner}/${name}`)}`); | ||
| } | ||
| const url = new URL(`https://api.github.com/repos/${owner}/${name}`); | ||
| if (url.origin !== 'https://api.github.com' || !url.pathname.startsWith('/repos/')) { | ||
| throw new Error(`refusing to request ${url.origin}${url.pathname}`); | ||
| } | ||
| const response = await fetch(url, { | ||
| headers: { Accept: 'application/vnd.github+json', 'User-Agent': 'flyto-docs-link-audit' }, | ||
| redirect: 'error', | ||
| }); | ||
| if (response.status === 404) return false; | ||
| if (response.status === 200) return true; | ||
| // Rate limiting or an outage must not turn into a false "now public", and | ||
| // must not silently pass either. | ||
| throw new Error(`GitHub answered ${response.status} for ${owner}/${name}`); | ||
| } | ||
|
|
||
| for (const entry of repositories) { | ||
| const { owner, name } = entry; | ||
| const slug = `${owner}/${name}`; | ||
| if (!workflow.includes(name)) { | ||
| failures.push(`${slug} is listed as unpublished but no lychee --exclude mentions it`); | ||
| continue; | ||
| } | ||
| let published; | ||
| try { | ||
| published = await isPublic(owner, name); | ||
| } catch (error) { | ||
| failures.push(`could not determine visibility of ${slug}: ${error.message}`); | ||
| continue; | ||
| } | ||
| if (published) { | ||
| failures.push( | ||
| `${slug} is public now. Remove its --exclude from .github/workflows/seo.yml and its entry ` + | ||
| `from config/unpublished-repos.json so the docs links to it are checked again.`, | ||
| ); | ||
| } else { | ||
| notes.push(`${slug} is still private (${entry.reason ?? 'no reason recorded'})`); | ||
| } | ||
| } | ||
|
|
||
| if (failures.length > 0) { | ||
| console.error('unpublished link exclusions need attention:'); | ||
| for (const failure of failures) console.error(`- ${failure}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log(`unpublished link exclusions still apply: ${repositories.length} repository(ies)`); | ||
| for (const note of notes) console.log(` ${note}`); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.