Repository navigation
Fix Pre-generate Contributor Data - #1803
David Pine (IEvangelist) merged 4 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation removes build-time network access while providing validated, automated contributor-data refreshes.
Review effort: Balanced
Findings: None
What changed in this PR
Pre-generates contributor data so Astro builds no longer depend on GitHub API availability.
Changes:
- Adds a paginated contributor-data updater and committed JSON snapshot.
- Renders contributor lists from local data and removes runtime fetching/caching.
- Integrates contributor refreshes into automation with validation tests.
| File | Description |
|---|---|
.github/instructions/astro.instructions.md |
Documents contributor data updates. |
.github/workflows/update-integration-data.yml |
Supplies authentication and stages generated data. |
src/frontend/astro.config.mjs |
Removes the contributor cache integration. |
src/frontend/package.json |
Adds contributor update commands. |
src/frontend/scripts/check-data-files.mjs |
Requires generated contributor data. |
src/frontend/scripts/update-contributors.ts |
Fetches, validates, and writes contributor data. |
src/frontend/scripts/update-integration-data.ps1 |
Includes contributor data in automation. |
src/frontend/src/components/ContributorList.astro |
Renders committed contributor data. |
src/frontend/src/content/i18n/en.json |
Removes obsolete unavailable-state translations. |
src/frontend/src/data/github-contributors.json |
Stores generated contributor records. |
src/frontend/src/utils/contributors.ts |
Removes build-time GitHub fetching and caching. |
src/frontend/tests/unit/contributor-list.vitest.test.ts |
Tests rendering, generation, and network guards. |
src/frontend/tests/unit/contributors.vitest.test.ts |
Removes obsolete runtime-fetch tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
I do really like this update, David Aniebo (@Webmekanic)! Let's get it cleaned up, resolve the conflicts, address the feedback. |
5913d9c to
8b63c20
Compare
I have resolved the conflicts and feedback. Kindly review. Thank you. David Pine (@IEvangelist) |
|
David Pine (@IEvangelist), I'm sure this is ready to be merged. |
|
David Pine (@IEvangelist), is there anything required from me here? |
CodeQL's js/incomplete-url-substring-sanitization flags includes() calls whose argument is a hostname literal. The build-time network guard scans source text for the host and does not validate a URL, so the alert is a false positive. Derive the host from a parsed URL instead; behavior is unchanged. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 081d2285-8343-442e-bdf1-2e09737e78b1
…tal builds (#1929) ## Summary <!-- Describe what this pull request changes and why. --> Explores incremental builds, parallel prerender and Bun together, based on `main`. Only the build changes are here; the hybrid API work stays in #1874, which targets `release/17.0`. An earlier version of this branch targeted `release/17.0` and also shared contributor fetches across prerender workers. `main` now pre-generates contributor data (#1803), so that change is dropped. - **Parallel prerender and incremental builds:** Sébastien Ros's #1927 (Astro 7.4 `experimental.parallelPrerender` and `incrementalBuild`, plus `cacheKey` refactors for the glossary, API and OG routes) is the first commit, applied unchanged with his authorship kept. Whichever of #1927 and this PR merges second rebases and drops it. This PR also fixes a quadratic comparison in `ts-api-route-catalog.vitest.test.ts` (about 34 s down to about 1.6 s in a local run). Astro is then bumped to 7.4.2 (the structured-clone patch is renamed and applies unchanged), and the TypeScript item Markdown routes now take an item index instead of the whole item: parallel prerender workers get a structured clone, so a slug lookup by identity fell back to the unsuffixed slug for a duplicate handle such as `thing-thing-2`. - **Bun replaces pnpm** (1.4.3) for installs and scripts. `bun.lock` is migrated from `pnpm-lock.yaml`, and the pnpm workspace settings move to `package.json` (`overrides`, `patchedDependencies`, `trustedDependencies`) and `bunfig.toml` (one-day release age gate). The `devalue` override from #1940 moves with them (`devalue@<5.9.3` resolves to 5.9.4). `patches/README.md` keeps the patch rationale that lived in `pnpm-workspace.yaml` comments. - **The production Astro build runs on the Bun runtime** (`bunx --bun astro build`). Dev, preview, Vitest, ESLint and Playwright stay on Node. Two Bun differences are handled in config: - `ec.config.mjs` imports the `starlight-plugin-icons` TypeScript source natively, because Bun has no Node module hooks, which `tsx` needs. - `astro.config.mjs` defaults `process.env.BASE_URL` to `/`. Bun resolves `import.meta.env` to `process.env`, and `starlight-links-validator` reads `import.meta.env.BASE_URL`, so without it `astro:build:done` crashed with `undefined is not an object (evaluating 'path.replace')`. - **CI:** `frontend-build`, `indexnow` and `update-integration-data` use the SHA-pinned `oven-sh/setup-bun` action (`bun-version-file` points at `src/frontend/package.json`), then `bun install --frozen-lockfile`. The CodeQL ADO pipeline, dev container and Dependabot (`bun` ecosystem) are converted too. - **Astro build cache in `frontend-build`:** `node_modules/.astro` is restored on every run (keyed on `bun.lock`, `astro.config.mjs` and the patches) so incremental builds can skip unchanged pages. It is saved only by push builds and by a PR build that found nothing to restore, so each PR commit doesn't write another entry against the 10 GB repo cache limit. The job summary reports the restored key, exact hit and size. - **`Frontend Build` runs on the 8-core runner.** The `build` job in `frontend-build.yml` uses `8-core-ubuntu-latest` (runner group `aspire-runners`, granted to this repository in microsoft/github-operations#1993) when the repository owner is `microsoft`, and `ubuntu-latest` otherwise, because forks can't use the label. The other jobs stay on `ubuntu-latest`. With the same four prerender workers, the cold build step went from 731 s to 296 s and the job from 968 s to 417 s (see the timings below). - **One flaky E2E test is fixed.** The `a missing live API stays disabled across navigation and visibility changes until reload` test in `live-status.spec.ts` failed on CI runners where the real WCP script shows its consent banner: the test helper rejects it, WCP reloads the page, and `/api/live/` is requested a second time. The test now aborts the WCP script, as other specs already do. - **Docs, agents and skills** now say Bun. In the contributor guide, the prerequisites list Bun, the pnpm | npm install tabs became one `bun install` step with a note (other package managers ignore `bun.lock` and the patches), and the `pnpm` commands became `bun run ...`. `CONTRIBUTING.md`, `CODESPACES.md`, the agent instructions and the skills match, and the pnpm card is gone from the thanks page. The contributor data hint in `ContributorList.astro` (and its unit test) now says `bun run update:contributors`. Timings (four prerender workers throughout; `ubuntu-latest` is 4 vCPU and 16 GB, `8-core-ubuntu-latest` is 8 vCPU and 32 GB). The `main` rows are push builds of `main`, which has sequential prerender, Node and no cache: | Run | Runner | Prerender | Astro build step | `Frontend Build` job | | --- | --- | --- | --- | --- | | `main` push `a62b64bec` (this PR's earlier base) | `ubuntu-latest` | 18 m 22 s | 1,252 s | 1,471 s | | `main` push `6be625cd0` (a fast runner) | `ubuntu-latest` | 12 m 13 s | 826 s | 976 s | | `main` push `3120da6c3` (a fast runner) | `ubuntu-latest` | 11 m 36 s | 786 s | 934 s | | This PR, cold (no cache) | `ubuntu-latest` | 9 m 36 s | 732 s | 963 s | | This PR, cold (no cache), after the rebase | `ubuntu-latest` | 9 m 33 s | 731 s | 968 s | | This PR, warm cache, same commit (re-run) | `ubuntu-latest` | 3 m 27 s | 438 s | 650 s | | This PR, cold (no cache) | `8-core-ubuntu-latest` | 3 m 53 s | 296 s | 417 s | | This PR, cold (no cache), after the Astro 7.4.2 bump | `8-core-ubuntu-latest` | 3 m 49 s | 386 s | 534 s | | This PR, warm cache, same commit (re-run) | `8-core-ubuntu-latest` | 3 m 15 s | 297 s | 485 s | On the 8-core runner the cold build step took 296 s against 731 s on `ubuntu-latest` for the same content and the same four workers, and the job 417 s against 968 s. That is more than the doubled vCPU count alone explains, and I didn't isolate why (the runner also has twice the memory). The cold artifact upload went from 171 s to 87 s and the cache save from 29 s to 6 s. The warm re-run on the 8-core runner took the same 297 s: prerender was 38 s faster, but Vite (38 s to 64 s) and Pagefind (43 s to 66 s) were each about 25 s slower, which looks like run-to-run noise in a single sample, and its artifact upload took 146 s. So on the larger runner the incremental cache gains little, while on `ubuntu-latest`, which forks fall back to, it saved about 5 min. A second cold run on the 8-core runner, after the Astro 7.4.2 bump, took 386 s for the build step and 534 s for the job: prerender took the same time (3 m 49 s), but Vite (54 s), Pagefind (52 s) and the artifact upload (109 s) were each slower, so read the 8-core figures as a range (417 to 534 s for the job). Runner speed varies a lot, so a single run says little. `Frontend Build` on `main` took 15.6 to 27.0 min over its last 20 pushes (median 23.5 min), and the cold run on `ubuntu-latest` (16 m 03 s) sits inside that spread, level with `main`'s two fastest pushes. The cold 8-core jobs (6 m 57 s and 8 m 54 s) are far below that spread. Prerender is the cleaner comparison on `ubuntu-latest`: 9 m 36 s here against 11 m 36 s to 18 m 22 s on `main`. The warm re-run on `ubuntu-latest` took 10 m 50 s. Prerender is the phase that moved; on `ubuntu-latest` Vite (about 70 s) and Pagefind (about 2 min over roughly 32k HTML files) don't change with parallelism or caching. On the 8-core runner the cold Astro build took 4 m 55 s (Vite 38 s, prerender 2 m 57 s, Pagefind 43 s). In the warm re-run on `ubuntu-latest` the Astro build took 7 m 17 s (Vite 1 m 10 s, prerender 3 m 27 s, Pagefind 2 m). It restored 48,685 of 57,144 routes from the cache (24,057 API reference pages, 24,094 reference `.md` endpoints and 534 OG images) and re-rendered 8,459, 7,546 of them locale pages. Those routes have no `cacheKey` and are the floor for a warm build. The cache entry is about 164 MB. `main` has no Astro cache entry yet, so the first push build after merge is cold and saves the entry that later PR builds restore. An earlier version of this branch, based on `release/17.0`, measured 447 s and 465 s for warm builds of new commits, so read the warm numbers as a range. The whole workflow gained less than the build job, because E2E dominates it now. Each of the six Playwright shards downloads the roughly 2.1 GB `frontend-dist` artifact (about 30 s to 13 min, depending on the run) and then runs Playwright for about 7 to 15 min, which this PR doesn't change. On `main` pushes `ci-gate` took 33.5 to 65.2 min over the last 20 (median 43.6 min). With the 8-core build the last shard finished about 37 min after the run started in attempt 1 (one shard spent 10 min installing Playwright Chromium) and about 28 min after in attempt 2, against about 33 and 38 min with the `ubuntu-latest` build on the previous head. All of these are inside `main`'s existing range, because the faster build only moves the point where the shards start. Speeding up E2E (more workers per shard, a compressed E2E artifact, the 8-core runner for the shards) is left out of this PR because it can affect test reliability or, for the 8-core runner, multiply the larger-runner minutes. ### Risks to watch in CI - The Bun-runtime build has passed CI on the current head (run `40014533725`, cold) and on the previous one (run `39981757109`, cold and warm), including the E2E shards on the Bun-built output. If it misbehaves later, fall back to Node for Astro only: change `bunx --bun astro build` to `astro build` in the three `build*` scripts and `scripts/build-static-host.mjs`. - About 8.5k routes (mostly locale pages) have no `cacheKey`, so they always re-render. That is the floor for a warm build. - `Frontend Build` now depends on the shared `aspire-runners` group (granted in microsoft/github-operations#1993, and also used by microsoft/aspire). A job whose runner label can't be served waits in the queue, and `timeout-minutes` only counts once it runs. Over a 12 h sample of microsoft/aspire (74 `8-core-ubuntu-latest` jobs) the queue time had a median of 5 s, a 95th percentile of 9 s and a maximum of 116 s, so contention looks low, but the sample was small and mostly off-peak. To fall back, change the `runs-on` line to `ubuntu-latest`. Larger runners are billed per minute, including in public repositories. - `PUBLIC_GIT_COMMIT_ID` (the merge base with `origin/main`) is rendered into every page: the footer, the commit link and `<meta name="git-commit-id">`, and client-side navigation between pages with different IDs falls back to a full page load (`deployment-guard.ts`). From reading Astro 7.4's incremental build code, I expected the dependency hash to ignore `.env`-derived values, so a page restored from the cache could keep an older commit ID after `main` advances. I tested that on a throwaway build: it restored a cache saved for a different commit and built with a new `PUBLIC_GIT_COMMIT_ID`, and all 32,200 built HTML pages carried the new ID (none kept the old one). Nothing is affected today either way: the CI `frontend-dist` only feeds E2E and the internal build has no Astro cache. Repeat that check before using the cache in a build that gets deployed, or key the cache on the commit ID. - Built HTML is no longer byte-for-byte reproducible between runs: Starlight tab ids (`tab-panel-N`) depend on which worker renders a page. They stay unique within each page, so nothing breaks, but diffing two builds shows tab-id noise. - The internal Azure DevOps build runs `frontend.esproj` (`bun run build`), so it needs Bun on its agents. A companion internal PR (Azure DevOps 67205, into `deploy`) installs the package manager that `package.json` names (pnpm while `main` still pins it, Bun once this lands), so it can merge first. A throwaway run of the same install and publish steps on the same internal agent type passed (Bun install, parallel prerender, no drift in the committed `.generated` output), but the companion PR itself hasn't run in the real pipeline yet. - pnpm-only settings were dropped: `allowedDeprecatedVersions`, `peerDependencyRules` and the version-pinned release-age excludes. Bun's `minimumReleaseAgeExcludes` matches names only, and a locked install isn't age-gated. ## Third-party links and affiliations <!-- List any third-party links added or changed by this pull request and disclose any material affiliation with the linked organizations, such as employment, sponsorship, or ownership. Write "None" if this pull request doesn't add or change third-party links. --> - https://bun.sh/docs/installation: Bun install docs in the contributor guide (replaces pnpm.io). - https://github.com/oven-sh/setup-bun: GitHub Action that installs Bun in CI, pinned to a commit SHA (v2.2.0) and added to the organization's allowed actions. - Rettend/starlight-plugin-icons#9: upstream fix tracked for one of the patches; moved from a comment in `pnpm-workspace.yaml` to `patches/README.md`. - The `bun` npm package (installed by the CodeQL ADO pipeline) and the `ghcr.io/devcontainers-extra/features/bun:1` dev container feature are new third-party tooling. No material affiliation with these projects or organizations to disclose. ## Validation <!-- List the checks you ran or explain why validation isn't needed. --> CI on the current head `f1a7ba038` (run `40014533725`, with `Frontend Build` on `8-core-ubuntu-latest`): every job passed on the first attempt with a cold Astro cache, including `Frontend validation` (lint, then 81 test files with 1,103 tests passed and 1 skipped), `AppHost Build`, `release-sync-tests`, all six Playwright E2E shards (no test failed or needed a retry), the report merge and `ci-gate`. On the previous head `5988e6ecd` (before the Astro 7.4.2 bump and the item route fix), run `39981757109` also passed, with `Frontend Build` on `8-core-ubuntu-latest`: - Attempt 1 (cold cache): every job passed, including `Frontend validation` (lint, then 80 test files with 1,094 tests passed and 1 skipped), `AppHost Build`, `release-sync-tests`, all six Playwright E2E shards, the report merge and `ci-gate`. One E2E test passed only on its retry: `mermaid-navigation.spec.ts` `Mermaid stays centered and responsive after client navigation in dark mode` timed out after 15 s on the tablet project while waiting for the Mermaid SVG to center. It polls client-side rendering, so it looks timing-sensitive on a loaded runner. It didn't retry in any of the last 14 `main` push runs (84 shard logs), where other tests did in 4 of the 14 (`twoslash-navigation` and `homepage`). - Attempt 2 (full re-run, exact cache hit): every job passed, including all six E2E shards and `ci-gate`. No test failed or needed a retry. On an earlier head `369123798` (before the rebase onto `main` at `1e4b28d3b` and the runner change), run `39804194596` on `ubuntu-latest` also passed. In attempt 1 (cold cache) only shard `mobile-chromium` 1/2 failed, with `Artifact download failed after 5 retries` before it ran any test, and attempt 2 (full re-run) passed every job. No test failed or needed a retry in either attempt. The E2E test fixed here (`live-status.spec.ts`, `a missing live API stays disabled across navigation and visibility changes until reload`) had failed on tablet shard 2/2 of run `39620067289` (the original attempt and both retries) and on an unrelated docs PR's run (`39344794778`). The failing trace shows the WCP consent banner appearing, the test helper clicking Reject, and the page reloading, which requested `/api/live/` a second time. The test now blocks the WCP script. It passed on its first attempt on the desktop, tablet and mobile projects in both attempts on each head above, and in run `39655383949` on the earlier version of this branch. The banner depends on the runner's region, so a few green runs don't prove the fix; the check is that this test stays green across further runs. `homepage.spec.ts` `keeps every dashboard screenshot loaded and fully contained in both themes` is a separate known flake that passes on retry (it failed once and passed on retry in runs `39655383949`, `39641836015` and `39513380035`); it didn't appear in these runs. Local checks ran on the earlier, `release/17.0`-based version of this branch with Bun 1.4.3 and Node 24. After the rebases onto `main`, `bunfig.toml`, `ec.config.mjs`, the `build*` scripts and `live-status.spec.ts` are identical, the Astro patch only moved to `[email protected]` with the same content, `bun.lock` differs by the `devalue` override ported from #1940 and the Astro 7.4.2 bump, `package.json` differs by those and by the `update:contributors` script that `main` added in #1803, and `frontend-build.yml` differs only by the `runs-on` line, so those results still apply (CI repeats the install, lint and unit tests on the current head): - `bun install --frozen-lockfile`: passed, lockfile unchanged. - `bun run lint`: passed (exit 0). - `bun run test:unit`: passed, including the workflow guard tests in `build-performance.vitest.test.ts` for the cache restore and save steps. CI's `Frontend validation` passed the same tests on the rebased head. - `bunx --bun astro sync`: passed. - `bunx --bun astro dev` probe: a docs page, a twoslash page and an OG PNG all returned 200. - A Bun probe of `starlight-links-validator` reproduced the `path.replace` crash without the `BASE_URL` default and returned the expected slug with it. - A throwaway Playwright probe against `astro dev` (Node): with a stand-in WCP that requires consent, the unchanged test body failed at `live-status.spec.ts:83` (`Expected: 1, Received: 2`, the CI failure), and with the abort line it passed. The changed spec then passed 15 of 15 (five repeats on each of the desktop, tablet and mobile projects). - YAML parse of the changed workflows: passed. On the rebased head I also ran the `contributor-list` and `ts-api-route-catalog` unit tests with Node 24 (18 tests passed). The first rebase conflicted only in `.agents/skills/update-integrations/SKILL.md` and `.github/instructions/astro.instructions.md`. The second one, onto `main` at `1e4b28d3b` (#1940, a `devalue` bump), conflicted in `pnpm-lock.yaml` in the first commit (I kept its `[email protected]` entries, which `[email protected]` pins) and in the Bun migration commit, which deletes `pnpm-lock.yaml` and `pnpm-workspace.yaml`. There I ported the override to `package.json` and `bun.lock`, and `bun install --lockfile-only` reported no changes. Output check: on the previous head, I compared the `frontend-dist` artifact from this PR's cold build (run `39804194596`, attempt 1) with the one from the `main` push build of the PR's earlier base (`a62b64bec`, sequential, Node). The later commits only change the `devalue` override and the `runs-on` line, and I didn't repeat the comparison: - Both contain 32,386 HTML pages, and no `/_astro/` reference in the HTML dangles. - Pagefind reports the same counts. - Non-HTML files are byte-identical except six: the Markdown of the two edited community pages, `llms-full.txt` and `llms-small.txt` (this PR's docs edits), and `rss.xml` and the Pagefind entry (hash and commit noise that also differs between two builds of `main`). - Two random samples of 201 and 251 pages have identical visible text. I didn't diff every page. - 150 PNG and 1 WEBP originals in `_astro/` that no page referenced are no longer emitted. Not run locally: `bun run build` (a full site build is too heavy to run locally; CI covers it), the full Playwright E2E suite (CI ran it; locally only the deflaked test ran, against `astro dev`) and the internal Azure DevOps pipelines. --------- Co-authored-by: Sébastien Ros <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: David Pine <[email protected]> Copilot-Session: 7fae752f-9a4b-40b9-afa8-fe291e54acb6 Copilot-Session: 5b3c83c2-1729-4e35-863d-c38bc4e0b41f
Summary
The Contributors page called
https://api.github.com/repos/{repo}/contributorswhile it was being rendered, once per repo for each language version of the page. Our internal Azure DevOps build (Aspire.Dev-Build) runs these calls without a token. On shared agent IPs, they hit GitHub's anonymous rate limit and return403 Forbidden: builds 3087220 and 3086870 logged 41–42 of these errors. When a call failed, the page was built and deployed without that repo's contributor list, in every language version.The build shouldn't depend on an outside service at all. These calls can fail, they make the output vary between builds, and they slow down CI. Setting a
PUBLIC_GITHUB_TOKENwould still leave network calls in the build. Because it's aPUBLIC_*variable, the token could also end up in client code.Validation
pnpm exec vitest run --config vitest.config.ts tests/unit/contributor-list.vitest.test.tspasses (9 tests). It covers:ContributorListrenders from the committed JSON, and a stubbedfetchis never calledignorelist and case-insensitive repo namespnpm update:contributorsgithub-contributors.jsontests/unit/release-contributors.vitest.test.tspasses.pnpm exec eslint --max-warnings 0on the changed.ts/.mjsfiles is clean.pnpm update:contributorsran successfully against GitHub and generated the committed JSON: 306 / 40 / 88 / 78 / 19 contributors. Pagination worked, sincemicrosoft/aspireneeded 4 pages.