Sample autogenerated page rendering on PRs that don't touch pipelines… · mogya/github_docs@b8b56d4 · GitHub
Skip to content

Commit b8b56d4

Browse files
heiskrCopilot
andauthored
Sample autogenerated page rendering on PRs that don't touch pipelines (#63746)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 796e2742-a386-4cab-8cc3-be8fe189e974
1 parent ca2cb49 commit b8b56d4

4 files changed

Lines changed: 81 additions & 4 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 25 additions & 0 deletions

‎src/automated-pipelines/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ When creating a new pipeline, the source data that is being consumed may not hav
4444
- Each pipeline typically requires a workflow to allow scheduling or manually running the pipeline. The workflow should be placed in the `.github/workflows` directory and named `sync-<pipeline-name>.ts`. Each workflow typically requires adding a manual run option and an input parameter to specify the source repo's branch to use.
4545
- Each pipeline will need a `scripts` directory with (at minimum) a `scripts/sync.ts` file to run the pipeline.
4646
- If the pipeline will contain structured data, you will need to add a `src/<pipeline-name>/data` directory. The files inside the `data` directory are typically organized by version (e.g., `src/webhooks/data/fpt/*`).
47-
- Pipelines typically have tests specific to the pipeline that are placed in the `src/<pipeline-name>/tests` directory. There is no need to add tests that render the page because all autogenerated pages are tested in `src/automated-pipelines/tests/rendering.ts`.
47+
- Pipelines typically have tests specific to the pipeline that are placed in the `src/<pipeline-name>/tests` directory. There is no need to add tests that render the page because all autogenerated pages are tested in `src/automated-pipelines/tests/rendering.ts`. Add the new `src/<pipeline-name>/**` path to the "Check for automated pipeline changes" step in `.github/workflows/test.yml` so PRs that change the pipeline render every page.
4848
- If the pipeline uses a Next.js page component (e.g., `pages/**/*.tsx`), ensure there is a test that fails if that page component is moved or deleted.
4949

5050
## How to get help
@@ -175,6 +175,12 @@ All autogenerated pages tested in `src/automated-pipelines/tests/rendering.ts`:
175175
- Links are valid
176176
- Schema validation
177177

178+
The merge queue and PRs that change pipeline code or generated REST, GraphQL, or CodeQL CLI content render every autogenerated page. Other PRs and local runs render the pages in `PINNED_PAGES` in `src/automated-pipelines/tests/rendering.ts`, and every page for generators not listed there. To render every page locally, run:
179+
180+
```bash
181+
AUTOGENERATED_RENDER_ALL=true npm test -- src/automated-pipelines/tests/rendering.ts
182+
```
183+
178184
### Pipeline-specific tests
179185

180186
Each pipeline in `src/<pipeline-name>/tests/` should test:

‎src/automated-pipelines/tests/rendering.ts‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { get } from '@/tests/helpers/e2etest'
99
type Page = {
1010
autogenerated?: string
1111
fullPath: string
12+
relativePath: string
1213
permalinks: Array<{ href: string }>
1314
versions: {
1415
feature?: string | string[]
@@ -18,16 +19,61 @@ type Page = {
1819

1920
const pageList: Page[] = await loadPages(undefined, ['en'])
2021

22+
// CI sets AUTOGENERATED_RENDER_ALL in the merge queue and on PRs that change pipeline code or output.
23+
// Otherwise, render a fixed set of pages per generator to keep local runs and PRs fast.
24+
const RENDER_ALL = process.env.AUTOGENERATED_RENDER_ALL === 'true'
25+
26+
// Paths are relative to content/. Generators not listed here render every page.
27+
// Pick pages that use the generator's main page layout, not index pages.
28+
const PINNED_PAGES: Record<string, string[]> = {
29+
'codeql-cli': [
30+
'code-security/reference/code-scanning/codeql/codeql-cli-manual/database-analyze.md',
31+
'code-security/reference/code-scanning/codeql/codeql-cli-manual/database-create.md',
32+
'code-security/reference/code-scanning/codeql/codeql-cli-manual/github-merge-results.md',
33+
],
34+
'github-apps': [
35+
'rest/authentication/endpoints-available-for-github-app-installation-access-tokens.md',
36+
'rest/authentication/permissions-required-for-fine-grained-personal-access-tokens.md',
37+
'rest/authentication/permissions-required-for-github-apps.md',
38+
],
39+
graphql: [
40+
'graphql/overview/breaking-changes.md',
41+
'graphql/overview/changelog/2025.md',
42+
'graphql/reference/repos.md',
43+
],
44+
rest: ['rest/actions/workflow-runs.md', 'rest/issues/issues.md', 'rest/repos/repos.md'],
45+
}
46+
47+
function pagesToRender(generator: string, pages: Page[]): { render: Page[]; missing: string[] } {
48+
const pinned = PINNED_PAGES[generator] ?? []
49+
const byPath = new Map(pages.map((page) => [page.relativePath, page]))
50+
// Check pins in full-render mode too, so a PR that moves a pinned page fails before merge.
51+
const missing = pinned.filter((path) => !byPath.has(path))
52+
if (RENDER_ALL || !pinned.length) return { render: pages, missing }
53+
return { render: pinned.flatMap((path) => byPath.get(path) ?? []), missing }
54+
}
55+
2156
describe('autogenerated docs render', () => {
2257
vi.setConfig({ testTimeout: 3 * 60 * 1000 })
2358

2459
const autogeneratedPages = pageList.filter((page: Page) => page.autogenerated)
60+
const pagesByGenerator = Object.groupBy(autogeneratedPages, (page: Page) => page.autogenerated!)
61+
// Include pinned generators with no pages left, so their stale pins still fail.
62+
const generators = new Set([...Object.keys(pagesByGenerator), ...Object.keys(PINNED_PAGES)])
63+
const generatorCases = [...generators].map(
64+
(generator) => [generator, pagesByGenerator[generator] ?? []] as const,
65+
)
2566

26-
test('all automated pages', async () => {
67+
test.each(generatorCases)('%s pages', async (generator, allPages) => {
68+
const { render: pages, missing } = pagesToRender(generator, allPages)
69+
expect(
70+
missing,
71+
`Pinned ${generator} pages not found. Update PINNED_PAGES in this file.`,
72+
).toEqual([])
2773
// Each page must render with 200 OK and unique heading IDs.
2874
const errors = (
2975
await Promise.all(
30-
autogeneratedPages.map(async (page: Page) => {
76+
pages.map(async (page: Page) => {
3177
const url = page.permalinks[0].href
3278
// Slow autogenerated pages get retries to avoid false-positive failures.
3379
const res = await get(url, { retries: 3 })

‎src/tests/SUITES.md‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)