How googlechromelabs/chrome-for-testing works
Project Type and Purpose
• This is an open-source static site generator + CLI utility suite that publishes JSON API endpoints and HTML pages for “Chrome for Testing” version availability.
• It ingests “known good” Chrome version data, enriches it with download URLs, builds a static website (hosted via GitHub Pages), and provides command-line tools (find-version.mjs, check-version.mjs) to query those APIs or check asset availability.
File Structure Analysis
• Top-level scripts (find-version.mjs, check-version.mjs) form the CLI utilities.
• The data/ folder holds raw JSON source files.
• Generator modules (generate-*.mjs, html-utils.mjs, json-utils.mjs, url-utils.mjs) read data/ and templates (_tpl/template.html) to produce JSON endpoints and HTML files in dist/.
• CI and deployment are handled by GitHub Actions (.github/workflows/build.yml).
• Configuration is minimal: package.json, .nvmrc, .editorconfig, .gitignore.
Key Components
a. External Data Sources
• Google Cloud Storage (chrome-for-testing-public)
• Upstream “LATEST_RELEASE_*” endpoints
b. Local Repository
• data/ (raw JSON snapshots)
• _tpl/ (HTML template)
• Generator scripts (generate-*.mjs, html-utils.mjs, json-utils.mjs, url-utils.mjs)
• CLI tools (find-version.mjs, check-version.mjs, check-version.mjs)
c. Build Orchestrator
• GitHub Actions workflow (build.yml)
• npm scripts (npm run generate, npm run find, npm run check)
d. Output & Hosting
• dist/ directory containing JSON API endpoints + HTML pages
• GitHub Pages hosting (via gh-pages or actions-gh-pages)
e. Consumers
• Browsers (human users viewing HTML)
• Automation tools or other services fetching JSON endpoints
• CLI users running npm run find / npm run check
Relationships & Data Flow
1. CI Trigger (push to main) → GitHub Actions
2. Actions checks out code → npm install → executes generator scripts
3. Generator scripts: read data/*.json → enrich with download URLs (via url-utils) → output new JSON API files and HTML pages to dist/ (using _tpl/template.html + html-utils)
4. Actions deploys dist/ to GitHub Pages
5. External consumers (browsers, clients, CLI) fetch JSON and HTML from GitHub Pages URLs
6. CLI tools (find-version, check-version) can also query Google Cloud Storage directly or fetch the generated JSON endpoints to validate asset availability
Architectural Patterns & Design Principles
• Static Site Generator (SSG) pattern: separation of content (data/) from presentation (_tpl/) and logic (generate-*.mjs).
• Single-responsibility per script: each generate-*.mjs has one job (directory index, extra JSON, HTML, latest-release JSON).
• Modular utilities (json-utils, url-utils, html-utils) to avoid duplication and simplify maintenance.
• CI/CD via GitHub Actions for fully automated build and deploy.
• CLI Commands leveraging shared modules for consistency.
Essential Elements to Capture
• All six generator scripts and their inputs/outputs
• Template folder _tpl/template.html as the presentation layer
• The data/ source JSON and the dist/ output directory
• GitHub Actions workflow triggering build and deploy
• External Google Cloud Storage as a source of binary assets
• Consumers: browsers/API clients and the command-line utilities