Skip to content

Commit 29fe94d

Browse files
committed
Build Android artifacts in a reusable workflow
This is a follow-up for python#137186 aiming to make the initially added automation live in its own "module" rather than the top-level workflow and make it possible to reuse it externally.
1 parent 04377a1 commit 29fe94d

File tree

2 files changed

+100
-9
lines changed

2 files changed

+100
-9
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ jobs:
398398
run: ./python Lib/test/ssltests.py
399399

400400
build-android:
401-
name: Android (${{ matrix.arch }})
401+
# ${{ '' } is a hack to nest jobs under the same sidebar category.
402+
name: Android${{ '' }} # zizmor: ignore[obfuscation]
402403
needs: build-context
403404
if: needs.build-context.outputs.run-tests == 'true'
404-
timeout-minutes: 60
405405
strategy:
406406
fail-fast: false
407407
matrix:
@@ -412,13 +412,12 @@ jobs:
412412
- arch: x86_64
413413
runs-on: ubuntu-24.04
414414

415-
runs-on: ${{ matrix.runs-on }}
416-
steps:
417-
- uses: actions/checkout@v4
418-
with:
419-
persist-credentials: false
420-
- name: Build and test
421-
run: ./Android/android.py ci ${{ matrix.arch }}-linux-android
415+
uses: ./.github/workflows/reusable-android.yml
416+
with:
417+
arch: ${{ matrix.arch }}
418+
check-name: ${{ matrix.arch }}
419+
runner-vm-os: ${{ matrix.runs-on }}
420+
timeout-minutes: 60
422421

423422
build-wasi:
424423
name: 'WASI'
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Reusable Android
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
arch:
7+
description: CPU architecture
8+
required: true
9+
type: string
10+
check-name:
11+
description: A custom name for the Checks API-reported status
12+
required: false
13+
type: string
14+
checkout-ref:
15+
description: A custom repository committish to fetch from Git
16+
required: false
17+
type: string
18+
checkout-repository:
19+
description: A custom repository slug to fetch from Git
20+
required: false
21+
type: string
22+
runner-vm-os:
23+
description: VM OS to use
24+
required: true
25+
type: string
26+
store-built-artifacts:
27+
default: false
28+
description: Whether to preserve output as workflow run artifacts
29+
required: false
30+
type: boolean
31+
timeout-minutes:
32+
description: Deadline for the job to complete
33+
required: true
34+
type: number
35+
outputs:
36+
steps:
37+
description: >-
38+
JSON-formatted collection of all build steps with their outputs
39+
value: ${{ jobs.build.outputs.steps }}
40+
41+
env:
42+
FORCE_COLOR: 1
43+
ANDROID_CI_SCRIPT_TRIPLET: ${{ inputs.arch }}-linux-android
44+
45+
jobs:
46+
build:
47+
name: >-
48+
${{
49+
inputs.check-name
50+
&& inputs.check-name
51+
|| format(
52+
'{0}@💻{1}',
53+
inputs.runner-vm-os,
54+
inputs.arch
55+
)
56+
}}
57+
58+
runs-on: ${{ inputs.runner-vm-os }}
59+
60+
timeout-minutes: ${{ inputs.timeout-minutes }}
61+
62+
outputs:
63+
steps: ${{ toJSON(steps) }}
64+
65+
steps:
66+
- name: >-
67+
Fetch CPython source from ${{
68+
inputs.checkout-repository
69+
&& inputs.checkout-repository
70+
|| 'Git'
71+
}}${{
72+
inputs.checkout-ref
73+
&& format(' @ {0}', inputs.checkout-ref)
74+
|| ''
75+
}}
76+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
77+
with:
78+
persist-credentials: false
79+
repository: ${{ inputs.checkout-repository }}
80+
ref: ${{ inputs.checkout-ref }}
81+
82+
- name: Build and test
83+
run: ./Android/android.py ci "${ANDROID_CI_SCRIPT_TRIPLET}"
84+
85+
- name: Upload Built artifacts
86+
if: inputs.store-built-artifacts
87+
id: artifacts
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: ${{ env.ANDROID_CI_SCRIPT_TRIPLET }}
91+
path: cross-build/${{ env.ANDROID_CI_SCRIPT_TRIPLET }}/dist/*
92+
if-no-files-found: error

0 commit comments

Comments
 (0)