Skip to content

gh-137242: Build Android artifacts in a reusable workflow #137768

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ jobs:
run: ./python Lib/test/ssltests.py

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

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

build-wasi:
name: 'WASI'
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/reusable-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Reusable Android

on:
workflow_call:
inputs:
arch:
description: CPU architecture
required: true
type: string
check-name:
description: A custom name for the Checks API-reported status
required: false
type: string
checkout-ref:
description: A custom repository committish to fetch from Git
required: false
type: string
checkout-repository:
description: A custom repository slug to fetch from Git
required: false
type: string
runner-vm-os:
description: VM OS to use
required: true
type: string
store-built-artifacts:
default: false
description: Whether to preserve output as workflow run artifacts
required: false
type: boolean
timeout-minutes:
description: Deadline for the job to complete
required: true
type: number
outputs:
steps:
description: >-
JSON-formatted collection of all build steps with their outputs
value: ${{ jobs.build.outputs.steps }}

env:
FORCE_COLOR: 1
ANDROID_CI_SCRIPT_TRIPLET: ${{ inputs.arch }}-linux-android

jobs:
build:
name: >-
${{
inputs.check-name
&& inputs.check-name
|| format(
'{0}@💻{1}',
inputs.runner-vm-os,
inputs.arch
)
}}

runs-on: ${{ inputs.runner-vm-os }}

timeout-minutes: ${{ inputs.timeout-minutes }}

outputs:
steps: ${{ toJSON(steps) }}

steps:
- name: >-
Fetch CPython source from ${{
inputs.checkout-repository
&& inputs.checkout-repository
|| 'Git'
}}${{
inputs.checkout-ref
&& format(' @ {0}', inputs.checkout-ref)
|| ''
}}
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
repository: ${{ inputs.checkout-repository }}
ref: ${{ inputs.checkout-ref }}

- name: Build and test
run: ./Android/android.py ci "${ANDROID_CI_SCRIPT_TRIPLET}"

- name: Upload Built artifacts
if: inputs.store-built-artifacts
id: artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ANDROID_CI_SCRIPT_TRIPLET }}
path: cross-build/${{ env.ANDROID_CI_SCRIPT_TRIPLET }}/dist/*
if-no-files-found: error
Loading