Skip to content

Commit 5dfad3f

Browse files
authored
Improves iOS CI workflow and adds Apple Silicon M1 runner (#1393)
1 parent 04f5d00 commit 5dfad3f

File tree

4 files changed

+71
-19
lines changed

4 files changed

+71
-19
lines changed

.ci/osx_ci.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
arm64_set_path_and_python_version(){
5+
python_version="$1"
6+
if [[ $(/usr/bin/arch) = arm64 ]]; then
7+
export PATH=/opt/homebrew/bin:$PATH
8+
eval "$(pyenv init --path)"
9+
pyenv install $python_version -s
10+
pyenv global $python_version
11+
export PATH=$(pyenv prefix)/bin:$PATH
12+
fi
13+
}

.github/workflows/ios.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,51 @@ on: [push, pull_request]
22
name: iOS
33
jobs:
44
Integration:
5-
runs-on: macOS-latest
5+
name: "Integration (${{ matrix.runs_on }}, ${{ matrix.python }})"
6+
defaults:
7+
run:
8+
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
9+
runs-on: ${{ matrix.runs_on || 'macos-latest' }}
10+
strategy:
11+
matrix:
12+
include:
13+
- runs_on: macos-latest
14+
python: '3.9'
15+
- runs_on: apple-silicon-m1
16+
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
17+
python: '3.9.7'
618
steps:
719
- name: Setup python
20+
# Needs to be skipped on our self-hosted runners tagged as 'apple-silicon-m1'
21+
if: ${{ matrix.runs_on != 'apple-silicon-m1' }}
822
uses: actions/setup-python@v2
923
with:
10-
python-version: 3.8
24+
python-version: ${{ matrix.python }}
1125
- uses: actions/checkout@v2
1226
- name: Setup environment
1327
run: |
28+
source .ci/osx_ci.sh
29+
arm64_set_path_and_python_version ${{ matrix.python }}
1430
pip install -e .
1531
pip install Cython cookiecutter pbxproj
16-
- run: buildozer --help
17-
- run: buildozer init
32+
- name: Check buildozer installation
33+
run: |
34+
source .ci/osx_ci.sh
35+
arm64_set_path_and_python_version ${{ matrix.python }}
36+
buildozer --help
37+
- name: Initialize buildozer in project folder
38+
run: |
39+
source .ci/osx_ci.sh
40+
arm64_set_path_and_python_version ${{ matrix.python }}
41+
buildozer init
1842
- name: Install dependencies
1943
run: |
44+
source .ci/osx_ci.sh
45+
arm64_set_path_and_python_version ${{ matrix.python }}
2046
brew install autoconf automake libtool pkg-config
2147
- name: buildozer ios debug
2248
run: |
49+
source .ci/osx_ci.sh
50+
arm64_set_path_and_python_version ${{ matrix.python }}
2351
touch main.py
2452
buildozer ios debug

buildozer/targets/ios.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,6 @@ def build_package(self):
258258
app_lower=app_name.lower(), mode=mode)
259259
self.buildozer.state['ios:latestappdir'] = ios_app_dir
260260

261-
key = 'ios.codesign.{}'.format(self.build_mode)
262-
ioscodesign = self.buildozer.config.getdefault('app', key, '')
263-
if not ioscodesign:
264-
self.buildozer.error('Cannot create the IPA package without'
265-
' signature. You must fill the "{}" token.'.format(key))
266-
return
267-
elif ioscodesign[0] not in ('"', "'"):
268-
ioscodesign = '"{}"'.format(ioscodesign)
269-
270261
intermediate_dir = join(self.ios_dir, '{}-{}.intermediates'.format(app_name, version))
271262
xcarchive = join(intermediate_dir, '{}-{}.xcarchive'.format(
272263
app_name, version))
@@ -286,9 +277,19 @@ def build_package(self):
286277
'-destination \'generic/platform=iOS\'',
287278
'archive',
288279
'ENABLE_BITCODE=NO',
280+
self.code_signing_allowed,
289281
self.code_signing_development_team,
290282
cwd=build_dir)
291283

284+
key = 'ios.codesign.{}'.format(self.build_mode)
285+
ioscodesign = self.buildozer.config.getdefault('app', key, '')
286+
if not ioscodesign:
287+
self.buildozer.error('Cannot create the IPA package without'
288+
' signature. You must fill the "{}" token.'.format(key))
289+
return
290+
elif ioscodesign[0] not in ('"', "'"):
291+
ioscodesign = '"{}"'.format(ioscodesign)
292+
292293
self.buildozer.info('Creating IPA...')
293294
self.xcodebuild(
294295
'-exportArchive',

tests/targets/test_ios.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_unlock_keychain_wrong_password(self):
176176
]
177177

178178
def test_build_package_no_signature(self):
179-
"""Code signing is currently required to go through final `xcodebuild` steps."""
179+
"""Code signing is currently required to go through final `xcodebuild` step."""
180180
target = init_target(self.temp_dir)
181181
target.ios_dir = "/ios/dir"
182182
# fmt: off
@@ -208,8 +208,18 @@ def test_build_package_no_signature(self):
208208
"/ios/dir/myapp-ios/myapp-Info.plist",
209209
)
210210
]
211-
assert m_cmd.call_args_list == [mock.call(mock.ANY, cwd=target.ios_dir), mock.call(
212-
"xcodebuild -configuration Debug -allowProvisioningUpdates ENABLE_BITCODE=NO "
213-
"CODE_SIGNING_ALLOWED=NO clean build",
214-
cwd="/ios/dir/myapp-ios",
215-
)]
211+
assert m_cmd.call_args_list == [
212+
mock.call(mock.ANY, cwd=target.ios_dir),
213+
mock.call(
214+
"xcodebuild -configuration Debug -allowProvisioningUpdates ENABLE_BITCODE=NO "
215+
"CODE_SIGNING_ALLOWED=NO clean build",
216+
cwd="/ios/dir/myapp-ios",
217+
),
218+
mock.call(
219+
"xcodebuild -alltargets -configuration Debug -scheme myapp "
220+
"-archivePath \"/ios/dir/myapp-0.1.intermediates/myapp-0.1.xcarchive\" "
221+
"-destination \'generic/platform=iOS\' "
222+
"archive ENABLE_BITCODE=NO CODE_SIGNING_ALLOWED=NO",
223+
cwd="/ios/dir/myapp-ios",
224+
),
225+
]

0 commit comments

Comments
 (0)