-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (153 loc) · 5.45 KB
/
test.yml
File metadata and controls
186 lines (153 loc) · 5.45 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Test
on:
push:
branches: [development, firefox-ci]
pull_request:
branches: [development]
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-chrome:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
- name: Log environment versions
run: |
echo "OS: ${{ matrix.os }}"
echo "Node: $(node --version)"
- name: Install dependencies
run: npm ci
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ${{ matrix.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || (matrix.os == 'windows-latest' && '~/AppData/Local/ms-playwright' || '~/.cache/ms-playwright') }}
key: playwright-${{ matrix.os }}-${{ hashFiles('package-lock.json') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium --with-deps
# Only needed on Linux - Windows/macOS have system deps pre-installed
- name: Install Playwright dependencies (Linux only)
if: steps.playwright-cache.outputs.cache-hit == 'true' && matrix.os == 'ubuntu-latest'
run: npx playwright install-deps chromium
- name: Build Chrome extension
run: npm run build:chrome
- name: Validate GitHub API PAT
id: validate-pat
shell: bash
env:
API_CONTRACT_TEST_PAT: ${{ secrets.API_CONTRACT_TEST_PAT }}
run: |
if [ -z "$API_CONTRACT_TEST_PAT" ]; then
echo "error_msg=API_CONTRACT_TEST_PAT secret is not configured. The API contract test requires this secret." >> "$GITHUB_OUTPUT"
exit 0
fi
response=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $API_CONTRACT_TEST_PAT" \
https://api.github.com/rate_limit)
if [ "$response" = "401" ]; then
echo "error_msg=API_CONTRACT_TEST_PAT is expired or invalid (HTTP 401). Please update the repository secret." >> "$GITHUB_OUTPUT"
elif [ "$response" != "200" ]; then
echo "error_msg=GitHub API returned HTTP $response when validating PAT." >> "$GITHUB_OUTPUT"
fi
- name: Run tests (excluding @auth-pat and @auth-session)
run: npm run test:chrome -- --grep-invert "@auth-pat|@auth-session"
- name: Run @auth-pat tests
if: ${{ !steps.validate-pat.outputs.error_msg }}
run: npm run test:chrome -- --grep @auth-pat
env:
API_CONTRACT_TEST_PAT: ${{ secrets.API_CONTRACT_TEST_PAT }}
- name: Fail @auth-pat tests (PAT issue)
if: ${{ steps.validate-pat.outputs.error_msg }}
shell: bash
run: |
echo "::error::${{ steps.validate-pat.outputs.error_msg }}"
exit 1
- name: Skip @auth-session tests (no session auth in CI)
run: echo "::notice::@auth-session tests skipped - GitHub session auth not available in CI"
- name: Upload Chrome extension
uses: actions/upload-artifact@v4
with:
name: chrome-extension-${{ matrix.os }}
path: build/bundle/*.zip
retention-days: 7
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.os }}
path: tests/runs/chrome/report/
retention-days: 7
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.os }}
path: tests/runs/chrome/results/
retention-days: 7
if-no-files-found: ignore
test-firefox:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build Firefox extension
run: npm run build:firefox
- name: Run Firefox tests
run: npm run test:firefox
- name: Upload Firefox test screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: firefox-screenshots-${{ matrix.os }}
path: tests/runs/firefox/screenshots/
retention-days: 7
if-no-files-found: ignore
lint:
runs-on: macos-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build Firefox extension
run: npm run build:firefox
- name: Lint extension
run: npm run lint
- name: Upload Firefox extension
uses: actions/upload-artifact@v4
with:
name: firefox-extension
path: build/bundle/*.xpi
retention-days: 7