Skip to content

Commit 4098d2a

Browse files
committed
chore: build @vfx-js/core before VRT
1 parent 549ebde commit 4098d2a

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

.github/workflows/vrt.yml

+37-20
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@ on:
33
issue_comment:
44
types: [created]
55
jobs:
6-
chromatic:
6+
vrt:
7+
# Only run when a "/vrt" comment is posted on a PR
78
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/vrt' }}
89
runs-on: ubuntu-latest
910
permissions:
1011
pull-requests: write
1112
statuses: write
13+
checks: write # Required for creating and updating check runs
1214
steps:
13-
- name: Set pending status
15+
# Create a required check to block merging until VRT passes
16+
- name: Create Required Check
1417
uses: actions/github-script@v7
1518
with:
1619
script: |
1720
const { owner, repo } = context.repo;
18-
await github.rest.repos.createCommitStatus({
21+
// Create initial check run
22+
const check = await github.rest.checks.create({
1923
owner,
2024
repo,
21-
sha: context.sha,
22-
state: 'pending',
23-
context: 'VRT',
24-
description: 'VRT is running'
25+
name: 'VRT Status',
26+
head_sha: context.sha,
27+
status: 'in_progress',
28+
output: {
29+
title: 'VRT Required',
30+
summary: 'Visual Regression Test is now required for this PR'
31+
}
2532
});
2633
- name: Checkout repository
2734
uses: actions/checkout@v4
2835
with:
29-
fetch-depth: 0
36+
fetch-depth: 0 # Required for Chromatic to access git history
3037
- name: Setup Node
3138
uses: actions/setup-node@v4
3239
with:
@@ -35,26 +42,36 @@ jobs:
3542
cache-dependency-path: "**/package-lock.json"
3643
- name: Install dependencies
3744
run: npm ci
38-
- name: Publish to Chromatic
45+
- name: Build @vfx-js/core
46+
run: npm --workspace @vfx-js/core run build
47+
# Run Chromatic VRT
48+
- name: Run Chromatic
3949
id: chromatic
4050
uses: chromaui/action@latest
4151
with:
4252
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
43-
workingDir: packages/storybook
44-
buildScriptName: build-storybook
45-
- name: Update status
46-
if: always()
53+
workingDir: packages/storybook # Specify Storybook directory in workspace
54+
# Update check result based on Chromatic outcome
55+
- name: Update Check Result
56+
if: always() # Run this step even if previous steps fail
4757
uses: actions/github-script@v7
4858
with:
4959
script: |-
5060
const { owner, repo } = context.repo;
51-
await github.rest.repos.createCommitStatus({
61+
const conclusion = '${{ steps.chromatic.outcome }}' === 'success' ? 'success' : 'failure';
62+
63+
// Update check run with final result
64+
await github.rest.checks.create({
5265
owner,
5366
repo,
54-
sha: context.sha,
55-
state: '${{ steps.chromatic.outcome }}' === 'success' ? 'success' : 'failure',
56-
context: 'Chromatic',
57-
description: '${{ steps.chromatic.outcome }}' === 'success'
58-
? 'VRT passed'
59-
: 'VRT failed'
67+
name: 'VRT Status',
68+
head_sha: context.sha,
69+
status: 'completed',
70+
conclusion: conclusion,
71+
output: {
72+
title: conclusion === 'success' ? 'VRT Passed' : 'VRT Failed',
73+
summary: conclusion === 'success'
74+
? 'Visual Regression Test passed successfully'
75+
: 'Visual Regression Test failed - please check the results'
76+
}
6077
});

0 commit comments

Comments
 (0)