-
Notifications
You must be signed in to change notification settings - Fork 20
278 lines (233 loc) · 8.49 KB
/
build-extension.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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: Extension Builder
# Run this workflow every time a new commit pushed to your repository
on:
push:
branches:
- master
pull_request:
jobs:
test-javascript-libraries:
name: Test the Javascript libraries
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: browser-extensions/common/js/tests
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v4
- name: Configure node v20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install test framework dependencies
run: npm install
- name: Run tests
run: npm run test-with-coverage
# Set the job key. The key is displayed as the job name
# when a job name is not provided
build-extension:
# Name the Job
name: Build the extension
# Set the type of machine to run on
runs-on: ubuntu-latest
strategy:
matrix:
browser: ["chrome", "firefox"]
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v4
- name: Configure node v20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install web-ext tooling
run: npm install -g web-ext
# Runs a script
- name: Build ${{ matrix.browser }} Extension
run: |
echo "Building extension for ${{ matrix.browser }} at `date`"
# Make the build script executable
chmod +x ./build/extension-${{ matrix.browser }}/build.sh
# Build the extension
./build/extension-${{ matrix.browser }}/build.sh
shell: bash
env:
EXTENSION_BUILD_ID: ${{ github.run_number }}
- name: Upload build extension package
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.browser }}-extension-package
path: browser-extensions/${{ matrix.browser }}/build/web-ext-artifacts/running_challenges-*.zip
integration-test:
name: UI Testing
runs-on: ubuntu-latest
needs:
- build-extension
- test-javascript-libraries
strategy:
matrix:
country_hostname:
- "parkrun.ca"
- "parkrun.co.at"
- "parkrun.co.nl"
- "parkrun.co.nz"
- "parkrun.co.za"
- "parkrun.com.au"
- "parkrun.us"
- "parkrun.dk"
- "parkrun.fi"
- "parkrun.fr"
- "parkrun.ie"
- "parkrun.it"
- "parkrun.jp"
- "parkrun.lt"
- "parkrun.my"
- "parkrun.no"
- "parkrun.org.uk"
- "parkrun.pl"
- "parkrun.se"
- "parkrun.sg"
# - "parkrun.ru" # Russian events are suspended
fail-fast: false
# max-parallel: 1
defaults:
run:
shell: bash
working-directory: browser-extensions/common/js/tests/ui-test
steps:
# Checks out a copy of the repository
- name: Checkout code
uses: actions/checkout@v4
# Get previously built packages
- name: Download all built extension packages
uses: actions/download-artifact@v4
with:
path: browser-extensions/common/js/tests/ui-test/extension-binaries
- name: Show built extension packages
run: ls -lR extension-binaries
- name: Configure node v20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Required OS packages
run: |
sudo apt-get update && \
sudo apt-get install -y xvfb unzip
- name: Start up the supporting nginx services
run: |
echo "Creating a certificate"
cd ./supporting-data/nginx/cert/
bash generate.sh
cd -
echo "Starting up docker compose services"
docker compose -f "./supporting-data/docker-compose-gh-actions.yml" up --force-recreate -d
# Give nginx a moment to have fully come up
sleep 1
# Make the changes to /etc/hosts so that the tests reference the above containers.
echo "Append to /etc/hosts to use this nginx"
sudo bash -c 'cat ./supporting-data/etc-hosts.txt >> /etc/hosts'
- name: Unpack extension
run: |
ls -lR extension-binaries
cd extension-binaries/chrome-extension-package
unzip *.zip
- name: Install Node dependencies
run: npm ci
- name: Install Playwright Browsers
run: |
npx playwright install --with-deps chromium
- name: Run Playwright tests
run: xvfb-run npx playwright test
env:
COUNTRY_HOSTNAME: "${{ matrix.country_hostname }}"
- name: list files in root dir
run: ls -l
- uses: actions/upload-artifact@v4
if: always()
with:
name: ui-tests-chrome-${{ matrix.country_hostname }}
path: |
browser-extensions/common/js/tests/ui-test/playwright-report/
browser-extensions/common/js/tests/ui-test/screenshot.png
retention-days: 30
# This stage will run once the extensions have been built, and should only run if they were successful.
# Assuming they are successful, we will push them somewhere they can be used.
# If we are on the master branch, and it is tagged as a release versino, we should create a release
publish-extension:
name: Push the build extensions somewhere
runs-on: ubuntu-latest
needs:
- integration-test
# if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all built extension packages
uses: actions/download-artifact@v4
with:
path: extension-binaries
- name: Show built extension packages
run: ls -lR extension-binaries
- id: get-branch-version-tag
uses: actions/github-script@v7
with:
script: |
console.log(context)
console.log(context.ref)
console.log(github.ref)
// This script will create a release, and upload our files and release notes to it
if (!"${{ github.ref }}".startsWith('refs/tags/v')) {
return
}
// Find the version tag
var version_tag = github.ref.replace("refs/tags/", "")
console.log(version_tag)
// Store it in the step output variables
core.setOutput('version_tag', version_tag)
/*
// TODO: Do we need to check if this release already exists?
// Create a release
github.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: version_tag,
name: <name of the release>,
body: <text for the release>,
draft: false,
prelease: false,
})
// Upload all the artifacts to it
github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ...
})
*/
# if: startsWith(github.ref, 'refs/tags/v')
# - id: get-branch-version-tag
# uses: actions/github-script@v7
# with:
# script: |
# var version_tag = ''
# if (github.ref.startsWith('refs/tags/v')){
# version_tag = github.ref.split('/')[2]
# }
# core.setOutput('version_tag', version_tag)
# if: startsWith(github.ref, 'refs/tags/v')
- run: echo "branch version tag is ${{steps.get-branch-version-tag.outputs.version_tag}}"
# if: startsWith(github.ref, 'refs/tags/v')
# We might be able to use the github script action instead of this to script what we need to do in one go
- name: Create release
uses: softprops/action-gh-release@v1 # Read the docs here: https://github.com/softprops/action-gh-release
if: startsWith(github.ref, 'refs/tags/v')
with:
name: Running Challenges ${{steps.get-branch-version-tag.outputs.version_tag}}
files: "extension-binaries/*/running_challenges*.zip"
body: |
Release notes go here
# body_path: Auto/manually generated file for release notes goes here
fail_on_unmatched_files: True
draft: True # We'll move it to release when it's all tested and known to be working
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}