Skip to content

*_rebuild_updated_recipes CI jobs now test the updated recipe along all the supported Android archs (arm64-v8a, armeabi-v7a, x86_64, x86) #2592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,15 @@ jobs:
path: ${{ matrix.runs_on }}-${{ env.AAB_ARTIFACT_FILENAME }}

ubuntu_rebuild_updated_recipes:
name: Test updated recipes [ ubuntu-latest ]
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ubuntu-latest ]
needs: [flake8]
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
android_arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
env:
REBUILD_UPDATED_RECIPES_EXTRA_ARGS: --arch=${{ matrix.android_arch }}
steps:
- name: Checkout python-for-android
uses: actions/checkout@v2
Expand All @@ -227,23 +233,26 @@ jobs:
make docker/run/make/rebuild_updated_recipes

macos_rebuild_updated_recipes:
name: Test updated recipes [ ${{ matrix.runs_on }} ]
name: Test updated recipes for arch ${{ matrix.android_arch }} [ ${{ matrix.runs_on }} ]
needs: [flake8]
defaults:
run:
shell: ${{ matrix.run_wrapper || 'bash --noprofile --norc -eo pipefail {0}' }}
runs-on: ${{ matrix.runs_on }}
continue-on-error: true
strategy:
matrix:
android_arch: ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
runs_on: [macos-latest, apple-silicon-m1]
include:
- runs_on: macos-latest
- runs_on: apple-silicon-m1
run_wrapper: arch -arm64 bash --noprofile --norc -eo pipefail {0}
env:
ANDROID_HOME: ${HOME}/.android
ANDROID_SDK_ROOT: ${HOME}/.android/android-sdk
ANDROID_SDK_HOME: ${HOME}/.android/android-sdk
ANDROID_NDK_HOME: ${HOME}/.android/android-ndk
REBUILD_UPDATED_RECIPES_EXTRA_ARGS: --arch=${{ matrix.android_arch }}
steps:
- name: Checkout python-for-android
uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PYTHON_WITH_VERSION=python$(PYTHON_VERSION)
DOCKER_IMAGE=kivy/python-for-android
ANDROID_SDK_HOME ?= $(HOME)/.android/android-sdk
ANDROID_NDK_HOME ?= $(HOME)/.android/android-ndk
REBUILD_UPDATED_RECIPES_EXTRA_ARGS ?= ''


all: virtualenv
Expand All @@ -32,7 +33,7 @@ test:
rebuild_updated_recipes: virtualenv
. $(ACTIVATE) && \
ANDROID_SDK_HOME=$(ANDROID_SDK_HOME) ANDROID_NDK_HOME=$(ANDROID_NDK_HOME) \
$(PYTHON) ci/rebuild_updated_recipes.py
$(PYTHON) ci/rebuild_updated_recipes.py $(REBUILD_UPDATED_RECIPES_EXTRA_ARGS)

testapps-with-numpy: virtualenv
. $(ACTIVATE) && cd testapps/on_device_unit_tests/ && \
Expand Down Expand Up @@ -84,6 +85,9 @@ docker/run/make/with-artifact/aab/%: docker/build
docker cp p4a-latest:/home/user/app/testapps/on_device_unit_tests/bdist_unit_tests_app-release-1.1-.aab ./aabs
docker rm -fv p4a-latest

docker/run/make/rebuild_updated_recipes: docker/build
docker run --name p4a-latest -e REBUILD_UPDATED_RECIPES_EXTRA_ARGS --env-file=.env $(DOCKER_IMAGE) make rebuild_updated_recipes

docker/run/make/%: docker/build
docker run --rm --env-file=.env $(DOCKER_IMAGE) make $*

Expand Down
21 changes: 18 additions & 3 deletions ci/rebuild_updated_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"""
import sh
import os
import sys
import argparse
from pythonforandroid.build import Context
from pythonforandroid import logger
from pythonforandroid.toolchain import current_directory
Expand All @@ -46,7 +48,7 @@ def modified_recipes(branch='origin/develop'):
return recipes


def build(target_python, requirements):
def build(target_python, requirements, archs):
"""
Builds an APK given a target Python and a set of requirements.
"""
Expand All @@ -57,16 +59,29 @@ def build(target_python, requirements):
requirements.add(target_python.name)
requirements = ','.join(requirements)
logger.info('requirements: {}'.format(requirements))

with current_directory('testapps/on_device_unit_tests/'):
# iterates to stream the output
for line in sh.python(
'setup.py', 'apk', '--sdk-dir', android_sdk_home,
'--ndk-dir', android_ndk_home, '--requirements',
requirements, _err_to_out=True, _iter=True):
requirements, *[f"--arch={arch}" for arch in archs],
_err_to_out=True, _iter=True):
print(line)


def main():
parser = argparse.ArgumentParser("rebuild_updated_recipes")
parser.add_argument(
"--arch",
help="The archs to build for during tests",
action="append",
default=[],
)
args, unknown = parser.parse_known_args(sys.argv[1:])

logger.info(f"Building updated recipes for the following archs: {args.arch}")

target_python = TargetPython.python3
recipes = modified_recipes()
logger.info('recipes modified: {}'.format(recipes))
Expand All @@ -89,7 +104,7 @@ def main():
broken_recipes = BROKEN_RECIPES[target_python]
recipes -= broken_recipes
logger.info('recipes to build (no broken): {}'.format(recipes))
build(target_python, recipes)
build(target_python, recipes, args.arch)


if __name__ == '__main__':
Expand Down