forked from beeware/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
315 lines (278 loc) · 12.8 KB
/
app-build-verify.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: Build App
#######
# Verify building an app for a target platform, format, and framework on a particular OS.
# If a platform and format are not specified, then an app is built for each platform and format supported on the OS.
#######
on:
workflow_call:
inputs:
python-version:
description: "Python version to use; defaults to latest Python release."
default: "3.X"
type: string
runner-os:
description: "The OS to use to build the App; must be a fully qualified GitHub runner OS, e.g. ubuntu-latest."
required: true
type: string
framework:
description: "Framework to use to build the App, e.g. toga."
required: true
type: string
repository:
description: "GitHub repository to checkout; defaults to repo running this workflow."
default: ${{ github.repository }}
type: string
target-platform:
description: "The target platform for the app, i.e. linux, macos, or windows. Leave blank all supported platforms."
default: ""
type: string
target-format:
description: "The target format for the app, e.g. appimage, xcode, app, etc. Leave blank all supported formats."
default: ""
type: string
briefcase-template-source:
description: "Path to use for --template for `briefcase new` to create app."
default: ""
type: string
defaults:
run:
shell: bash
env:
FORCE_COLOR: "1"
jobs:
verify-app:
name: Verify App Build
runs-on: ${{ inputs.runner-os }}
steps:
- name: Checkout ${{ inputs.repository }}
uses: actions/checkout@v4.1.1
with:
repository: ${{ inputs.repository }}
fetch-depth: 0
- name: Checkout beeware/.github
uses: actions/checkout@v4.1.1
with:
repository: "beeware/.github"
path: "beeware-.github"
- name: Package name
id: package
run: echo "name=$(basename '${{ inputs.repository }}')" >> ${GITHUB_OUTPUT}
- name: Determine Cache Directories
id: dirs
run: |
echo "cookiecutters-data-dir=~/.cookiecutters" >> ${GITHUB_OUTPUT}
if [[ "${{ startsWith(inputs.runner-os, 'ubuntu') }}" == "true" ]]; then
echo "briefcase-data-dir=~/.cache/briefcase" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/.cache/pip" >> ${GITHUB_OUTPUT}
elif [[ "${{ startsWith(inputs.runner-os, 'macos') }}" == "true" ]]; then
echo "briefcase-data-dir=~/Library/Caches/org.beeware.briefcase" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/Library/Caches/pip" >> ${GITHUB_OUTPUT}
echo "docker-cache-dir=~/Library/Containers/com.docker.docker/Data/vms/0/" >> ${GITHUB_OUTPUT}
elif [[ "${{ startsWith(inputs.runner-os, 'windows') }}" == "true" ]]; then
echo "briefcase-data-dir=~/AppData/Local/BeeWare/briefcase/Cache" >> ${GITHUB_OUTPUT}
echo "pip-cache-dir=~/AppData/Local/pip/Cache" >> ${GITHUB_OUTPUT}
echo "docker-cache-dir=C:/ProgramData/DockerDesktop" >> ${GITHUB_OUTPUT}
fi
- name: Cache Briefcase tools
uses: actions/cache@v3.3.2
with:
key: briefcase-${{ runner.os }}-${{ inputs.repository }}-${{ inputs.framework }}-${{ inputs.target-platform }}-${{ inputs.target-format }}
path: |
${{ steps.dirs.outputs.cookiecutters-data-dir }}
${{ steps.dirs.outputs.briefcase-data-dir }}
${{ steps.dirs.outputs.pip-cache-dir }}
${{ steps.dirs.outputs.docker-cache-dir }}
- name: Determine system python3 version
id: system-python
run: |
echo "python-version=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
echo "python-version=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')" >> ${GITHUB_OUTPUT}
- name: Set up Python
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ inputs.python-version }}
- name: Get packages
# Briefcase will build and package itself in a previous step in its CI.
if: endsWith(inputs.repository, 'briefcase')
uses: actions/download-artifact@v3.0.2
with:
name: packages-${{ steps.package.outputs.name }}
path: dist
- name: Install Briefcase artifact
if: endsWith(inputs.repository, 'briefcase')
run: python -m pip install dist/briefcase-*.whl
- name: Install Briefcase
if: ${{ !endsWith(inputs.repository, 'briefcase') }}
uses: ./beeware-.github/.github/actions/install-briefcase
- name: Create Briefcase project
# Don't run for template repos since they already contain a created app.
if: ${{ !endsWith(inputs.repository, '-template') || inputs.repository == 'beeware/briefcase-template' }}
run: |
if [[ "${{ inputs.briefcase-template-source }}" != "" ]]; then
TEMPLATE=$(printf -- "--template %q" "${{ inputs.briefcase-template-source }}")
fi
cd tests/apps
cat verify-${{ inputs.framework }}.config | briefcase new ${TEMPLATE}
# In the steps below, using the builtin functions for comparison (instead of ==)
# allows for case-insensitivity to the inputs for the workflow.
- name: Build macOS app
if: >
startsWith(inputs.runner-os, 'macOS')
&& contains(fromJSON('["", "macOS"]'), inputs.target-platform)
&& contains(fromJSON('["", "app"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create macOS app
briefcase build macOS app
briefcase package macOS app --adhoc-sign
- name: Build macOS Xcode project
if: >
startsWith(inputs.runner-os, 'macOS')
&& contains(fromJSON('["", "macOS"]'), inputs.target-platform)
&& contains(fromJSON('["", "Xcode"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create macOS Xcode
briefcase build macOS Xcode
briefcase package macOS Xcode --adhoc-sign
- name: Build Windows app
if: >
startsWith(inputs.runner-os, 'Windows')
&& contains(fromJSON('["", "Windows"]'), inputs.target-platform)
&& contains(fromJSON('["", "app"]'), inputs.target-format)
run: |
unset WIX # force Briefcase to install and use its own version of WiX
cd tests/apps/verify-${{ inputs.framework }}
briefcase create windows app
briefcase build windows app
briefcase package windows app --adhoc-sign
- name: Build Windows Visual Studio project
if: >
startsWith(inputs.runner-os, 'Windows')
&& contains(fromJSON('["", "Windows"]'), inputs.target-platform)
&& contains(fromJSON('["", "VisualStudio"]'), inputs.target-format)
run: |
unset WIX # force Briefcase to install and use its own version of WiX
cd tests/apps/verify-${{ inputs.framework }}
briefcase create windows VisualStudio
briefcase build windows VisualStudio
briefcase package windows VisualStudio --adhoc-sign
- name: Build Linux System project (Ubuntu, local)
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& startsWith(inputs.python-version, steps.system-python.outputs.python-version)
&& contains(fromJSON('["", "Linux"]'), inputs.target-platform)
&& contains(fromJSON('["", "system"]'), inputs.target-format)
run: |
sudo apt-get update -y && sudo apt-get install -y python3-dev python3-pip libcairo2-dev libgirepository1.0-dev
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux system
briefcase build linux system
briefcase package linux system --adhoc-sign
- name: Build Linux System project (Debian, Dockerized)
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& contains(fromJSON('["", "Linux"]'), inputs.target-platform)
&& contains(fromJSON('["", "system"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux system --target debian:bullseye
briefcase build linux system --target debian:bullseye
briefcase package linux system --target debian:bullseye --adhoc-sign
- name: Build Linux System project (RPM, Dockerized)
# fedora:37 ships with Python 3.11 and PySide2 cannot be installed
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& !contains(fromJSON('["PySide2"]'), inputs.framework)
&& contains(fromJSON('["", "Linux"]'), inputs.target-platform)
&& contains(fromJSON('["", "system"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux system --target fedora:37
briefcase build linux system --target fedora:37
briefcase package linux system --target fedora:37 --adhoc-sign
- name: Build Linux System project (Arch, Dockerized)
# arch started shipping Python 3.11 on 3 may 2023 and PySide2 cannot be installed
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& !contains(fromJSON('["PySide2"]'), inputs.framework)
&& contains(fromJSON('["", "Linux"]'), inputs.target-platform)
&& contains(fromJSON('["", "system"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux system --target archlinux:latest
briefcase build linux system --target archlinux:latest
briefcase package linux system --target archlinux:latest --adhoc-sign
# 2023-09-11 AppImage dropped to "best effort" support.
#
# AppImage builds are the slowest, because they're incompatible with binary wheels;
# and installing Linux GUI toolkits (which are on a constant "install the latest"
# push) is fundamentally incompatible with using an old base image. As of today,
# it's impossible to install Toga on *any* manylinux image (
# https://gitlab.gnome.org/GNOME/pygobject/-/issues/590); PySide2 can't be
# installed on any *supported* manylinux image, and PySide6 only works on 2_28.
# Even when the install *does* work, there are so many incompatibility and
# binary dependency issues that it's just not worth the oxygen to keep this thing
# alive.
#
# Only runs when target platform and format are explicitly Linux and AppImage.
- name: Build AppImage project
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& contains(fromJSON('["Linux"]'), inputs.target-platform)
&& contains(fromJSON('["AppImage"]'), inputs.target-format)
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux AppImage
briefcase build linux AppImage
briefcase package linux AppImage --adhoc-sign
- name: Build Flatpak project
if: >
startsWith(inputs.runner-os, 'ubuntu')
&& contains(fromJSON('["", "Linux"]'), inputs.target-platform)
&& contains(fromJSON('["", "Flatpak"]'), inputs.target-format)
&& contains(fromJSON('["Toga", "PyGame"]'), inputs.framework)
run: |
sudo apt-get update -y
sudo apt-get install -y flatpak flatpak-builder
cd tests/apps/verify-${{ inputs.framework }}
briefcase create linux flatpak
briefcase build linux flatpak
briefcase package linux flatpak --adhoc-sign
- name: Build Android App
if: >
contains(fromJSON('["", "Android"]'), inputs.target-platform)
&& contains(fromJSON('["", "Gradle"]'), inputs.target-format)
&& startsWith(inputs.framework, 'toga')
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create android gradle
briefcase build android gradle
briefcase package android gradle --adhoc-sign
- name: Build iOS App
if: >
startsWith(inputs.runner-os, 'macOS')
&& contains(fromJSON('["", "iOS"]'), inputs.target-platform)
&& contains(fromJSON('["", "Xcode"]'), inputs.target-format)
&& startsWith(inputs.framework, 'toga')
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create iOS xcode
briefcase build iOS xcode
briefcase package iOS xcode --adhoc-sign
- name: Build Web App
if: >
contains(fromJSON('["", "web"]'), inputs.target-platform)
&& contains(fromJSON('["", "static"]'), inputs.target-format)
&& startsWith(inputs.framework, 'toga')
run: |
cd tests/apps/verify-${{ inputs.framework }}
briefcase create web static
briefcase build web static
briefcase package web static
- name: Upload failure logs
uses: actions/upload-artifact@v3.1.3
if: failure()
with:
name: build-failure-logs-${{ inputs.framework }}-${{ inputs.python-version }}-${{ inputs.target-platform }}-${{ inputs.target-format }}
path: tests/apps/verify-${{ inputs.framework }}/logs/*