From 2dfac71db56c0bb7303ffdb1e67648b04bfbb58a Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 18:47:34 +1300 Subject: [PATCH 1/2] Docs: the CLI release comes from the newest GitHub release at build time; the GitHub Actions example runs once per PR commit --- .claude-plugin/marketplace.json | 2 +- .claude-plugin/plugin.json | 2 +- .cursor-plugin/plugin.json | 2 +- .github/workflows/ci.yml | 13 ++++- AGENTS.md | 6 +-- docker/app.Dockerfile | 3 ++ frontend/content/docs/ci/bitbucket.md | 2 +- frontend/content/docs/ci/buildkite.md | 2 +- frontend/content/docs/ci/circleci.md | 2 +- frontend/content/docs/ci/github-actions.md | 18 ++++--- frontend/content/docs/ci/gitlab.md | 2 +- frontend/content/docs/ci/jenkins.md | 2 +- frontend/content/docs/ci/semaphore.md | 2 +- frontend/content/docs/ci/teamcity.md | 2 +- frontend/content/docs/ci/travis.md | 2 +- frontend/content/docs/quick-start.md | 2 +- frontend/content/docs/reference/cli.md | 2 +- .../content/docs/snapshots/laravel-rust.md | 4 +- frontend/scripts/cli-version.d.mts | 3 ++ frontend/scripts/cli-version.mjs | 47 +++++++++++++++++++ frontend/scripts/prerender.mjs | 11 ++++- frontend/scripts/site.mjs | 46 ++++-------------- frontend/scripts/skills.mjs | 8 +++- frontend/src/components/SetupChecklist.tsx | 5 +- frontend/src/vite-env.d.ts | 2 + frontend/vite.config.ts | 5 +- gemini-extension.json | 2 +- skills/visualci-bitbucket/SKILL.md | 4 +- skills/visualci-buildkite/SKILL.md | 4 +- skills/visualci-circleci/SKILL.md | 4 +- skills/visualci-github-actions/SKILL.md | 20 +++++--- skills/visualci-gitlab/SKILL.md | 4 +- skills/visualci-jenkins/SKILL.md | 4 +- skills/visualci-laravel-rust/SKILL.md | 6 ++- skills/visualci-semaphore/SKILL.md | 4 +- skills/visualci-teamcity/SKILL.md | 4 +- skills/visualci-travis/SKILL.md | 4 +- skills/visualci/SKILL.md | 4 +- 38 files changed, 177 insertions(+), 84 deletions(-) create mode 100644 frontend/scripts/cli-version.d.mts create mode 100644 frontend/scripts/cli-version.mjs diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 7ebc74ac..ae4a3e12 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -5,7 +5,7 @@ "plugins": [ { "name": "visualci", - "version": "0.1.59", + "version": "0.1.61", "description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.", "author": { "name": "DocSpring", "url": "https://visualci.com" }, "homepage": "https://visualci.com/docs/skills/", diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 45d23bbe..3073e047 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.59", + "version": "0.1.61", "description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.", "author": { "name": "DocSpring", "url": "https://visualci.com" }, "homepage": "https://visualci.com/docs/skills/", diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json index 4b8d888f..41c1ee6b 100644 --- a/.cursor-plugin/plugin.json +++ b/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "visualci", "displayName": "VisualCI", - "version": "0.1.59", + "version": "0.1.61", "description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.", "author": { "name": "DocSpring" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef1da708..ecd7c8c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,6 +214,8 @@ jobs: working-directory: frontend - run: pnpm install --frozen-lockfile && pnpm build working-directory: frontend + env: + GITHUB_TOKEN: ${{ github.token }} # the docs' CLI release (scripts/cli-version.mjs) - uses: ./.github/actions/playwright with: save: ${{ github.ref == 'refs/heads/main' }} @@ -437,6 +439,8 @@ jobs: # The production site: with the Plausible snippets (analytics.ts) and, required, the WebAssembly. - run: pnpm install --frozen-lockfile && VISUALCI_ANALYTICS=1 VISUALCI_REQUIRE_WASM=1 pnpm build working-directory: frontend + env: + GITHUB_TOKEN: ${{ github.token }} # the docs' CLI release (scripts/cli-version.mjs) # visualci.com's static site: assembled from the build and checked (every docs page has its Markdown copy, and # llms.txt links each one), then deployed by the site job. - run: VISUALCI_ANALYTICS=1 node scripts/site.mjs @@ -539,7 +543,13 @@ jobs: steps: - uses: actions/checkout@v4 - id: version - run: echo "renderer=$(cat docker/renderer.version)" >>"$GITHUB_OUTPUT" + env: + GH_TOKEN: ${{ github.token }} + run: | + echo "renderer=$(cat docker/renderer.version)" >>"$GITHUB_OUTPUT" + # The CLI release the app's add-to-CI snippets install (frontend/scripts/cli-version.mjs): a build arg, so a + # new release rebuilds the cached frontend layer + echo "cli=$(gh api repos/DocSpring/visualci/releases/latest --jq .tag_name)" >>"$GITHUB_OUTPUT" - uses: actions/download-artifact@v4 with: name: release-bins @@ -564,6 +574,7 @@ jobs: BUILD_SHA=${{ github.sha }} RENDERER_VERSION=${{ steps.version.outputs.renderer }} VISUALCI_ANALYTICS=1 + VISUALCI_CLI_VERSION=${{ steps.version.outputs.cli }} tags: ghcr.io/docspring/visualci-app:${{ github.sha }} cache-from: ${{ env.S3_CACHE }},name=visualci-app cache-to: ${{ env.PUSH == 'true' && format('{0},name=visualci-app,mode=max,ignore-error=true', env.S3_CACHE) || '' }} diff --git a/AGENTS.md b/AGENTS.md index d52e008f..11ea07ba 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,9 +43,9 @@ design is in `docs/design.md`; read it before changing the architecture, and upd `.claude-plugin/plugin.json` and `marketplace.json` when a skill changes. - A change to the CLI (crates/visualci-cli or crates/visualci-core) bumps the workspace version in Cargo.toml and Cargo.lock's visualci-* entries. CI's `cli-version` job fails without the bump; once CI passes on main, the release - workflow publishes it. The docs' `VISUALCI_VERSION=` lines pin a published release (`scripts/site.mjs` checks it - exists): move them to the new version in a commit after its release is out. The docs must never describe a CLI - nobody can download. + workflow publishes it. The docs never name a CLI version: they write `{{cli_version}}` + (`VISUALCI_VERSION={{cli_version}}`, `github-action@v{{cli_version}}`), which the site build fills in with the newest + published release (`frontend/scripts/cli-version.mjs`), so they never pin an old CLI or one nobody can download yet. - Fixtures are test data only: synthetic values, or blank template PDFs someone has checked. Never commit a real customer's document or data. - Build Rust in CI or on a build machine (docspring-dev), not on small agent VMs. The server is app/ (Laravel Rust, diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index 995f8b63..0753de3f 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -13,6 +13,9 @@ ARG VISUALCI_ANALYTICS=0 ENV VISUALCI_ANALYTICS=${VISUALCI_ANALYTICS} # The site's Compare two PDFs page (and its WebAssembly) is served by the site's Worker, never by the app. ENV VISUALCI_SKIP_WASM=1 +# The CLI release the add-to-CI snippets install (frontend/scripts/cli-version.mjs); CI passes the newest release. +ARG VISUALCI_CLI_VERSION= +ENV VISUALCI_CLI_VERSION=${VISUALCI_CLI_VERSION} RUN if [ -f pnpm-lock.yaml ]; then pnpm build; else npm run build; fi # cargo-chef: the dependencies build in a layer of their own, rebuilt only when a Cargo.toml or Cargo.lock changes. diff --git a/frontend/content/docs/ci/bitbucket.md b/frontend/content/docs/ci/bitbucket.md index 9fc3fccb..bd39c8d1 100644 --- a/frontend/content/docs/ci/bitbucket.md +++ b/frontend/content/docs/ci/bitbucket.md @@ -14,7 +14,7 @@ pipelines: name: Test image: node:24 script: - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR=/usr/local/bin sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR=/usr/local/bin sh - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u # write snapshots instead of failing; see the snapshot guides - visualci upload --from auto src tests diff --git a/frontend/content/docs/ci/buildkite.md b/frontend/content/docs/ci/buildkite.md index 7a8a0d67..5d729885 100644 --- a/frontend/content/docs/ci/buildkite.md +++ b/frontend/content/docs/ci/buildkite.md @@ -11,7 +11,7 @@ The CLI reads the commit from `BUILDKITE_COMMIT`, the branch from `BUILDKITE_BRA steps: - label: ":test_tube: Tests" command: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$$HOME/bin" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$$HOME/bin" sh export PATH="$$HOME/bin:$$PATH" export VISUALCI_BUILD_ID=$$(visualci build create) npm test -- -u diff --git a/frontend/content/docs/ci/circleci.md b/frontend/content/docs/ci/circleci.md index 17c84e7a..ee3921e7 100644 --- a/frontend/content/docs/ci/circleci.md +++ b/frontend/content/docs/ci/circleci.md @@ -16,7 +16,7 @@ jobs: - checkout - run: name: Install VisualCI - command: curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + command: curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$HOME/bin" sh - run: name: Start a VisualCI build command: echo "export VISUALCI_BUILD_ID=$($HOME/bin/visualci build create)" >> "$BASH_ENV" diff --git a/frontend/content/docs/ci/github-actions.md b/frontend/content/docs/ci/github-actions.md index 8695bc76..63de29d6 100644 --- a/frontend/content/docs/ci/github-actions.md +++ b/frontend/content/docs/ci/github-actions.md @@ -8,6 +8,10 @@ skill_description: Sets up VisualCI in GitHub Actions, including Blacksmith and Add `VISUALCI_TOKEN` (a project token) to the repository's Actions secrets. Then add VisualCI's action to the job that runs your tests, after them: ```yaml +on: + pull_request: # one build per pull request commit + push: + branches: [main] # and one per merge to main: the baselines jobs: test: runs-on: ubuntu-latest @@ -17,7 +21,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 # VisualCI finds the baseline through the commit's ancestors - run: npm test -- -u # write snapshots instead of failing; see the snapshot guides - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@v{{cli_version}} if: always() with: token: ${{ secrets.VISUALCI_TOKEN }} @@ -26,6 +30,8 @@ jobs: screenshots --platform chromium-linux --threshold 0.1 ``` +Run it on `pull_request` and on pushes to your main branch only: with `push` on every branch too, each commit to a pull request runs twice and sends two builds. + The action installs the CLI, creates the build, uploads and finalizes it. `upload` takes one `visualci upload` per line, as its arguments (paths, `--from`, `--prefix`, `--platform`, `--format`); leave it out to send the `uploads` in [visualci.yml](/docs/reference/config/). Without a token the step fails, so a misnamed secret can't pass quietly. The token comes from `token`, or from `VISUALCI_TOKEN` in the workflow's or job's `env`. The exceptions are where GitHub passes no repository secrets: a fork's pull request and runs in a fork get none, and Dependabot's pull requests get only Dependabot secrets. The action skips those with a notice; [send a fork's from a second workflow](#pull-requests-from-forks), and add `VISUALCI_TOKEN` to the Dependabot secrets to review Dependabot's. | Input | What it does | @@ -50,7 +56,7 @@ Every job of a workflow run that uses the same `name` joins one build. Send from browser: [chromium, webkit] steps: # ... checkout and tests ... - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@v{{cli_version}} with: token: ${{ secrets.VISUALCI_TOKEN }} finalize: false @@ -62,7 +68,7 @@ Every job of a workflow run that uses the same `name` joins one build. Send from - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@v{{cli_version}} with: token: ${{ secrets.VISUALCI_TOKEN }} finalize-only: true @@ -106,7 +112,7 @@ jobs: - uses: actions/checkout@v4 # your default branch: the fork's commits are only fetched with: fetch-depth: 0 - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@v{{cli_version}} with: token: ${{ secrets.VISUALCI_TOKEN }} artifact: visualci @@ -174,7 +180,7 @@ jobs: - 'templates/**' - name: Install VisualCI run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - name: Start a VisualCI build # A skipped run sends nothing: --subset carries every snapshot forward. @@ -218,7 +224,7 @@ jobs: fetch-depth: 0 - name: Install VisualCI run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - name: Start a VisualCI build run: echo "VISUALCI_BUILD_ID=$(visualci build create)" >> "$GITHUB_ENV" diff --git a/frontend/content/docs/ci/gitlab.md b/frontend/content/docs/ci/gitlab.md index 177bbf57..4bcd7458 100644 --- a/frontend/content/docs/ci/gitlab.md +++ b/frontend/content/docs/ci/gitlab.md @@ -13,7 +13,7 @@ visual: variables: GIT_DEPTH: 0 # VisualCI finds the baseline through the commit's ancestors script: - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR=/usr/local/bin sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR=/usr/local/bin sh - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u - visualci upload --from auto src tests diff --git a/frontend/content/docs/ci/jenkins.md b/frontend/content/docs/ci/jenkins.md index d244e4a0..6baa5f40 100644 --- a/frontend/content/docs/ci/jenkins.md +++ b/frontend/content/docs/ci/jenkins.md @@ -16,7 +16,7 @@ pipeline { stages { stage('Test') { steps { - sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$WORKSPACE/bin" sh' + sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$WORKSPACE/bin" sh' sh ''' export PATH="$WORKSPACE/bin:$PATH" export VISUALCI_BUILD_ID=$(visualci build create) diff --git a/frontend/content/docs/ci/semaphore.md b/frontend/content/docs/ci/semaphore.md index 10d425a2..ac8ac07e 100644 --- a/frontend/content/docs/ci/semaphore.md +++ b/frontend/content/docs/ci/semaphore.md @@ -23,7 +23,7 @@ blocks: - name: Test commands: - checkout - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$HOME/bin" sh - export PATH="$HOME/bin:$PATH" - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u # write snapshots instead of failing; see the snapshot guides diff --git a/frontend/content/docs/ci/teamcity.md b/frontend/content/docs/ci/teamcity.md index f819d694..b4288d1a 100644 --- a/frontend/content/docs/ci/teamcity.md +++ b/frontend/content/docs/ci/teamcity.md @@ -16,7 +16,7 @@ The CLI doesn't read TeamCity's parameters by itself: pass them as environment v Then a command-line step: ```sh -curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$PWD/bin" sh +curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$PWD/bin" sh export PATH="$PWD/bin:$PATH" export VISUALCI_BUILD_ID=$(visualci build create) npm test -- -u # write snapshots instead of failing; see the snapshot guides diff --git a/frontend/content/docs/ci/travis.md b/frontend/content/docs/ci/travis.md index a7e9ccb3..295da746 100644 --- a/frontend/content/docs/ci/travis.md +++ b/frontend/content/docs/ci/travis.md @@ -14,7 +14,7 @@ git: depth: false install: - npm ci - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$HOME/bin" sh script: - export PATH="$HOME/bin:$PATH" - export VISUALCI_BUILD_ID=$(visualci build create) diff --git a/frontend/content/docs/quick-start.md b/frontend/content/docs/quick-start.md index 7e027ac0..b0aafb37 100644 --- a/frontend/content/docs/quick-start.md +++ b/frontend/content/docs/quick-start.md @@ -40,7 +40,7 @@ Install the CLI on Linux (x86_64 or arm64) or macOS: curl -fsSL https://visualci.com/install.sh | sh ``` -It installs to `/usr/local/bin`, or to `$VISUALCI_INSTALL_DIR`, and checks the download's SHA-256. In CI, pin the version with `VISUALCI_VERSION=0.2.23`, so a new release never changes a build by surprise. It downloads the latest [GitHub release](https://github.com/DocSpring/visualci/releases) for Linux (x86_64 and arm64) or macOS. Anywhere else with Rust, build it from source: +It installs to `/usr/local/bin`, or to `$VISUALCI_INSTALL_DIR`, and checks the download's SHA-256. In CI, pin the version with `VISUALCI_VERSION={{cli_version}}`, so a new release never changes a build by surprise. It downloads the latest [GitHub release](https://github.com/DocSpring/visualci/releases) for Linux (x86_64 and arm64) or macOS. Anywhere else with Rust, build it from source: ```sh cargo install --git https://github.com/DocSpring/visualci visualci-cli diff --git a/frontend/content/docs/reference/cli.md b/frontend/content/docs/reference/cli.md index d61a7b23..2493a753 100644 --- a/frontend/content/docs/reference/cli.md +++ b/frontend/content/docs/reference/cli.md @@ -3,7 +3,7 @@ title: CLI reference description: Every visualci command and option, and the environment variables the CLI reads. --- -Install it on Linux or macOS with `curl -fsSL https://visualci.com/install.sh | sh` (set `VISUALCI_VERSION=0.2.23` to pin a release, and `VISUALCI_INSTALL_DIR` for somewhere other than `/usr/local/bin`), or anywhere with Rust with `cargo install --git https://github.com/DocSpring/visualci visualci-cli`. `visualci --help` and `visualci --help` print the same options. +Install it on Linux or macOS with `curl -fsSL https://visualci.com/install.sh | sh` (set `VISUALCI_VERSION={{cli_version}}` to pin a release, and `VISUALCI_INSTALL_DIR` for somewhere other than `/usr/local/bin`), or anywhere with Rust with `cargo install --git https://github.com/DocSpring/visualci visualci-cli`. `visualci --help` and `visualci --help` print the same options. Every command that talks to the server takes `--token` (default `$VISUALCI_TOKEN`, a project token, else the token `visualci login` kept) and `--api-url` (default `$VISUALCI_API_URL`, else `https://api.visualci.com`). With a personal token, it also needs the project: `--project org/project`, `$VISUALCI_PROJECT`, or `project:` in visualci.yml. Errors exit with status 2. `--verbose` prints how long each step takes: hashing the files, each call to the server, and the uploads. diff --git a/frontend/content/docs/snapshots/laravel-rust.md b/frontend/content/docs/snapshots/laravel-rust.md index efec15a6..5dfbcdca 100644 --- a/frontend/content/docs/snapshots/laravel-rust.md +++ b/frontend/content/docs/snapshots/laravel-rust.md @@ -49,7 +49,7 @@ For snapshots without a browser, `default-features = false` leaves the browser o Then the CLI, and a project token (see [Quick start](/docs/quick-start/)): ```sh -curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 sh +curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} sh export VISUALCI_TOKEN=vci_... ``` @@ -76,7 +76,7 @@ On GitHub Actions: node-version: 22 - run: npx -y playwright@1.65.2 install --with-deps --only-shell chromium - run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$HOME/bin" sh echo "$HOME/bin" >> "$GITHUB_PATH" - run: visualci test -- cargo test --locked env: diff --git a/frontend/scripts/cli-version.d.mts b/frontend/scripts/cli-version.d.mts new file mode 100644 index 00000000..c7bd4113 --- /dev/null +++ b/frontend/scripts/cli-version.d.mts @@ -0,0 +1,3 @@ +export const PLACEHOLDER: RegExp +export function fillCliVersion(text: string, version: string): string +export function latestCliVersion(): Promise diff --git a/frontend/scripts/cli-version.mjs b/frontend/scripts/cli-version.mjs new file mode 100644 index 00000000..336d56fd --- /dev/null +++ b/frontend/scripts/cli-version.mjs @@ -0,0 +1,47 @@ +// The CLI release the docs install: `{{cli_version}}` in a page's Markdown (VISUALCI_VERSION={{cli_version}}, +// DocSpring/visualci/clients/github-action@v{{cli_version}}) is filled in at build time with the newest published +// release, so the docs never pin an old one or a CLI nobody can download yet (a release goes out after CI on main +// passes, .github/workflows/release.yml, later than the site deploys). The generated skills (scripts/skills.mjs) are +// committed, so they say x.y.z and where to find the newest release instead. +import { readFile } from 'node:fs/promises' +import { join } from 'node:path' +import { root } from './docs-source.mjs' + +export const PLACEHOLDER = /\{\{cli_version\}\}/g +export const fillCliVersion = (text, version) => text.replace(PLACEHOLDER, version) + +let cached + +/** The newest published CLI release (`0.2.24`). VISUALCI_CLI_VERSION overrides it. In CI the build fails when GitHub + * can't say; elsewhere (a dev server, a local build) it falls back to the workspace version with a warning. */ +export function latestCliVersion() { + cached ??= resolve() + return cached +} + +async function resolve() { + if (process.env.VISUALCI_CLI_VERSION) return process.env.VISUALCI_CLI_VERSION.replace(/^v/, '') + const headers = { accept: 'application/vnd.github+json', ...(process.env.GITHUB_TOKEN ? { authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}) } + let reason = '' + for (let attempt = 1; attempt <= 3; attempt++) { + try { + const response = await fetch('https://api.github.com/repos/DocSpring/visualci/releases/latest', { headers, signal: AbortSignal.timeout(15000) }) + if (response.ok) { + const tag = (await response.json()).tag_name ?? '' + if (/^v\d+\.\d+\.\d+$/.test(tag)) return tag.slice(1) + reason = `the latest release's tag is ${JSON.stringify(tag)}` + break + } + reason = `HTTP ${response.status}` + } catch (e) { + reason = e.message + } + } + if (process.env.CI) throw new Error(`couldn't find VisualCI's latest CLI release for the docs (${reason}); set VISUALCI_CLI_VERSION to build anyway`) + const cargo = await readFile(join(root, '../Cargo.toml'), 'utf8').catch(() => { + throw new Error(`couldn't find VisualCI's latest CLI release for the docs (${reason}), and there's no Cargo.toml: set VISUALCI_CLI_VERSION`) + }) + const version = cargo.match(/^version = "(.*)"/m)[1] + console.warn(`couldn't find VisualCI's latest CLI release (${reason}): the docs say ${version}, the workspace version`) + return version +} diff --git a/frontend/scripts/prerender.mjs b/frontend/scripts/prerender.mjs index 975291d6..37f4d57a 100644 --- a/frontend/scripts/prerender.mjs +++ b/frontend/scripts/prerender.mjs @@ -11,7 +11,16 @@ import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises' import { dirname, join } from 'node:path' import { pathToFileURL } from 'node:url' import { Marked } from 'marked' -import { SITE, absoluteLinks, pageSlugs, parsePage, readPage, root } from './docs-source.mjs' +import { fillCliVersion, latestCliVersion } from './cli-version.mjs' +import { SITE, absoluteLinks, pageSlugs, parsePage, readPage as readSource, root } from './docs-source.mjs' + +// Every page with the CLI release filled in (scripts/cli-version.mjs). +const cliVersion = await latestCliVersion() +const readPage = async (slug) => { + const page = await readSource(slug) + return { ...page, body: fillCliVersion(page.body, cliVersion) } +} +console.log(`the docs install CLI ${cliVersion}`) import { buildHosts, hostsMeta } from './hosts.mjs' import { atomFeed, copyPostFiles, indexHtml, indexMarkdown, loadPosts, postImage, postJsonLd, postMarkdown, postMetaHtml, postPath } from './blog.mjs' diff --git a/frontend/scripts/site.mjs b/frontend/scripts/site.mjs index d488ae0b..78d42100 100644 --- a/frontend/scripts/site.mjs +++ b/frontend/scripts/site.mjs @@ -126,46 +126,18 @@ const landing = await readFile(join(out, 'index.html'), 'utf8') // To the app the site was built for (scripts/hosts.mjs: visualci.com's, unless VISUALCI_*_URL name others) const appHost = buildHosts(process.env).app if (!landing.includes(`${appHost}/auth/github`)) problems.push(`the landing page's sign-in doesn't go to ${appHost}`) -// The CLI version the docs pin (VISUALCI_VERSION=x.y.z) must be a published release, so install.sh never 404s: a -// release goes out after CI on main passes (.github/workflows/release.yml), later than this site deploys. Pin the newest -// release once it's out; the pin can't be newer than the workspace version (Cargo.toml). -const cargo = await readFile(join(root, '../Cargo.toml'), 'utf8') -const cliVersion = cargo.match(/^version = "(.*)"/m)[1] -const newer = (a, b) => { - const [x, y] = [a, b].map((v) => v.split('.').map(Number)) - for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] > y[i] - return false -} +// The CLI release the docs pin is filled in at build time (scripts/cli-version.mjs): every page says the same one, +// and no `{{cli_version}}` is left in a page or its Markdown copy (the app fills in its copies when it shows them). const pins = new Set() -for (const page of [...files].filter((f) => f.endsWith('.md'))) { - const text = await readFile(join(out, page), 'utf8') - for (const m of text.matchAll(/VISUALCI_VERSION=v?([0-9][0-9.]*[0-9])/g)) pins.add(`${page} ${m[1]}`) +for (const f of [...files].filter((f) => /\.(md|html|txt)$/.test(f))) { + const text = await readFile(join(out, f), 'utf8') + if (text.includes('{{cli_version}}')) problems.push(`${f} still says {{cli_version}}`) + if (!f.endsWith('.md')) continue + for (const m of text.matchAll(/VISUALCI_VERSION=v?([0-9][0-9.]*[0-9])/g)) pins.add(m[1]) // VisualCI's GitHub Action, pinned to a release tag of this repository. - for (const m of text.matchAll(/DocSpring\/visualci\/clients\/github-action@v([0-9][0-9.]*[0-9])/g)) pins.add(`${page} ${m[1]}`) -} -const released = new Map() -for (const pin of pins) { - const [page, version] = pin.split(' ') - if (newer(version, cliVersion)) problems.push(`${page} pins VISUALCI_VERSION=${version}, newer than the CLI (${cliVersion})`) - if (!released.has(version)) { - const headers = process.env.GITHUB_TOKEN ? { authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {} - const response = await fetch(`https://api.github.com/repos/DocSpring/visualci/releases/tags/v${version}`, { headers }) - released.set(version, response.status === 200 ? true : response.status === 404 ? false : null) - if (released.get(version) === null) console.warn(`couldn't check release v${version}: HTTP ${response.status}`) - } - if (released.get(version) === false) problems.push(`${page} pins VISUALCI_VERSION=${version}, which isn't released`) -} -// One version everywhere: the app's add-to-CI step shows these snippets, so a page left behind shows an old release. -const versions = new Set([...pins].map((p) => p.split(' ')[1])) -if (versions.size > 1) problems.push(`the docs pin more than one CLI release (${[...versions].join(', ')}): pin the newest everywhere`) -{ - const headers = process.env.GITHUB_TOKEN ? { authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {} - const response = await fetch('https://api.github.com/repos/DocSpring/visualci/releases/latest', { headers }) - const latest = response.status === 200 ? (await response.json()).tag_name?.replace(/^v/, '') : null - for (const version of versions) { - if (latest && newer(latest, version)) console.warn(`the docs pin ${version}; ${latest} is out: move the pins to it`) - } + for (const m of text.matchAll(/DocSpring\/visualci\/clients\/github-action@v([0-9][0-9.]*[0-9])/g)) pins.add(m[1]) } +if (pins.size > 1) problems.push(`the docs pin more than one CLI release (${[...pins].join(', ')}): use {{cli_version}}`) // Production builds (VISUALCI_ANALYTICS=1, analytics.ts) carry the marketing site's Plausible script on every page but // the plain 404, and never the app's. if (process.env.VISUALCI_ANALYTICS === '1') { diff --git a/frontend/scripts/skills.mjs b/frontend/scripts/skills.mjs index 25efffaa..11dc2ae5 100644 --- a/frontend/scripts/skills.mjs +++ b/frontend/scripts/skills.mjs @@ -12,8 +12,11 @@ // them at visualci.com/.well-known/agent-skills/, and the MCP server's get_skill tool embeds them. import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' +import { PLACEHOLDER, fillCliVersion } from './cli-version.mjs' import { SITE, absoluteLinks, markdownPath, pageSlugs, readPage, root } from './docs-source.mjs' +const PLACEHOLDER_TEST = (text) => text.search(PLACEHOLDER) >= 0 + export const skillsDir = join(root, '../skills') const MAIN = 'visualci' @@ -40,7 +43,10 @@ export async function generateSkills() { `---\nname: ${page.skill.name}\ndescription: ${JSON.stringify(page.skill.description)}\nlicense: Apache-2.0\nmetadata:\n docs: ${url}\n---`, ``, `# ${page.title}`, - absoluteLinks(page.body), + ...(PLACEHOLDER_TEST(page.body) + ? ['Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest'] + : []), + absoluteLinks(fillCliVersion(page.body, 'x.y.z')), ] if (page.skill.name === MAIN) { parts.push( diff --git a/frontend/src/components/SetupChecklist.tsx b/frontend/src/components/SetupChecklist.tsx index 26692737..6235e304 100644 --- a/frontend/src/components/SetupChecklist.tsx +++ b/frontend/src/components/SetupChecklist.tsx @@ -127,8 +127,11 @@ function InstallGithubApp({ org, data, onCreateProject }: { org: string; data: O } /** The first code block of a docs page: the CI snippets live in the docs, once. */ +// The docs' snippets say {{cli_version}}, filled in at build time with the newest CLI release (x.y.z in tests). +const CLI_VERSION = typeof __VISUALCI_CLI_VERSION__ === 'undefined' ? 'x.y.z' : __VISUALCI_CLI_VERSION__ + function firstBlock(markdown: string): string { - return markdown.match(/```\w*\n([\s\S]*?)```/)?.[1].trimEnd() ?? '' + return (markdown.match(/```\w*\n([\s\S]*?)```/)?.[1].trimEnd() ?? '').replace(/\{\{cli_version\}\}/g, CLI_VERSION) } function Tabs({ label, tabs, value, onChange }: { label: string; tabs: readonly T[]; value: T; onChange: (t: T) => void }) { diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts index 14ed0090..d3c65591 100644 --- a/frontend/src/vite-env.d.ts +++ b/frontend/src/vite-env.d.ts @@ -2,4 +2,6 @@ /** Set by vite.config.ts: whether the blog has a published post, so the footer links /blog/ only then. */ declare const __VISUALCI_BLOG__: boolean +/** Set by vite.config.ts: the CLI release the docs' snippets install (scripts/cli-version.mjs). */ +declare const __VISUALCI_CLI_VERSION__: string declare const __VISUALCI_HOSTS__: { site: string; app: string; api: string; mcp: string } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 812ac521..4f7535b6 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import { analytics } from './analytics' +import { latestCliVersion } from './scripts/cli-version.mjs' import { hasBlog } from './scripts/has-blog.mjs' import { buildHosts } from './scripts/hosts.mjs' @@ -10,7 +11,7 @@ import { buildHosts } from './scripts/hosts.mjs' // // `loadEnv` is Vite's own reader; the empty prefix takes shell variables too. // It is used here for the dev server and the analytics switch only: nothing is exposed to the client. -export default defineConfig(({ mode, isSsrBuild }) => { +export default defineConfig(async ({ mode, isSsrBuild }) => { const env = loadEnv(mode, '..', '') const backend = `http://127.0.0.1:${env.SERVER_PORT || '5250'}` @@ -20,6 +21,8 @@ export default defineConfig(({ mode, isSsrBuild }) => { __VISUALCI_BLOG__: JSON.stringify(hasBlog(env.VISUALCI_BLOG_DRAFTS === '1')), // The hosts the server-rendered site links to (scripts/hosts.mjs); the browser reads the meta tags instead __VISUALCI_HOSTS__: JSON.stringify(buildHosts(env)), + // The CLI release the docs' snippets install (scripts/cli-version.mjs), for the add-to-CI step's copies of them + __VISUALCI_CLI_VERSION__: JSON.stringify(await latestCliVersion()), }, // Three pages: the app (index.html), the landing page (landing.html) and the docs template (docs.html), which // scripts/prerender.mjs fills with server-rendered HTML. The SSR build (`vite build --ssr`) has one entry for each diff --git a/gemini-extension.json b/gemini-extension.json index 681c2af9..15d44f8b 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.59", + "version": "0.1.61", "description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.", "mcpServers": { "visualci": { diff --git a/skills/visualci-bitbucket/SKILL.md b/skills/visualci-bitbucket/SKILL.md index 7d00775e..a522fd33 100644 --- a/skills/visualci-bitbucket/SKILL.md +++ b/skills/visualci-bitbucket/SKILL.md @@ -10,6 +10,8 @@ metadata: # Bitbucket Pipelines +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Add `VISUALCI_TOKEN` (a project token) as a secured repository variable. The CLI reads the commit from `BITBUCKET_COMMIT`, the branch from `BITBUCKET_BRANCH` and the pull request from `BITBUCKET_PR_ID`. ```yaml @@ -19,7 +21,7 @@ pipelines: name: Test image: node:24 script: - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR=/usr/local/bin sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR=/usr/local/bin sh - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u # write snapshots instead of failing; see the snapshot guides - visualci upload --from auto src tests diff --git a/skills/visualci-buildkite/SKILL.md b/skills/visualci-buildkite/SKILL.md index b3f43d48..fb935d02 100644 --- a/skills/visualci-buildkite/SKILL.md +++ b/skills/visualci-buildkite/SKILL.md @@ -10,13 +10,15 @@ metadata: # Buildkite +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + The CLI reads the commit from `BUILDKITE_COMMIT`, the branch from `BUILDKITE_BRANCH` and the pull request from `BUILDKITE_PULL_REQUEST`. ```yaml steps: - label: ":test_tube: Tests" command: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$$HOME/bin" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$$HOME/bin" sh export PATH="$$HOME/bin:$$PATH" export VISUALCI_BUILD_ID=$$(visualci build create) npm test -- -u diff --git a/skills/visualci-circleci/SKILL.md b/skills/visualci-circleci/SKILL.md index 8bc78cdd..6c5e6993 100644 --- a/skills/visualci-circleci/SKILL.md +++ b/skills/visualci-circleci/SKILL.md @@ -10,6 +10,8 @@ metadata: # CircleCI +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Add `VISUALCI_TOKEN` (a project token) to the project's environment variables or a context. The CLI reads the commit from `CIRCLE_SHA1`, the branch from `CIRCLE_BRANCH` and the pull request from `CIRCLE_PULL_REQUEST`. ```yaml @@ -21,7 +23,7 @@ jobs: - checkout - run: name: Install VisualCI - command: curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + command: curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$HOME/bin" sh - run: name: Start a VisualCI build command: echo "export VISUALCI_BUILD_ID=$($HOME/bin/visualci build create)" >> "$BASH_ENV" diff --git a/skills/visualci-github-actions/SKILL.md b/skills/visualci-github-actions/SKILL.md index eca99362..a6be8cae 100644 --- a/skills/visualci-github-actions/SKILL.md +++ b/skills/visualci-github-actions/SKILL.md @@ -10,9 +10,15 @@ metadata: # GitHub Actions +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Add `VISUALCI_TOKEN` (a project token) to the repository's Actions secrets. Then add VisualCI's action to the job that runs your tests, after them: ```yaml +on: + pull_request: # one build per pull request commit + push: + branches: [main] # and one per merge to main: the baselines jobs: test: runs-on: ubuntu-latest @@ -22,7 +28,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 # VisualCI finds the baseline through the commit's ancestors - run: npm test -- -u # write snapshots instead of failing; see the snapshot guides - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@vx.y.z if: always() with: token: ${{ secrets.VISUALCI_TOKEN }} @@ -31,6 +37,8 @@ jobs: screenshots --platform chromium-linux --threshold 0.1 ``` +Run it on `pull_request` and on pushes to your main branch only: with `push` on every branch too, each commit to a pull request runs twice and sends two builds. + The action installs the CLI, creates the build, uploads and finalizes it. `upload` takes one `visualci upload` per line, as its arguments (paths, `--from`, `--prefix`, `--platform`, `--format`); leave it out to send the `uploads` in [visualci.yml](https://visualci.com/docs/reference/config.md). Without a token the step fails, so a misnamed secret can't pass quietly. The token comes from `token`, or from `VISUALCI_TOKEN` in the workflow's or job's `env`. The exceptions are where GitHub passes no repository secrets: a fork's pull request and runs in a fork get none, and Dependabot's pull requests get only Dependabot secrets. The action skips those with a notice; [send a fork's from a second workflow](#pull-requests-from-forks), and add `VISUALCI_TOKEN` to the Dependabot secrets to review Dependabot's. | Input | What it does | @@ -55,7 +63,7 @@ Every job of a workflow run that uses the same `name` joins one build. Send from browser: [chromium, webkit] steps: # ... checkout and tests ... - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@vx.y.z with: token: ${{ secrets.VISUALCI_TOKEN }} finalize: false @@ -67,7 +75,7 @@ Every job of a workflow run that uses the same `name` joins one build. Send from - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@vx.y.z with: token: ${{ secrets.VISUALCI_TOKEN }} finalize-only: true @@ -111,7 +119,7 @@ jobs: - uses: actions/checkout@v4 # your default branch: the fork's commits are only fetched with: fetch-depth: 0 - - uses: DocSpring/visualci/clients/github-action@v0.2.23 + - uses: DocSpring/visualci/clients/github-action@vx.y.z with: token: ${{ secrets.VISUALCI_TOKEN }} artifact: visualci @@ -179,7 +187,7 @@ jobs: - 'templates/**' - name: Install VisualCI run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - name: Start a VisualCI build # A skipped run sends nothing: --subset carries every snapshot forward. @@ -223,7 +231,7 @@ jobs: fetch-depth: 0 - name: Install VisualCI run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$RUNNER_TEMP" sh echo "$RUNNER_TEMP" >> "$GITHUB_PATH" - name: Start a VisualCI build run: echo "VISUALCI_BUILD_ID=$(visualci build create)" >> "$GITHUB_ENV" diff --git a/skills/visualci-gitlab/SKILL.md b/skills/visualci-gitlab/SKILL.md index 91010273..3d496428 100644 --- a/skills/visualci-gitlab/SKILL.md +++ b/skills/visualci-gitlab/SKILL.md @@ -10,6 +10,8 @@ metadata: # GitLab CI +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + The CLI reads the commit from `CI_COMMIT_SHA`, the branch from `CI_COMMIT_REF_NAME` and the merge request from `CI_MERGE_REQUEST_IID`. In a merged results pipeline it reports the source branch's commit and name (`CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` and `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME`), not the merge commit. ```yaml @@ -18,7 +20,7 @@ visual: variables: GIT_DEPTH: 0 # VisualCI finds the baseline through the commit's ancestors script: - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR=/usr/local/bin sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR=/usr/local/bin sh - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u - visualci upload --from auto src tests diff --git a/skills/visualci-jenkins/SKILL.md b/skills/visualci-jenkins/SKILL.md index 45436425..26da9c24 100644 --- a/skills/visualci-jenkins/SKILL.md +++ b/skills/visualci-jenkins/SKILL.md @@ -10,6 +10,8 @@ metadata: # Jenkins +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Store a project token as a **Secret text** credential, say `visualci-token`. The CLI reads the commit from `GIT_COMMIT`, the branch from `CHANGE_BRANCH`, `BRANCH_NAME` or `GIT_BRANCH`, and the pull request from `CHANGE_ID`. ```groovy @@ -21,7 +23,7 @@ pipeline { stages { stage('Test') { steps { - sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$WORKSPACE/bin" sh' + sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$WORKSPACE/bin" sh' sh ''' export PATH="$WORKSPACE/bin:$PATH" export VISUALCI_BUILD_ID=$(visualci build create) diff --git a/skills/visualci-laravel-rust/SKILL.md b/skills/visualci-laravel-rust/SKILL.md index 81146412..d9e89100 100644 --- a/skills/visualci-laravel-rust/SKILL.md +++ b/skills/visualci-laravel-rust/SKILL.md @@ -10,6 +10,8 @@ metadata: # Laravel Rust +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + [snapshot-testing-laravel](https://github.com/DocSpring/snapshot-testing-laravel-rs) is snapshot testing for [Laravel Rust](https://laravel.com/rust) apps: browser screenshots, plus HTML, JSON and text snapshots of your responses. On its own it keeps baselines as files in your repository. With `VISUALCI_TOKEN` set, it sends every snapshot to VisualCI instead, through the `visualci` CLI, and changes wait for review there. ```rust @@ -54,7 +56,7 @@ For snapshots without a browser, `default-features = false` leaves the browser o Then the CLI, and a project token (see [Quick start](https://visualci.com/docs/quick-start.md)): ```sh -curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 sh +curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z sh export VISUALCI_TOKEN=vci_... ``` @@ -81,7 +83,7 @@ On GitHub Actions: node-version: 22 - run: npx -y playwright@1.65.2 install --with-deps --only-shell chromium - run: | - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$HOME/bin" sh echo "$HOME/bin" >> "$GITHUB_PATH" - run: visualci test -- cargo test --locked env: diff --git a/skills/visualci-semaphore/SKILL.md b/skills/visualci-semaphore/SKILL.md index 0b0b35a7..83045812 100644 --- a/skills/visualci-semaphore/SKILL.md +++ b/skills/visualci-semaphore/SKILL.md @@ -10,6 +10,8 @@ metadata: # Semaphore +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Create a secret named `visualci` with the environment variable `VISUALCI_TOKEN` (a project token). The CLI reads the commit from `SEMAPHORE_GIT_PR_SHA` or `SEMAPHORE_GIT_SHA`, the branch from `SEMAPHORE_GIT_PR_BRANCH` or `SEMAPHORE_GIT_BRANCH`, and the pull request from `SEMAPHORE_GIT_PR_NUMBER`. ```yaml @@ -28,7 +30,7 @@ blocks: - name: Test commands: - checkout - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$HOME/bin" sh - export PATH="$HOME/bin:$PATH" - export VISUALCI_BUILD_ID=$(visualci build create) - npm test -- -u # write snapshots instead of failing; see the snapshot guides diff --git a/skills/visualci-teamcity/SKILL.md b/skills/visualci-teamcity/SKILL.md index 904ea38d..16f4d854 100644 --- a/skills/visualci-teamcity/SKILL.md +++ b/skills/visualci-teamcity/SKILL.md @@ -10,6 +10,8 @@ metadata: # TeamCity +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + The CLI doesn't read TeamCity's parameters by itself: pass them as environment variables. Add a password parameter `env.VISUALCI_TOKEN` with a project token, and these to the build configuration: | Parameter | Value | @@ -21,7 +23,7 @@ The CLI doesn't read TeamCity's parameters by itself: pass them as environment v Then a command-line step: ```sh -curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$PWD/bin" sh +curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$PWD/bin" sh export PATH="$PWD/bin:$PATH" export VISUALCI_BUILD_ID=$(visualci build create) npm test -- -u # write snapshots instead of failing; see the snapshot guides diff --git a/skills/visualci-travis/SKILL.md b/skills/visualci-travis/SKILL.md index 478b1115..32181798 100644 --- a/skills/visualci-travis/SKILL.md +++ b/skills/visualci-travis/SKILL.md @@ -10,6 +10,8 @@ metadata: # Travis CI +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + Add `VISUALCI_TOKEN` (a project token) as a repository environment variable, hidden from the build log. The CLI reads the commit from `TRAVIS_PULL_REQUEST_SHA` or `TRAVIS_COMMIT`, the branch from `TRAVIS_PULL_REQUEST_BRANCH` or `TRAVIS_BRANCH`, and the pull request from `TRAVIS_PULL_REQUEST`. ```yaml @@ -19,7 +21,7 @@ git: depth: false install: - npm ci - - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh + - curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR="$HOME/bin" sh script: - export PATH="$HOME/bin:$PATH" - export VISUALCI_BUILD_ID=$(visualci build create) diff --git a/skills/visualci/SKILL.md b/skills/visualci/SKILL.md index bcb5860c..55bb1a81 100644 --- a/skills/visualci/SKILL.md +++ b/skills/visualci/SKILL.md @@ -10,6 +10,8 @@ metadata: # Quick start +Replace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest + To see what a review looks like first, open the [demo build](https://app.visualci.com/visualci/demo): no sign-in needed. ## 1. Install the GitHub App @@ -45,7 +47,7 @@ Install the CLI on Linux (x86_64 or arm64) or macOS: curl -fsSL https://visualci.com/install.sh | sh ``` -It installs to `/usr/local/bin`, or to `$VISUALCI_INSTALL_DIR`, and checks the download's SHA-256. In CI, pin the version with `VISUALCI_VERSION=0.2.23`, so a new release never changes a build by surprise. It downloads the latest [GitHub release](https://github.com/DocSpring/visualci/releases) for Linux (x86_64 and arm64) or macOS. Anywhere else with Rust, build it from source: +It installs to `/usr/local/bin`, or to `$VISUALCI_INSTALL_DIR`, and checks the download's SHA-256. In CI, pin the version with `VISUALCI_VERSION=x.y.z`, so a new release never changes a build by surprise. It downloads the latest [GitHub release](https://github.com/DocSpring/visualci/releases) for Linux (x86_64 and arm64) or macOS. Anywhere else with Rust, build it from source: ```sh cargo install --git https://github.com/DocSpring/visualci visualci-cli From 9e1de0fac27d8f800938480db15df18126536a37 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Fri, 4 Dec 2026 19:08:54 +1300 Subject: [PATCH 2/2] Docs CLI release: fill it in public/ci.md too; get_skill golden --- .../get_skill-2.json | 2 +- frontend/public/ci.md | 2 +- frontend/scripts/prerender.mjs | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json index 9b3a434c..a8f8171c 100644 --- a/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json +++ b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json @@ -5,7 +5,7 @@ "result": { "content": [ { - "text": "---\nname: visualci-jenkins\ndescription: \"Sets up VisualCI in a Jenkins pipeline (Jenkinsfile): the token as a credential, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel stages. Use when the user wants visual or snapshot review in Jenkins, or a project has a Jenkinsfile and VisualCI. Not for other CI providers, or for writing the tests themselves.\"\nlicense: Apache-2.0\nmetadata:\n docs: https://visualci.com/docs/ci/jenkins.md\n---\n\n\n\n# Jenkins\n\nStore a project token as a **Secret text** credential, say `visualci-token`. The CLI reads the commit from `GIT_COMMIT`, the branch from `CHANGE_BRANCH`, `BRANCH_NAME` or `GIT_BRANCH`, and the pull request from `CHANGE_ID`.\n\n```groovy\npipeline {\n agent any\n environment {\n VISUALCI_TOKEN = credentials('visualci-token')\n }\n stages {\n stage('Test') {\n steps {\n sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR=\"$WORKSPACE/bin\" sh'\n sh '''\n export PATH=\"$WORKSPACE/bin:$PATH\"\n export VISUALCI_BUILD_ID=$(visualci build create)\n npm test -- -u # write snapshots instead of failing; see the snapshot guides\n visualci upload --from auto src tests\n visualci build finalize\n '''\n }\n }\n }\n}\n```\n\nEach `sh` step is its own shell, so keep the build's commands in one step, or pass `VISUALCI_BUILD_ID` on with `withEnv`.\n\n## Parallel stages\n\nCreate the build once, then give each parallel stage a shard number:\n\n```groovy\nstage('Start VisualCI') {\n steps {\n script {\n env.VISUALCI_BUILD_ID = sh(script: 'bin/visualci build create --shards 2', returnStdout: true).trim()\n }\n }\n}\nstage('Tests') {\n parallel {\n stage('Unit') { steps { sh 'npm run test:unit -- -u && bin/visualci upload --from auto src && bin/visualci build finalize --shard 0' } }\n stage('Browser') { steps { sh 'npm run test:e2e && bin/visualci upload screenshots && bin/visualci build finalize --shard 1' } }\n }\n}\n```\n\nSee [Other CI providers](https://visualci.com/docs/ci/other.md) for the environment variables and how shards work.\n\nThis skill is the page https://visualci.com/docs/ci/jenkins.md. All of VisualCI's documentation: https://visualci.com/llms.txt\n", + "text": "---\nname: visualci-jenkins\ndescription: \"Sets up VisualCI in a Jenkins pipeline (Jenkinsfile): the token as a credential, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel stages. Use when the user wants visual or snapshot review in Jenkins, or a project has a Jenkinsfile and VisualCI. Not for other CI providers, or for writing the tests themselves.\"\nlicense: Apache-2.0\nmetadata:\n docs: https://visualci.com/docs/ci/jenkins.md\n---\n\n\n\n# Jenkins\n\nReplace x.y.z below with the newest release of the VisualCI CLI: https://github.com/DocSpring/visualci/releases/latest\n\nStore a project token as a **Secret text** credential, say `visualci-token`. The CLI reads the commit from `GIT_COMMIT`, the branch from `CHANGE_BRANCH`, `BRANCH_NAME` or `GIT_BRANCH`, and the pull request from `CHANGE_ID`.\n\n```groovy\npipeline {\n agent any\n environment {\n VISUALCI_TOKEN = credentials('visualci-token')\n }\n stages {\n stage('Test') {\n steps {\n sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=x.y.z VISUALCI_INSTALL_DIR=\"$WORKSPACE/bin\" sh'\n sh '''\n export PATH=\"$WORKSPACE/bin:$PATH\"\n export VISUALCI_BUILD_ID=$(visualci build create)\n npm test -- -u # write snapshots instead of failing; see the snapshot guides\n visualci upload --from auto src tests\n visualci build finalize\n '''\n }\n }\n }\n}\n```\n\nEach `sh` step is its own shell, so keep the build's commands in one step, or pass `VISUALCI_BUILD_ID` on with `withEnv`.\n\n## Parallel stages\n\nCreate the build once, then give each parallel stage a shard number:\n\n```groovy\nstage('Start VisualCI') {\n steps {\n script {\n env.VISUALCI_BUILD_ID = sh(script: 'bin/visualci build create --shards 2', returnStdout: true).trim()\n }\n }\n}\nstage('Tests') {\n parallel {\n stage('Unit') { steps { sh 'npm run test:unit -- -u && bin/visualci upload --from auto src && bin/visualci build finalize --shard 0' } }\n stage('Browser') { steps { sh 'npm run test:e2e && bin/visualci upload screenshots && bin/visualci build finalize --shard 1' } }\n }\n}\n```\n\nSee [Other CI providers](https://visualci.com/docs/ci/other.md) for the environment variables and how shards work.\n\nThis skill is the page https://visualci.com/docs/ci/jenkins.md. All of VisualCI's documentation: https://visualci.com/llms.txt\n", "type": "text" } ], diff --git a/frontend/public/ci.md b/frontend/public/ci.md index 6a21d5e9..b764cbe9 100644 --- a/frontend/public/ci.md +++ b/frontend/public/ci.md @@ -6,7 +6,7 @@ https://visualci.com/install.md for the whole setup). The token is the CI secret Every provider runs the same three steps around the tests: ```sh -curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.23 VISUALCI_INSTALL_DIR="$HOME/bin" sh +curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION={{cli_version}} VISUALCI_INSTALL_DIR="$HOME/bin" sh export VISUALCI_BUILD_ID=$(visualci build create) # run the tests (writing snapshots instead of failing), then: visualci upload # sends visualci.yml's uploads diff --git a/frontend/scripts/prerender.mjs b/frontend/scripts/prerender.mjs index 37f4d57a..a3f53404 100644 --- a/frontend/scripts/prerender.mjs +++ b/frontend/scripts/prerender.mjs @@ -420,4 +420,19 @@ console.log(`wrote dist/llms.txt and dist/llms-full.txt (${full.length} characte console.log(`wrote the hosts into ${count} site pages`) } +// public/'s Markdown and text files for agents (ci.md and the rest) are copied as they are: fill in the CLI release there too. +async function publicTextFiles(dir, base = dir) { + const out = [] + for (const entry of await readdir(dir, { withFileTypes: true })) { + const path = join(dir, entry.name) + if (entry.isDirectory()) out.push(...(await publicTextFiles(path, base))) + else if (/\.(md|txt)$/.test(entry.name)) out.push(path.slice(base.length + 1)) + } + return out +} +for (const file of await publicTextFiles(join(root, 'public'))) { + const text = await readFile(join(dist, file), 'utf8') + if (text.search(/\{\{cli_version\}\}/) >= 0) await writeFile(join(dist, file), fillCliVersion(text, cliVersion)) +} + await rm(join(root, 'dist-ssr'), { recursive: true, force: true })