-
Notifications
You must be signed in to change notification settings - Fork 26
143 lines (121 loc) · 4.43 KB
/
update-snapshots.yml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Update E2E Snapshots
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, labeled]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
oisy-backend-wasm:
runs-on: ubuntu-24.04
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-e2e-snapshots') }}
permissions:
contents: write
packages: write
steps:
- name: Checkout
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v4
- name: Checkout for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Build oisy-backend WASM
uses: ./.github/actions/oisy-backend
update_snapshots:
runs-on: ${{ matrix.os }}
needs: oisy-backend-wasm
strategy:
matrix:
os: [ubuntu-24.04, macos-14]
env:
MATRIX_OS: ${{ matrix.os }}
if: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-e2e-snapshots') }}
steps:
- name: Fail if branch is main
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
run: |
echo "This workflow should not be triggered with workflow_dispatch on main"
exit 1
- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
- name: Checkout
if: ${{ github.event_name != 'pull_request' }}
uses: actions/checkout@v4
- name: Checkout for pull request
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.app-token.outputs.token }}
- name: Download WASM artifact
uses: actions/download-artifact@v4
with:
name: backend.wasm.gz
- name: Prepare macOS
if: runner.os == 'macOS'
uses: ./.github/actions/prepare-macos
- name: Set Environment Variables
run: echo "VITE_ETHERSCAN_API_KEY=${{ secrets.VITE_ETHERSCAN_API_KEY_E2E }}" >> $GITHUB_ENV
- name: Deploy the backend
uses: ./.github/actions/deploy-backend
- name: Prepare
uses: ./.github/actions/prepare
- name: Run Playwright tests
run: npm run e2e:snapshots
- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.os }}
path: playwright-report/
retention-days: 3
- name: Upload Playwright Results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.os }}
path: test-results/
retention-days: 3
- name: Commit Playwright updated snapshots
uses: EndBug/add-and-commit@v9
if: ${{ github.ref != 'refs/heads/main' }}
with:
add: e2e
default_author: github_actions
message: '🤖 Update E2E snapshots'
- name: Stage Changes
if: github.ref == 'refs/heads/main'
run: git add .
- name: Check for Changes
if: github.ref == 'refs/heads/main'
run: |
if ! git diff --cached --quiet; then
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
MODIFIED_FILES=$(git diff --cached --name-only)
echo "MODIFIED_FILES<<EOF" >> $GITHUB_ENV
echo "$MODIFIED_FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Create Pull Request (if changes and on main)
if: github.ref == 'refs/heads/main' && env.CHANGES_DETECTED == 'true'
uses: ./.github/actions/create-pr
with:
token: ${{ steps.app-token.outputs.token }}
branch: bot-e2e-update-snapshots
title: 'chore(e2e): Update Playwright E2E Snapshots'
body: |
The following E2E snapshots have been updated:
```
${{ env.MODIFIED_FILES }}