Skip to content

Commit 97ffb3e

Browse files
committed
Add Android CI job
1 parent 1481384 commit 97ffb3e

File tree

5 files changed

+86
-4
lines changed

5 files changed

+86
-4
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This is coded as an action rather than a workflow so the release-tools
2+
# repository can load it from a dynamically-chosen commit. Cross-repository
3+
# workflow calls must have a Git reference hard-coded in the calling workflow,
4+
# but actions can be run dynamically from the runner's filesystem.
5+
6+
name: Build and test (Android)
7+
description: Build and test (Android)
8+
9+
inputs:
10+
triplet:
11+
description: Host triplet
12+
required: true
13+
14+
runs:
15+
using: composite
16+
17+
steps:
18+
# Build Python, and package it into a release artifact.
19+
- run: ./Android/android.py build ${{ inputs.triplet }}
20+
- run: ./Android/android.py package ${{ inputs.triplet }}
21+
- uses: actions/upload-artifact@v4
22+
with:
23+
name: android
24+
path: cross-build/${{ inputs.triplet }}/dist/*
25+
if-no-files-found: error
26+
27+
# Currently, GitHub Actions can only run the Android emulator on Linux, so
28+
# all the remaining steps are conditional on that.
29+
30+
# (https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/).
31+
- name: Enable KVM for Android emulator
32+
if: runner.os == "Linux"
33+
run: |
34+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
35+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
36+
sudo udevadm control --reload-rules
37+
sudo udevadm trigger --name-match=kvm
38+
39+
- name: Unpack release artifact
40+
if: runner.os == "Linux"
41+
run: |
42+
mkdir $RUNNER_TEMP/android
43+
tar -C $RUNNER_TEMP/android -xf cross-build/${{ inputs.triplet }}/dist/*
44+
45+
- name: Tests
46+
if: runner.os == "Linux"
47+
run: |
48+
$RUNNER_TEMP/android/android.py test --managed maxVersion -v -- \
49+
-uall --single-process --rerun -W

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,31 @@ jobs:
397397
- name: SSL tests
398398
run: ./python Lib/test/ssltests.py
399399

400+
build-android:
401+
name: "Android"
402+
needs: build-context
403+
if: needs.build-context.outputs.run-tests == 'true'
404+
timeout-minutes: 60
405+
strategy:
406+
fail-fast: false
407+
matrix:
408+
arch: [aarch64, x86_64]
409+
include:
410+
# Use the same runs-on configuration as build-macos and build-ubuntu.
411+
- arch: aarch64
412+
runs-on: ${{ github.repository_owner == 'python' && 'ghcr.io/cirruslabs/macos-runner:sonoma' || 'macos-14' }}
413+
- arch: x86_64
414+
runs-on: ubuntu-24.04
415+
416+
runs-on: ${{ matrix.runs-on }}
417+
steps:
418+
- uses: actions/checkout@v4
419+
with:
420+
persist-credentials: false
421+
- uses: ./.github/actions/build-android
422+
with:
423+
triplet: ${{ matrix.arch }}-linux-android
424+
400425
build-wasi:
401426
name: 'WASI'
402427
needs: build-context
@@ -705,6 +730,7 @@ jobs:
705730
- build-ubuntu
706731
- build-ubuntu-ssltests-awslc
707732
- build-ubuntu-ssltests-openssl
733+
- build-android
708734
- build-wasi
709735
- test-hypothesis
710736
- build-asan
@@ -740,6 +766,7 @@ jobs:
740766
build-ubuntu,
741767
build-ubuntu-ssltests-awslc,
742768
build-ubuntu-ssltests-openssl,
769+
build-android,
743770
build-wasi,
744771
test-hypothesis,
745772
build-asan,

.github/zizmor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ rules:
88
config:
99
policies:
1010
"*": ref-pin
11+
obfuscation:
12+
ignore:
13+
- build.yml

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ repos:
7272
- id: actionlint
7373

7474
- repo: https://github.com/woodruffw/zizmor-pre-commit
75-
rev: v1.6.0
75+
rev: v1.11.0
7676
hooks:
7777
- id: zizmor
7878

Android/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ similar to the `Android` directory of the CPython source tree.
9696

9797
## Testing
9898

99-
The Python test suite can be run on Linux, macOS, or Windows:
99+
The Python test suite can be run on Linux, macOS, or Windows.
100100

101-
* On Linux, the emulator needs access to the KVM virtualization interface, and
102-
a DISPLAY environment variable pointing at an X server. Xvfb is acceptable.
101+
On Linux, the emulator needs access to the KVM virtualization interface. This may
102+
require adding your user to a group, or [changing your udev
103+
rules](https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/).
104+
If the emulator fails to start, try running `$ANDROID_HOME/emulator/emulator
105+
-accel-check`.
103106

104107
The test suite can usually be run on a device with 2 GB of RAM, but this is
105108
borderline, so you may need to increase it to 4 GB. As of Android

0 commit comments

Comments
 (0)