ext-apps/.github/workflows/update-snapshots.yml
Olivier Chafik b093e39560
ci: use npm ci with caching, validate typedoc links, align Node versions (#533)
- Switch npm install -> npm ci in ci.yml (build, build-wsl) and docs.yml
  to fail on lockfile drift rather than silently tolerating it
- Add cache: npm to all setup-node steps that have a lockfile to hash
  (skipped test-git-install which has no checkout, and WSL which has no
  setup-node action)
- Add TypeDoc link validation step after build (Linux x64 only, matching
  existing single-OS gate pattern for MCPB). Verified passing on main.
- Align all workflows on Node 22 (active LTS) — previously CI used 20
  but publish workflows used 22, so releases were tested on a different
  Node than PRs
- Add engines.node >=20 to package.json so consumers on Node 18 get a
  warning
2026-03-06 17:13:58 +00:00

104 lines
3.2 KiB
YAML

name: Update E2E Snapshots
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to update snapshots on"
required: true
default: "main"
issue_comment:
types: [created]
permissions:
contents: write
pull-requests: write
jobs:
update-snapshots:
# Run on workflow_dispatch OR when someone comments "/update-snapshots" on a PR
if: >
github.event_name == 'workflow_dispatch' ||
(github.event.issue.pull_request && contains(github.event.comment.body, '/update-snapshots'))
runs-on: ubuntu-latest
steps:
- name: Get PR branch
if: github.event_name == 'issue_comment'
id: pr
uses: actions/github-script@v8
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('ref', pr.data.head.ref);
core.setOutput('sha', pr.data.head.sha);
- name: Add reaction to comment
if: github.event_name == 'issue_comment'
uses: actions/github-script@v8
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.branch || steps.pr.outputs.ref || github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
- uses: astral-sh/setup-uv@v7
- run: npm ci
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Update snapshots
run: npx playwright test --update-snapshots --reporter=list
- name: Commit updated snapshots
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add tests/e2e/**/*.png
if git diff --staged --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No snapshot changes to commit"
else
git commit -m "chore: update e2e snapshots [skip ci]"
git push
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Comment on PR
if: github.event_name == 'issue_comment'
uses: actions/github-script@v8
with:
script: |
const changed = '${{ steps.commit.outputs.changed }}' === 'true';
const body = changed
? '✅ Snapshots updated and pushed to this branch.'
: '✅ No snapshot changes needed - all snapshots are up to date.';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});