Skip to content

Commit 2b3720b

Browse files
authored
Consolidate Build & Test CI (#32929)
* Consolidate Build & Test CI * Add missing workflow dependency * Fix artifact name clash * Fix playwright config * Fix playwright_ew job * Fix ed tests * Fix playwright tags * Iterate * Fix file reads * Fix sample-files paths * Fix PW_TAG * Fix blob report paths * Delint * Fix build-and-test.yaml * Iterate * Fix consentHomeserver.ts * Simplify * Iterate * Delint * Iterate * Iterate * Iterate * Specify shell * Simplify * Delete apps/web/playwright/sample-files/index.ts * Discard changes to apps/web/playwright/sample-files/index.ts * Exclude playwright-common from coverage gate * Attempt to speed up arm64 desktop test * Revert "Attempt to speed up arm64 desktop test" This reverts commit 8fa8ff0. * Iterate * Fix cache key * Accept python or python3 as per node-gyp * Accept python or python3 as per node-gypd * Exclude apps/desktop/hak from coverage gate
1 parent cabac4e commit 2b3720b

18 files changed

+203
-254
lines changed

.github/workflows/end-to-end-tests-netlify.yaml renamed to .github/workflows/build-and-test-netlify.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
# Privilege escalation necessary to publish to Netlify
66
# 🚨 We must not execute any checked out code here.
77
workflow_run: # zizmor: ignore[dangerous-triggers]
8-
workflows: ["End to End Tests"]
8+
workflows: ["Build & Test"]
99
types:
1010
- completed
1111

Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# Produce a build of element-web with this version of react-sdk
2-
# and any matching branches of element-web and js-sdk, output it
3-
# as an artifact and run end-to-end tests.
4-
name: End to End Tests
1+
# builds Element Web
2+
# runs Playwright tests against the built Element Web
3+
# builds Element Desktop using the built Element Web
4+
#
5+
# Tries to use a matching js-sdk branch for the build.
6+
#
7+
# Produces a `webapp` artifact
8+
# Produces multiple Desktop artifacts
9+
# Produces multiple Playwright report artifacts
10+
name: Build & Test
511
on:
612
# CRON to run all Projects at 6am UTC
713
schedule:
@@ -10,7 +16,8 @@ on:
1016
merge_group:
1117
types: [checks_requested]
1218
push:
13-
branches: [develop, master]
19+
# We do not build on push to develop as the merge_group check handles that
20+
branches: [staging, master]
1421
repository_dispatch:
1522
types: [element-web-notify]
1623

@@ -35,15 +42,15 @@ concurrency:
3542
env:
3643
# fetchdep.sh needs to know our PR number
3744
PR_NUMBER: ${{ github.event.pull_request.number }}
38-
# Use 6 runners in the default case, but 4 when running on a schedule where we run all 5 projects (20 runners total)
39-
NUM_RUNNERS: ${{ github.event_name == 'schedule' && 4 || 6 }}
45+
# Use 4 runners in the default case, but only 1 when running on a schedule where we run all 5 projects
46+
NUM_RUNNERS: ${{ github.event_name == 'schedule' && 1 || 4 }}
4047
NX_DEFAULT_OUTPUT_STYLE: stream-without-prefixes
4148

4249
permissions: {} # No permissions required
4350

4451
jobs:
45-
build:
46-
name: "Build Element-Web"
52+
build_ew:
53+
name: "Build Element Web"
4754
runs-on: ubuntu-24.04
4855
if: inputs.skip != true
4956
outputs:
@@ -94,9 +101,9 @@ jobs:
94101
const matrix = Array.from({ length: numRunners }, (_, i) => i + 1);
95102
core.setOutput("matrix", JSON.stringify(matrix));
96103
97-
playwright:
98-
name: "Run Tests [${{ matrix.project }}] ${{ matrix.runner }}/${{ needs.build.outputs.num-runners }}"
99-
needs: build
104+
playwright_ew:
105+
name: "Run Tests [${{ matrix.project }}] ${{ matrix.runner }}/${{ needs.build_ew.outputs.num-runners }}"
106+
needs: build_ew
100107
if: inputs.skip != true
101108
runs-on: ubuntu-24.04
102109
permissions:
@@ -107,7 +114,7 @@ jobs:
107114
fail-fast: false
108115
matrix:
109116
# Run multiple instances in parallel to speed up the tests
110-
runner: ${{ fromJSON(needs.build.outputs.runners-matrix) }}
117+
runner: ${{ fromJSON(needs.build_ew.outputs.runners-matrix) }}
111118
project:
112119
- Chrome
113120
- Firefox
@@ -179,29 +186,85 @@ jobs:
179186
--project="${{ matrix.project }}" \
180187
${{ (github.event_name == 'pull_request' && matrix.runAllTests == false ) && '--grep-invert @mergequeue' || '' }}
181188
env:
182-
SHARD: ${{ format('{0}/{1}', matrix.runner, needs.build.outputs.num-runners) }}
189+
SHARD: ${{ format('{0}/{1}', matrix.runner, needs.build_ew.outputs.num-runners) }}
183190

184191
- name: Upload blob report to GitHub Actions Artifacts
185192
if: always()
186193
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
187194
with:
188-
name: all-blob-reports-${{ matrix.project }}-${{ matrix.runner }}
195+
name: blob-report-${{ matrix.project }}-${{ matrix.runner }}
189196
path: apps/web/blob-report
190197
retention-days: 1
198+
if-no-files-found: error
191199

192200
downstream-modules:
193201
name: Downstream Playwright tests [element-modules]
194-
needs: build
202+
needs: build_ew
195203
if: inputs.skip != true && github.event_name == 'merge_group'
196204
uses: element-hq/element-modules/.github/workflows/reusable-playwright-tests.yml@main # zizmor: ignore[unpinned-uses]
197205
with:
198206
webapp-artifact: webapp
199207

208+
prepare_ed:
209+
name: "Prepare Element Desktop"
210+
uses: ./.github/workflows/build_desktop_prepare.yaml
211+
needs: build_ew
212+
if: inputs.skip != true
213+
permissions:
214+
contents: read
215+
with:
216+
config: ${{ (github.event.pull_request.base.ref || github.ref_name) == 'develop' && 'element.io/nightly' || 'element.io/release' }}
217+
version: ${{ (github.event.pull_request.base.ref || github.ref_name) == 'develop' && 'develop' || '' }}
218+
webapp-artifact: webapp
219+
220+
build_ed_windows:
221+
needs: prepare_ed
222+
name: "Desktop Windows"
223+
uses: ./.github/workflows/build_desktop_windows.yaml
224+
if: inputs.skip != true
225+
strategy:
226+
matrix:
227+
arch: [x64, ia32, arm64]
228+
with:
229+
arch: ${{ matrix.arch }}
230+
blob_report: true
231+
232+
build_ed_linux:
233+
needs: prepare_ed
234+
name: "Desktop Linux"
235+
uses: ./.github/workflows/build_desktop_linux.yaml
236+
if: inputs.skip != true
237+
strategy:
238+
matrix:
239+
sqlcipher: [system, static]
240+
arch: [amd64, arm64]
241+
runAllTests:
242+
- ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'X-Run-All-Tests') }}
243+
# We ship static sqlcipher builds, so delegate testing the system builds to the merge queue
244+
exclude:
245+
- runAllTests: false
246+
sqlcipher: system
247+
with:
248+
sqlcipher: ${{ matrix.sqlcipher }}
249+
arch: ${{ matrix.arch }}
250+
blob_report: true
251+
252+
build_ed_macos:
253+
needs: prepare_ed
254+
name: "Desktop macOS"
255+
uses: ./.github/workflows/build_desktop_macos.yaml
256+
if: inputs.skip != true
257+
with:
258+
blob_report: true
259+
200260
complete:
201261
name: end-to-end-tests
202262
needs:
203-
- playwright
263+
- playwright_ew
204264
- downstream-modules
265+
- build_ed_windows
266+
- build_ed_linux
267+
- build_ed_macos
205268
if: always()
206269
runs-on: ubuntu-24.04
207270
steps:
@@ -227,26 +290,28 @@ jobs:
227290
if: inputs.skip != true
228291
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
229292
with:
230-
pattern: all-blob-reports-*
231-
path: apps/web/all-blob-reports
293+
pattern: blob-report-*
294+
path: all-blob-reports
232295
merge-multiple: true
233296

234297
- name: Merge into HTML Report
235298
if: inputs.skip != true
236-
working-directory: apps/web
237-
run: pnpm playwright merge-reports --reporter=html,./playwright/flaky-reporter.ts,@element-hq/element-web-playwright-common/lib/stale-screenshot-reporter.js ./all-blob-reports
299+
run: |
300+
pnpm playwright merge-reports \
301+
--config=playwright-merge.config.ts \
302+
./all-blob-reports
238303
env:
239304
# Only pass creds to the flaky-reporter on main branch runs
240305
GITHUB_TOKEN: ${{ github.ref_name == 'develop' && secrets.ELEMENT_BOT_TOKEN || '' }}
241-
PLAYWRIGHT_HTML_TITLE: ${{ case(github.event_name == 'pull_request', format('EW Playwright Report PR-{0}', env.PR_NUMBER), 'EW Playwright Report') }}
306+
PLAYWRIGHT_HTML_TITLE: ${{ case(github.event_name == 'pull_request', format('Playwright Report PR-{0}', env.PR_NUMBER), 'Playwright Report') }}
242307

243308
# Upload the HTML report even if one of our reporters fails, this can happen when stale screenshots are detected
244309
- name: Upload HTML report
245310
if: always() && inputs.skip != true
246311
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
247312
with:
248313
name: html-report
249-
path: apps/web/playwright-report
314+
path: playwright-report
250315
retention-days: 14
251316
if-no-files-found: error
252317

.github/workflows/build_desktop_and_test.yaml

Lines changed: 0 additions & 89 deletions
This file was deleted.

.github/workflows/build_desktop_linux.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
type: string
2929
required: false
3030
description: |
31-
The name of the prepare artifact to use, defaults to 'webapp'.
31+
The name of the prepare artifact to use, defaults to 'desktop-prepare'.
3232
The artifact must contain the following:
3333
+ webapp.asar - the asar archive of the webapp to embed in the desktop app
3434
+ electronVersion - the version of electron to use for cache keying
@@ -38,7 +38,7 @@ on:
3838
3939
The artifact can also contain any additional files which will be applied as overrides to the checkout root before building,
4040
for example icons in the `build/` directory to override the app icons.
41-
default: "webapp"
41+
default: "desktop-prepare"
4242
test:
4343
type: boolean
4444
required: false
@@ -73,20 +73,8 @@ jobs:
7373
# https://github.com/matrix-org/seshat/issues/135
7474
runs-on: ${{ inputs.runs-on || (inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04') }}
7575
env:
76-
HAK_DOCKER_IMAGE: ghcr.io/element-hq/element-web/desktop-build-env
76+
HAK_DOCKER_IMAGE: ghcr.io/element-hq/element-web/desktop-build-env:${{ case(github.event_name == 'push', inputs.ref || github.ref_name, github.event_name == 'release', 'staging', 'develop') }}
7777
steps:
78-
- name: Resolve docker image tag for push
79-
if: github.event_name == 'push'
80-
run: echo "HAK_DOCKER_IMAGE=$HAK_DOCKER_IMAGE:$REF" >> $GITHUB_ENV
81-
env:
82-
REF: ${{ inputs.ref || github.ref_name }}
83-
- name: Resolve docker image tag for release
84-
if: github.event_name == 'release'
85-
run: echo "HAK_DOCKER_IMAGE=$HAK_DOCKER_IMAGE:staging" >> $GITHUB_ENV
86-
- name: Resolve docker image tag for other triggers
87-
if: github.event_name != 'push' && github.event_name != 'release'
88-
run: echo "HAK_DOCKER_IMAGE=$HAK_DOCKER_IMAGE:develop" >> $GITHUB_ENV
89-
9078
- uses: nbucic/variable-mapper@0673f6891a0619ba7c002ecfed0f9f4f39017b6f
9179
id: config
9280
with:
@@ -95,11 +83,9 @@ jobs:
9583
map: |
9684
{
9785
"amd64": {
98-
"target": "x86_64-unknown-linux-gnu",
9986
"arch": "x86-64"
10087
},
10188
"arm64": {
102-
"target": "aarch64-unknown-linux-gnu",
10389
"arch": "aarch64",
10490
"build-args": "--arm64"
10591
}
@@ -120,7 +106,7 @@ jobs:
120106
id: cache
121107
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
122108
with:
123-
key: ${{ runner.os }}-${{ github.ref_name }}-${{ inputs.sqlcipher }}-${{ inputs.arch }}-${{ hashFiles('hakHash', 'electronVersion', 'dockerbuild/*') }}
109+
key: ${{ runner.os }}-${{ github.ref_name }}-${{ inputs.sqlcipher }}-${{ inputs.arch }}-${{ hashFiles('apps/desktop/hakHash', 'apps/desktop/electronVersion', 'apps/desktop/dockerbuild/*') }}
124110
path: |
125111
apps/desktop/.hak
126112
@@ -135,7 +121,7 @@ jobs:
135121

136122
- name: Install Deps
137123
working-directory: apps/desktop
138-
run: pnpm install --frozen-lockfile
124+
run: "pnpm install --frozen-lockfile --filter element-desktop"
139125

140126
- name: "Get modified files"
141127
id: changed_files

.github/workflows/build_desktop_macos.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ on:
3737
type: string
3838
required: false
3939
description: |
40-
The name of the prepare artifact to use, defaults to 'webapp'.
40+
The name of the prepare artifact to use, defaults to 'desktop-prepare'.
4141
The artifact must contain the following:
4242
+ webapp.asar - the asar archive of the webapp to embed in the desktop app
4343
+ electronVersion - the version of electron to use for cache keying
@@ -46,7 +46,7 @@ on:
4646
4747
The artifact can also contain any additional files which will be applied as overrides to the checkout root before building,
4848
for example icons in the `build/` directory to override the app icons.
49-
default: "webapp"
49+
default: "desktop-prepare"
5050
test:
5151
type: boolean
5252
required: false
@@ -92,7 +92,7 @@ jobs:
9292
id: cache
9393
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
9494
with:
95-
key: ${{ runner.os }}-${{ hashFiles('hakHash', 'electronVersion') }}
95+
key: ${{ runner.os }}-${{ hashFiles('apps/desktop/hakHash', 'apps/desktop/electronVersion') }}
9696
path: |
9797
apps/desktop/.hak
9898
@@ -121,7 +121,7 @@ jobs:
121121

122122
- name: Install Deps
123123
working-directory: apps/desktop
124-
run: "pnpm install --frozen-lockfile"
124+
run: "pnpm install --frozen-lockfile --filter element-desktop"
125125

126126
- name: Build Natives
127127
if: steps.cache.outputs.cache-hit != 'true'

0 commit comments

Comments
 (0)