-
Notifications
You must be signed in to change notification settings - Fork 34
67 lines (58 loc) · 2.06 KB
/
baseline-visual-regression.yml
File metadata and controls
67 lines (58 loc) · 2.06 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
# This workflow runs Percy visual regression tests after a PR tagged with "package: skin"
# is merged into the main branch. It extracts the list of stories from the PR body
# and runs snapshots for those stories to update the visual regression baselines.
name: Percy Merged Visual Regression Baselines
on:
push:
branches:
- main
jobs:
post-merge-snapshots:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
# Install dependencies
- name: Install dependencies
run: npm install
working-directory: ./packages/skin
# Extract target stories from PR body
- name: Extract target stories
id: extract_stories
run: |
# Get the last merged PR details
PR_BODY=$(gh pr view $(git log -1 --pretty=format:"%s" | grep -oP '#\d+') --json body -q '.body')
if [[ $PR_BODY == *"package: skin"* ]]; then
STORIES=$(echo "$PR_BODY" | awk '/Percy Stories/{getline; print}')
if [ -z "$STORIES" ]; then
echo "No Percy Stories found in PR body."
exit 0
fi
echo "stories=$STORIES" >> $GITHUB_ENV
else
echo "No relevant PR found for package: skin."
exit 0
fi
working-directory: ./packages/skin
# Debug: Print extracted stories
- name: Debug extracted stories
run: echo "Extracted stories: $stories"
working-directory: ./packages/skin
# Run Percy for the extracted stories
- name: Run Percy visual tests
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
run: |
if [ -z "$stories" ]; then
echo "No target stories found. Skipping Percy tests."
exit 0
fi
echo "Running Percy for stories: $stories"
npm run snapshots "$stories"
working-directory: ./packages/skin