Skip to content

Commit 0e994db

Browse files
committed
👷 On-demand CI custom build using
Make it possible to trigger a build from the CI on demand. TODO: - still work in progress - the idea is to make it possible to chose requirements e.g. python3,ffmpeg,av and arch e.g. x86_64: setup.py apk --sdk-dir /home/user/.android/android-sdk --ndk-dir /home/user/.android/android-ndk --requirements python3,ffmpeg,av --arch=x86_64 - maybe add both Ubuntu and macOS support as well as configurable Python version - also introduced changes to Makefile and docker.yml, to be tested and split to another PR
1 parent 08713b3 commit 0e994db

File tree

5 files changed

+284
-11
lines changed

5 files changed

+284
-11
lines changed

.github/workflows/custom-build.yml

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: Custom build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
# TODO
8+
APK_ARTIFACT_FILENAME: bdist_custom_build-debug-1.1.apk
9+
AAB_ARTIFACT_FILENAME: bdist_custom_build-release-1.1.aab
10+
AAR_ARTIFACT_FILENAME: bdist_custom_build-release-1.1.aar
11+
# TODO: needed?
12+
PYTHONFORANDROID_PREREQUISITES_INSTALL_INTERACTIVE: 0
13+
14+
jobs:
15+
16+
# TODO
17+
# flake8:
18+
# name: Flake8 tests
19+
# runs-on: ubuntu-latest
20+
# steps:
21+
# - name: Checkout python-for-android
22+
# uses: actions/checkout@v4
23+
# - name: Set up Python 3.x
24+
# uses: actions/setup-python@v5
25+
# with:
26+
# python-version: 3.x
27+
28+
# TODO
29+
# test:
30+
# name: Pytest [Python ${{ matrix.python-version }} | ${{ matrix.os }}]
31+
# needs: flake8
32+
# runs-on: ${{ matrix.os }}
33+
# strategy:
34+
# matrix:
35+
# python-version: ['3.11']
36+
# os: [ubuntu-latest]
37+
# steps:
38+
# - name: Checkout python-for-android
39+
# uses: actions/checkout@v4
40+
# - name: Set up Python ${{ matrix.python-version }}
41+
# uses: actions/setup-python@v4
42+
# with:
43+
# python-version: ${{ matrix.python-version }}
44+
# - name: Tox tests
45+
# run: |
46+
# python -m pip install --upgrade pip
47+
# pip install tox>=2.0
48+
# make test
49+
# - name: Coveralls
50+
# uses: AndreMiras/coveralls-python-action@develop
51+
# if: ${{ matrix.os == 'ubuntu-latest' }}
52+
# with:
53+
# parallel: true
54+
# flag-name: run-${{ matrix.os }}-${{ matrix.python-version }}
55+
56+
ubuntu_build:
57+
name: Build test APP [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
58+
needs: [flake8]
59+
runs-on: ${{ matrix.runs_on }}
60+
continue-on-error: true
61+
strategy:
62+
matrix:
63+
runs_on: [ubuntu-latest]
64+
# TODO
65+
bootstrap:
66+
- name: sdl2
67+
target: testapps-with-numpy
68+
- name: sdl2_scipy
69+
target: testapps-with-scipy
70+
- name: webview
71+
target: testapps-webview
72+
- name: service_library
73+
target: testapps-service_library-aar
74+
- name: qt
75+
target: testapps-qt
76+
steps:
77+
- name: Checkout python-for-android
78+
uses: actions/checkout@v4
79+
# TODO: later we would pull from Docker hub
80+
- name: Build python-for-android docker image
81+
run: |
82+
docker build --tag=kivy/python-for-android .
83+
- name: Build multi-arch ${{ matrix.bootstrap.target }} artifact with docker
84+
run: |
85+
docker run --name p4a-latest kivy/python-for-android make ${{ matrix.bootstrap.target }}
86+
- name: Copy produced artifacts from docker container (*.apk, *.aab)
87+
if: matrix.bootstrap.name != 'service_library'
88+
run: |
89+
mkdir -p dist
90+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.APK_ARTIFACT_FILENAME }} dist/
91+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.AAB_ARTIFACT_FILENAME }} dist/
92+
- name: Copy produced artifacts from docker container (*.aar)
93+
if: matrix.bootstrap.name == 'service_library'
94+
run: |
95+
mkdir -p dist
96+
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/${{ env.AAR_ARTIFACT_FILENAME }} dist/
97+
- name: Rename artifacts to include the build platform name (*.apk, *.aab, *.aar)
98+
run: |
99+
if [ -f dist/${{ env.APK_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.APK_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}; fi
100+
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
101+
if [ -f dist/${{ env.AAR_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAR_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAR_ARTIFACT_FILENAME }}; fi
102+
- name: Upload artifacts
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
106+
path: dist
107+
108+
# TODO: should we support both
109+
macos_build:
110+
name: Build test APP [ ${{ matrix.runs_on }} | ${{ matrix.bootstrap.name }} ]
111+
needs: [flake8]
112+
runs-on: ${{ matrix.runs_on }}
113+
continue-on-error: true
114+
strategy:
115+
matrix:
116+
# macos-latest (ATM macos-14) runs on Apple Silicon,
117+
# macos-13 runs on Intel
118+
runs_on: ['macos-latest', 'macos-13']
119+
bootstrap:
120+
- name: sdl2
121+
target: testapps-with-numpy
122+
- name: webview
123+
target: testapps-webview
124+
env:
125+
ANDROID_HOME: ${HOME}/.android
126+
ANDROID_SDK_ROOT: ${HOME}/.android/android-sdk
127+
ANDROID_SDK_HOME: ${HOME}/.android/android-sdk
128+
ANDROID_NDK_HOME: ${HOME}/.android/android-ndk
129+
steps:
130+
- name: Checkout python-for-android
131+
uses: actions/checkout@v4
132+
- name: Set up Python 3.x
133+
uses: actions/setup-python@v5
134+
with:
135+
python-version: 3.x
136+
- name: Install python-for-android
137+
run: |
138+
python3 -m pip install -e .
139+
- name: Install prerequisites via pythonforandroid/prerequisites.py (Experimental)
140+
run: |
141+
python3 pythonforandroid/prerequisites.py
142+
- name: Install dependencies (Legacy)
143+
run: |
144+
make --file ci/makefiles/osx.mk
145+
- name: Build multi-arch apk Python 3 (armeabi-v7a, arm64-v8a, x86_64, x86)
146+
run: |
147+
make ${{ matrix.bootstrap.target }}
148+
- name: Copy produced artifacts into dist/ (*.apk, *.aab)
149+
run: |
150+
mkdir -p dist
151+
cp testapps/on_device_unit_tests/*.apk dist/
152+
cp testapps/on_device_unit_tests/*.aab dist/
153+
ls -l dist/
154+
- name: Rename artifacts to include the build platform name (*.apk, *.aab)
155+
run: |
156+
if [ -f dist/${{ env.APK_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.APK_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.APK_ARTIFACT_FILENAME }}; fi
157+
if [ -f dist/${{ env.AAB_ARTIFACT_FILENAME }} ]; then mv dist/${{ env.AAB_ARTIFACT_FILENAME }} dist/${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-${{ env.AAB_ARTIFACT_FILENAME }}; fi
158+
- name: Upload artifacts
159+
uses: actions/upload-artifact@v3
160+
with:
161+
name: ${{ matrix.runs_on }}-${{ matrix.bootstrap.name }}-artifacts
162+
path: dist
163+
164+
ubuntu_rebuild_updated_recipes:
165+
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ubuntu-latest ]
166+
needs: [flake8]
167+
runs-on: ubuntu-latest
168+
continue-on-error: true
169+
strategy:
170+
matrix:
171+
android_arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
172+
env:
173+
REBUILD_UPDATED_RECIPES_EXTRA_ARGS: --arch=${{ matrix.android_arch }}
174+
steps:
175+
- name: Checkout python-for-android (all-history)
176+
uses: actions/checkout@v4
177+
with:
178+
fetch-depth: 0
179+
# helps with GitHub runner getting out of space
180+
- name: Free disk space
181+
run: |
182+
df -h
183+
sudo swapoff -a
184+
sudo rm -f /swapfile
185+
sudo apt -y clean
186+
docker rmi $(docker image ls -aq)
187+
df -h
188+
- name: Pull docker image
189+
run: |
190+
make docker/pull
191+
- name: Rebuild updated recipes
192+
run: |
193+
make docker/run/make/rebuild_updated_recipes
194+
195+
macos_rebuild_updated_recipes:
196+
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ${{ matrix.runs_on }} ]
197+
needs: [flake8]
198+
runs-on: ${{ matrix.runs_on }}
199+
continue-on-error: true
200+
strategy:
201+
matrix:
202+
android_arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
203+
# macos-latest (ATM macos-14) runs on Apple Silicon,
204+
# macos-13 runs on Intel
205+
runs_on: ['macos-latest', 'macos-13']
206+
env:
207+
ANDROID_HOME: ${HOME}/.android
208+
ANDROID_SDK_ROOT: ${HOME}/.android/android-sdk
209+
ANDROID_SDK_HOME: ${HOME}/.android/android-sdk
210+
ANDROID_NDK_HOME: ${HOME}/.android/android-ndk
211+
REBUILD_UPDATED_RECIPES_EXTRA_ARGS: --arch=${{ matrix.android_arch }}
212+
steps:
213+
- name: Checkout python-for-android (all-history)
214+
uses: actions/checkout@v4
215+
with:
216+
fetch-depth: 0
217+
- name: Set up Python 3.x
218+
uses: actions/setup-python@v5
219+
with:
220+
python-version: 3.x
221+
- name: Install python-for-android
222+
run: |
223+
python3 -m pip install -e .
224+
- name: Install prerequisites via pythonforandroid/prerequisites.py (Experimental)
225+
run: |
226+
python3 pythonforandroid/prerequisites.py
227+
- name: Install dependencies (Legacy)
228+
run: |
229+
make --file ci/makefiles/osx.mk
230+
- name: Rebuild updated recipes
231+
run: |
232+
make rebuild_updated_recipes
233+
234+
coveralls_finish:
235+
needs: test
236+
runs-on: ubuntu-latest
237+
steps:
238+
- name: Coveralls Finished
239+
uses: AndreMiras/coveralls-python-action@develop
240+
with:
241+
parallel-finished: true
242+
243+
documentation:
244+
runs-on: ubuntu-latest
245+
steps:
246+
- uses: actions/checkout@v4
247+
- name: Requirements
248+
run: |
249+
python -m pip install --upgrade pip
250+
pip install -r doc/requirements.txt
251+
- name: Check links
252+
run: sphinx-build -b linkcheck doc/source doc/build
253+
- name: Generate documentation
254+
run: sphinx-build doc/source doc/build
255+
256+

.github/workflows/docker.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- develop
8+
tags:
9+
- "*"
810
pull_request:
911

1012
jobs:
@@ -14,11 +16,20 @@ jobs:
1416
- uses: actions/checkout@v4
1517
- uses: docker/setup-buildx-action@v3
1618
- run: make docker/build
19+
- name: docker login
20+
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/')
1721
env:
1822
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
1923
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
24+
run: make docker/login
2025
- name: docker push
21-
if: github.ref == 'develop'
26+
if: github.ref == 'refs/heads/develop'
27+
# TODO
28+
# run: make docker/push
29+
run: echo make docker/push
30+
- name: docker push (tag)
31+
if: startsWith(github.ref, 'refs/tags/')
2232
run: |
23-
make docker/login
24-
make docker/push
33+
make docker/tag DOCKER_TAG=${GITHUB_REF#refs/tags/}
34+
# TODO: debugging
35+
# make docker/push

.github/workflows/push.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Unit tests & build apps
22

3-
on: ['push', 'pull_request']
3+
# TODO
4+
# on: ['push', 'pull_request']
5+
on: ['pull_request']
46

57
env:
68
APK_ARTIFACT_FILENAME: bdist_unit_tests_app-debug-1.1.apk
@@ -17,7 +19,7 @@ jobs:
1719
- name: Checkout python-for-android
1820
uses: actions/checkout@v4
1921
- name: Set up Python 3.x
20-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2123
with:
2224
python-version: 3.x
2325
- name: Run flake8
@@ -38,7 +40,7 @@ jobs:
3840
- name: Checkout python-for-android
3941
uses: actions/checkout@v4
4042
- name: Set up Python ${{ matrix.python-version }}
41-
uses: actions/setup-python@v4
43+
uses: actions/setup-python@v5
4244
with:
4345
python-version: ${{ matrix.python-version }}
4446
- name: Tox tests

.github/workflows/pypi-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ jobs:
55
pypi_release:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v3
8+
- uses: actions/checkout@v4
99
- name: Set up Python 3.x
10-
uses: actions/setup-python@v4
10+
uses: actions/setup-python@v5
1111
with:
1212
python-version: '3.x'
1313
- name: Install dependencies
@@ -22,4 +22,4 @@ jobs:
2222
uses: pypa/gh-action-pypi-publish@v1.4.2
2323
with:
2424
user: __token__
25-
password: ${{ secrets.pypi_password }}
25+
password: ${{ secrets.pypi_password }}

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ TOX=`which tox`
44
ACTIVATE=$(VIRTUAL_ENV)/bin/activate
55
PYTHON=$(VIRTUAL_ENV)/bin/python
66
DOCKER_IMAGE=kivy/python-for-android
7+
DOCKER_TAG=latest
78
ANDROID_SDK_HOME ?= $(HOME)/.android/android-sdk
89
ANDROID_NDK_HOME ?= $(HOME)/.android/android-ndk
910
ANDROID_NDK_HOME_LEGACY ?= $(HOME)/.android/android-ndk-legacy
@@ -118,10 +119,13 @@ docker/build:
118119
docker build --cache-from=$(DOCKER_IMAGE) --tag=$(DOCKER_IMAGE) .
119120

120121
docker/login:
121-
@echo $(DOCKERHUB_TOKEN) | docker login --username $(DOCKERHUB_USERNAME) --password-stdin
122+
@echo $$DOCKERHUB_TOKEN | docker login --username $(DOCKERHUB_USERNAME) --password-stdin
123+
124+
docker/tag:
125+
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(DOCKER_TAG)
122126

123127
docker/push:
124-
docker push $(DOCKER_IMAGE)
128+
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
125129

126130
docker/run/test: docker/build
127131
docker run --rm --env-file=.env $(DOCKER_IMAGE) 'make test'

0 commit comments

Comments
 (0)