-
Notifications
You must be signed in to change notification settings - Fork 135
132 lines (111 loc) · 3.75 KB
/
e2e-tests.yml
File metadata and controls
132 lines (111 loc) · 3.75 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
127
128
129
130
131
132
name: E2E Tests
on:
push:
paths:
- '**.js'
- '**.jsx'
- '**.ts'
- '**.tsx'
- '**.scss'
- '**.css'
- 'package.json'
- 'package-lock.json'
- 'webpack.config.js'
- '.wp-env.json'
- 'tests/e2e/**'
- '.github/workflows/e2e-tests.yml'
pull_request:
branches: [develop, main]
paths:
- '**.js'
- '**.jsx'
- '**.ts'
- '**.tsx'
- '**.scss'
- '**.css'
- 'package.json'
- 'package-lock.json'
- 'webpack.config.js'
- '.wp-env.json'
- 'tests/e2e/**'
- '.github/workflows/e2e-tests.yml'
workflow_dispatch:
# Disable all permissions by default; grant minimal permissions per job
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up NodeJS 20
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build assets
run: npm run build
- name: Verify built assets exist
run: |
echo "Checking custom-status assets..."
test -f build/custom-status-block.js || (echo "Missing: build/custom-status-block.js" && exit 1)
test -f build/custom-status-block.css || (echo "Missing: build/custom-status-block.css" && exit 1)
echo "Checking calendar assets..."
test -f build/calendar-react.js || (echo "Missing: build/calendar-react.js" && exit 1)
test -f build/calendar-react.css || (echo "Missing: build/calendar-react.css" && exit 1)
echo "All expected assets present!"
- name: Report asset sizes
run: |
echo "### Asset Sizes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Size |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|" >> $GITHUB_STEP_SUMMARY
echo "| custom-status-block.js | $(du -h build/custom-status-block.js | cut -f1) |" >> $GITHUB_STEP_SUMMARY
echo "| calendar-react.js | $(du -h build/calendar-react.js | cut -f1) |" >> $GITHUB_STEP_SUMMARY
- name: Upload build artifacts
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: build-artifacts
path: build/
retention-days: 1
test:
name: E2E Tests
# Pin to ubuntu-22.04 for Playwright compatibility
# ubuntu-latest (24.04) has library version mismatches with Playwright's WebKit dependencies
runs-on: ubuntu-22.04
needs: build
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Set up NodeJS 20
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Download build artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: build-artifacts
path: build/
- name: Install Playwright browsers and system dependencies
run: npx playwright install --with-deps chromium
- name: Install WordPress with wp-env
run: npm run wp-env start
- name: Run E2E tests
run: npm run test-e2e