Skip to content

Commit 1c55aa7

Browse files
authored
Improve workflows for better reusability (#2608)
1 parent 5dd1984 commit 1c55aa7

File tree

6 files changed

+193
-72
lines changed

6 files changed

+193
-72
lines changed

.github/workflows/build_linux.yaml

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,39 @@ on:
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.
4141
default: "webapp"
42+
test:
43+
type: boolean
44+
required: false
45+
default: true
46+
description: "Whether to run the test stage after building"
47+
test-args:
48+
type: string
49+
required: false
50+
description: "Additional arguments to pass to playwright"
51+
runs-on:
52+
type: string
53+
required: false
54+
description: "The runner image to use, normally set for you, may be needed for running in private repos."
55+
artifact-prefix:
56+
type: string
57+
required: false
58+
description: "An optional prefix to add to the artifact name, useful for distinguishing builds in private repos."
59+
default: ""
60+
targets:
61+
type: string
62+
required: false
63+
description: "List of targets to build"
64+
default: "tar.gz deb"
4265
env:
4366
SQLCIPHER_BUNDLED: ${{ inputs.sqlcipher == 'static' && '1' || '' }}
4467
MAX_GLIBC: 2.31 # bullseye-era glibc, used by glibc-check.sh
4568
permissions: {} # No permissions required
4669
jobs:
4770
build:
71+
name: Build Linux ${{ inputs.arch }} SQLCipher ${{ inputs.sqlcipher }}
4872
# We build on native infrastructure as matrix-seshat fails to cross-compile properly
4973
# https://github.com/matrix-org/seshat/issues/135
50-
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }}
74+
runs-on: ${{ inputs.runs-on || (inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04') }}
5175
env:
5276
HAK_DOCKER_IMAGE: ghcr.io/element-hq/element-desktop-dockerbuild
5377
steps:
@@ -109,7 +133,7 @@ jobs:
109133

110134
- name: "Get modified files"
111135
id: changed_files
112-
if: steps.cache.outputs.cache-hit != 'true' && github.event_name == 'pull_request'
136+
if: steps.cache.outputs.cache-hit != 'true' && github.event_name == 'pull_request' && github.repository == 'element-hq/element-desktop'
113137
uses: tj-actions/changed-files@823fcebdb31bb35fdf2229d9f769b400309430d0 # v46
114138
with:
115139
files: |
@@ -159,13 +183,11 @@ jobs:
159183
echo "USE_SYSTEM_FPM=true" >> $GITHUB_ENV
160184
161185
- name: Build App
162-
run: yarn build --publish never -l ${{ steps.config.outputs.build-args }}
186+
run: yarn build --publish never ${{ steps.config.outputs.build-args }} -l ${{ inputs.targets }}
163187
env:
164188
VARIANT_PATH: variant.json
165189
# Only set for Nightly builds
166190
VERSION: ${{ inputs.version }}
167-
FPM_DEBUG: true # TODO
168-
DEBUG: electron-builder # TODO
169191
# Workaround for https://github.com/electron-userland/electron-builder/issues/5721
170192
USE_HARD_LINKS: false
171193

@@ -199,39 +221,46 @@ jobs:
199221
- name: Upload Artifacts
200222
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
201223
with:
202-
name: linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }}
224+
name: ${{ inputs.artifact-prefix }}linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }}
203225
path: |
204226
dist
205227
!dist/*-unpacked/**
206228
retention-days: 1
207229

208-
- name: Assert all required files are present
230+
- name: Assert deb is present and valid
231+
if: contains(inputs.targets, 'deb')
209232
run: |
210233
test -f ./dist/element-desktop*$ARCH.deb
211-
test -f ./dist/element-desktop*.tar.gz
234+
235+
DEB_LISTING=$(dpkg-deb --fsys-tarfile ./dist/element-desktop*.deb | tar -tv)
236+
echo "deb listing: "
237+
echo "$DEB_LISTING"
238+
! echo "$DEB_LISTING" | grep '^h'
212239
env:
213240
ARCH: ${{ inputs.arch }}
214241

215-
- name: Assert no hardlinks are found
242+
- name: Assert tar.gz is present
243+
if: contains(inputs.targets, 'tar.gz')
216244
run: |
245+
test -f ./dist/element-desktop*.tar.gz
246+
217247
TAR_GZ_LISTING=$(tar -tvf ./dist/element-desktop*.tar.gz)
218248
echo "tar.gz listing: "
219249
echo "$TAR_GZ_LISTING"
220250
! echo "$TAR_GZ_LISTING" | grep '^h'
221251
222-
DEB_LISTING=$(dpkg-deb --fsys-tarfile ./dist/element-desktop*.deb | tar -tv)
223-
echo "deb listing: "
224-
echo "$DEB_LISTING"
225-
! echo "$DEB_LISTING" | grep '^h'
226-
227252
test:
253+
name: Test Linux ${{ inputs.arch }} SQLCipher ${{ inputs.sqlcipher }}
228254
needs: build
255+
if: inputs.test && contains(inputs.targets, 'deb')
229256
uses: ./.github/workflows/build_test.yaml
230257
with:
231-
artifact: linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }}
232-
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04' }}
258+
project: linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }}
259+
artifact: ${{ inputs.artifact-prefix }}linux-${{ inputs.arch }}-sqlcipher-${{ inputs.sqlcipher }}
260+
runs-on: ${{ inputs.runs-on || (inputs.arch == 'arm64' && 'ubuntu-22.04-arm' || 'ubuntu-22.04') }}
233261
executable: /opt/Element*/element-desktop*
234262
prepare_cmd: |
235263
sudo apt-get -qq update
236264
sudo apt install ./dist/*.deb
237265
blob_report: ${{ inputs.blob_report }}
266+
args: ${{ inputs.test-args }}

.github/workflows/build_macos.yaml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,29 @@ on:
4949
The artifact can also contain any additional files which will be applied as overrides to the checkout root before building,
5050
for example icons in the `build/` directory to override the app icons.
5151
default: "webapp"
52+
test:
53+
type: boolean
54+
required: false
55+
default: true
56+
description: "Whether to run the test stage after building"
57+
test-args:
58+
type: string
59+
required: false
60+
description: "Additional arguments to pass to playwright"
61+
artifact-prefix:
62+
type: string
63+
required: false
64+
description: "An optional prefix to add to the artifact name, useful for distinguishing builds in private repos."
65+
default: ""
66+
targets:
67+
type: string
68+
required: false
69+
description: "List of targets to build"
70+
default: "dmg zip"
5271
permissions: {} # No permissions required
5372
jobs:
5473
build:
74+
name: Build macOS Universal
5575
runs-on: macos-14 # M1
5676
environment: ${{ inputs.sign && 'packages.element.io' || '' }}
5777
steps:
@@ -105,7 +125,7 @@ jobs:
105125
- name: "[Signed] Build App"
106126
if: inputs.sign != ''
107127
run: |
108-
yarn build:universal --publish never
128+
yarn build:universal --publish never -m ${{ inputs.targets }}
109129
env:
110130
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
111131
APPLE_ID: ${{ secrets.APPLE_ID }}
@@ -127,7 +147,7 @@ jobs:
127147
- name: "[Unsigned] Build App"
128148
if: inputs.sign == ''
129149
run: |
130-
yarn build:universal --publish never
150+
yarn build:universal --publish never -m ${{ inputs.targets }}
131151
env:
132152
CSC_IDENTITY_AUTO_DISCOVERY: false
133153
VARIANT_PATH: variant.json
@@ -162,22 +182,30 @@ jobs:
162182
- name: Upload Artifacts
163183
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
164184
with:
165-
name: macos
185+
name: ${{ inputs.artifact-prefix }}macos
166186
path: |
167187
dist
168188
!dist/mac-universal/**
169189
retention-days: 1
170190

171-
- name: Assert all required files are present
191+
- name: Assert zip is present
192+
if: contains(inputs.targets, 'zip')
172193
run: |
173-
test -f ./dist/Element*.dmg
174194
test -f ./dist/Element*-mac.zip
175195
196+
- name: Assert dmg is present
197+
if: contains(inputs.targets, 'dmg')
198+
run: |
199+
test -f ./dist/Element*.dmg
200+
176201
test:
202+
name: Test macOS Universal
177203
needs: build
204+
if: inputs.test && contains(inputs.targets, 'dmg')
178205
uses: ./.github/workflows/build_test.yaml
179206
with:
180-
artifact: macos
207+
project: macos
208+
artifact: ${{ inputs.artifact-prefix }}macos
181209
runs-on: macos-14
182210
executable: /Users/runner/Applications/Element*.app/Contents/MacOS/Element*
183211
# We need to mount the DMG and copy the app to the Applications folder as a mounted DMG is
@@ -187,3 +215,4 @@ jobs:
187215
rsync -a /Volumes/Element/Element*.app ~/Applications/ &&
188216
hdiutil detach /Volumes/Element
189217
blob_report: ${{ inputs.blob_report }}
218+
args: ${{ inputs.test-args }}

.github/workflows/build_test.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
type: string
1111
required: true
1212
description: "The name of the artifact to download"
13+
project:
14+
type: string
15+
required: true
16+
description: "The Playwright project to use for testing"
1317
executable:
1418
type: string
1519
required: true
@@ -22,12 +26,19 @@ on:
2226
type: boolean
2327
default: false
2428
description: "Whether to upload a blob report instead of the HTML report"
29+
args:
30+
type: string
31+
required: false
32+
description: "Additional arguments to pass to playwright, for e.g. skipping specific tests"
2533
permissions: {}
2634
jobs:
2735
test:
36+
name: Test ${{ inputs.project }}
2837
runs-on: ${{ inputs.runs-on }}
2938
steps:
3039
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
40+
with:
41+
repository: ${{ github.repository == 'element-hq/element-web-pro' && 'element-hq/element-desktop' || github.repository }}
3142

3243
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
3344
with:
@@ -69,7 +80,7 @@ jobs:
6980
uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a
7081
timeout-minutes: 20
7182
with:
72-
run: yarn test --project=${{ inputs.artifact }} ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }} ${{ inputs.blob_report == false && '--reporter=html' || '' }}
83+
run: yarn test --project=${{ inputs.project }} ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }} ${{ inputs.blob_report == false && '--reporter=html' || '' }} ${{ inputs.args }}
7384
env:
7485
ELEMENT_DESKTOP_EXECUTABLE: ${{ steps.executable.outputs.path }}
7586

.github/workflows/build_windows.yaml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,33 @@ on:
5353
The artifact can also contain any additional files which will be applied as overrides to the checkout root before building,
5454
for example icons in the `build/` directory to override the app icons.
5555
default: "webapp"
56+
test:
57+
type: boolean
58+
required: false
59+
default: true
60+
description: "Whether to run the test stage after building"
61+
test-runs-on:
62+
type: string
63+
required: false
64+
description: "The runner image to use for testing, normally set for you, may be needed for running in private repos."
65+
test-args:
66+
type: string
67+
required: false
68+
description: "Additional arguments to pass to playwright"
69+
artifact-prefix:
70+
type: string
71+
required: false
72+
description: "An optional prefix to add to the artifact name, useful for distinguishing builds in private repos."
73+
default: ""
74+
targets:
75+
type: string
76+
required: false
77+
description: "List of targets to build"
78+
default: "squirrel msi"
5679
permissions: {} # No permissions required
5780
jobs:
5881
build:
82+
name: Build Windows ${{ inputs.arch }}
5983
runs-on: windows-2025
6084
environment: ${{ inputs.sign && 'packages.element.io' || '' }}
6185
env:
@@ -208,7 +232,7 @@ jobs:
208232
MASTER_KEY_FILE: C:\Users\runneradmin\eSignerCKA\master.key
209233

210234
- name: Build App
211-
run: yarn build --publish never -w ${{ steps.config.outputs.build-args }}
235+
run: yarn build --publish never ${{ steps.config.outputs.build-args }} -w ${{ inputs.targets }}
212236
env:
213237
VARIANT_PATH: variant.json
214238
# Only set for Nightly builds
@@ -236,24 +260,36 @@ jobs:
236260
- name: Upload Artifacts
237261
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
238262
with:
239-
name: win-${{ inputs.arch }}
263+
name: ${{ inputs.artifact-prefix }}win-${{ inputs.arch }}
240264
path: |
241265
dist
242266
retention-days: 1
243267

244-
- name: Assert all required files are present
268+
- name: Assert executable is present
245269
run: |
246270
Test-Path './dist/win-*unpacked/Element*.exe'
271+
272+
- name: Assert all Squirrel files are present
273+
if: contains(inputs.targets, 'squirrel')
274+
run: |
247275
Test-Path './dist/squirrel-windows*/Element Setup*.exe'
248276
Test-Path './dist/squirrel-windows*/element-desktop-*-full.nupkg'
249277
Test-Path './dist/squirrel-windows*/RELEASES'
278+
279+
- name: Assert MSI is present
280+
if: contains(inputs.targets, 'msi')
281+
run: |
250282
Test-Path './dist/Element*.msi'
251283
252284
test:
285+
name: Test Windows ${{ inputs.arch }}
253286
needs: build
287+
if: inputs.test
254288
uses: ./.github/workflows/build_test.yaml
255289
with:
256-
artifact: win-${{ inputs.arch }}
257-
runs-on: ${{ inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
290+
project: win-${{ inputs.arch }}
291+
artifact: ${{ inputs.artifact-prefix }}win-${{ inputs.arch }}
292+
runs-on: ${{ inputs.test-runs-on || (inputs.arch == 'arm64' && 'windows-11-arm' || 'windows-2022') }}
258293
executable: ./dist/win*-unpacked/Element*.exe
259294
blob_report: ${{ inputs.blob_report }}
295+
args: ${{ inputs.test-args }}

electron-builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const config: Omit<Writable<Configuration>, "electronFuses"> & {
151151
fpm: ["--deb-pre-depends", "libc6 (>= 2.31)"],
152152
},
153153
mac: {
154+
target: ["dmg", "zip"],
154155
category: "public.app-category.social-networking",
155156
darkModeSupport: true,
156157
hardenedRuntime: true,

0 commit comments

Comments
 (0)