-
Notifications
You must be signed in to change notification settings - Fork 4
126 lines (107 loc) · 3.94 KB
/
update-golden.yml
File metadata and controls
126 lines (107 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
#
# Regenerate PDF visual regression golden baselines on a CI runner
# and open a PR with the updated PNGs.
#
# Workflow:
# 1. Code change causes golden drift → pr-validate CI fails
# 2. Developer triggers this workflow (optionally targeting a branch)
# 3. Goldens are regenerated on the same runner/fonts as CI
# 4. A PR is opened with the visual diff for review
#
# Usage:
# gh workflow run update-golden.yml -f branch=my-feature-branch
name: Update Golden Baselines
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to regenerate goldens on (default: main)"
required: false
default: "main"
type: string
permissions:
contents: write
pull-requests: write
concurrency:
group: update-golden-${{ inputs.branch }}
cancel-in-progress: true
jobs:
update-goldens:
name: Regenerate PDF Goldens
runs-on:
[
self-hosted,
Linux,
X64,
"1ES.Pool=hld-kvm-amd",
"JobId=update-golden-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}",
]
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
# Full history not needed, but we need push access
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v6
with:
node-version: "22"
- uses: hyperlight-dev/ci-setup-workflow@v1.9.0
with:
rust-toolchain: "1.89"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install PDF test dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq poppler-utils qpdf fonts-dejavu-core
- name: Setup
run: just setup
- name: Regenerate golden baselines
run: UPDATE_GOLDEN=1 npx vitest run tests/pdf-visual.test.ts
- name: Check for changes
id: diff
run: |
if git diff --quiet tests/golden/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "✅ No golden changes detected — baselines already match."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "📸 Golden baselines updated:"
git diff --stat tests/golden/
fi
- name: Create golden update PR
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="update-golden/${{ inputs.branch }}"
# Configure git for the commit
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Stage ONLY golden files — nothing else (e.g. package-lock.json from setup)
git add tests/golden/
# Create or update the golden update branch
git checkout -B "$BRANCH"
git commit -m "test: update PDF golden baselines from CI"
git push --force-with-lease origin "$BRANCH"
# Create PR if one doesn't already exist for this branch
if ! gh pr view "$BRANCH" --json state -q '.state' 2>/dev/null | grep -q OPEN; then
gh pr create \
--base "${{ inputs.branch }}" \
--head "$BRANCH" \
--title "test: update PDF golden baselines" \
--body "$(cat <<'EOF'
🖼️ **Automated golden baseline update**
Regenerated PDF visual regression baselines on the CI runner
(`hld-kvm-amd` pool with `fonts-dejavu-core`).
**Source branch**: `${{ inputs.branch }}`
**Triggered by**: @${{ github.actor }}
Review the PNG diffs below to verify the visual changes are expected.
EOF
)" \
--label "test" \
--label "automated"
else
echo "ℹ️ PR already exists for $BRANCH — pushed updated goldens."
fi