-
Notifications
You must be signed in to change notification settings - Fork 145
71 lines (56 loc) · 1.96 KB
/
run-tests-example-apps.yml
File metadata and controls
71 lines (56 loc) · 1.96 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
name: Run tests for example apps
on:
workflow_dispatch:
inputs:
update-screenshots:
description: "Update screenshots"
required: false
default: "false"
# TODO: Enable this when we test this workflow manually
# pull_request:
# branches:
# - develop
permissions:
contents: write
pull-requests: write
jobs:
run-tests-example-apps:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: cd examples/tests && npm ci
- name: Install Playwright browsers
run: cd examples/tests && npx playwright install --with-deps
- name: Install http-server globally
run: npm install -g http-server
- name: Run tests
if: inputs.update-screenshots == 'false'
run: cd examples/tests && npm test
- name: Run tests with updated screenshots
if: inputs.update-screenshots == 'true'
run: cd examples/tests && npm test -- --update-snapshots
- name: Upload screenshots
if: inputs.update-screenshots == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Create a branch and open a PR (unique branch name based on run id)
BRANCH="update-screenshots-${{ github.run_id }}"
git checkout -b "$BRANCH"
git add .
git commit -m 'ci: update screenshots' --allow-empty
# Push changes
git push origin "$BRANCH"
# Open PR
gh pr create \
--base main \
--head "$BRANCH" \
--title "ci: update screenshots" \
--body "Automated update of visual test screenshots from GitHub Actions workflow."