mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
This change uses Gradle's official `setup-gradle` action to allow the caching of the downloaded gradle distribution and java dependencies in the GitHub Actions cache. However, since the initial download of gradle distribution is still handled by the `gradlew` wrapper script which doesn't retry on network failures, this change also adds a simple retry mechanism using shell scripting. Fixes #34600 Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
146 lines
5.6 KiB
YAML
146 lines
5.6 KiB
YAML
name: Android
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
profile:
|
|
required: false
|
|
default: "release"
|
|
type: string
|
|
upload:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
github-release-id:
|
|
required: false
|
|
type: string
|
|
workflow_dispatch:
|
|
inputs:
|
|
profile:
|
|
required: false
|
|
default: "release"
|
|
type: choice
|
|
options: ["release", "debug", "production"]
|
|
|
|
env:
|
|
RUST_BACKTRACE: 1
|
|
SHELL: /bin/bash
|
|
# FIXME: Temporarily commented to see if it helps with #34571.
|
|
# SCCACHE_GHA_ENABLED: "true"
|
|
# RUSTC_WRAPPER: "sccache"
|
|
# CCACHE: "sccache"
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
jobs:
|
|
build:
|
|
name: Android Build
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
target: ['aarch64-linux-android', 'armv7-linux-androideabi', 'i686-linux-android', 'x86_64-linux-android']
|
|
steps:
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@main
|
|
with:
|
|
tool-cache: false
|
|
android: false
|
|
large-packages: false
|
|
swap-storage: false
|
|
- uses: actions/checkout@v4
|
|
if: github.event_name != 'pull_request_target'
|
|
with:
|
|
fetch-depth: 2
|
|
# This is necessary to checkout the pull request if this run was triggered via a
|
|
# `pull_request_target` event.
|
|
- uses: actions/checkout@v4
|
|
if: github.event_name == 'pull_request_target'
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 2
|
|
# FIXME: Temporarily commented to see if it helps with #34571.
|
|
# - name: Run sccache-cache
|
|
# uses: mozilla-actions/sccache-action@v0.0.6
|
|
- name: Install crown
|
|
run: cargo install --path support/crown
|
|
- name: Bootstrap Python
|
|
run: python3 -m pip install --upgrade pip virtualenv
|
|
- name: Bootstrap dependencies
|
|
run: sudo apt update && python3 ./mach bootstrap --skip-lints
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
with:
|
|
packages: 'tools platform-tools platforms;android-33'
|
|
- name: Install Android NDK
|
|
uses: nttld/setup-ndk@v1
|
|
id: setup-ndk
|
|
with:
|
|
ndk-version: r26c
|
|
- name: Setup Gradle caches
|
|
uses: gradle/actions/setup-gradle@v4
|
|
- name: Trigger initial download of Gradle with retries
|
|
run: |
|
|
for i in {1..4}; do
|
|
./gradlew --version && break || { echo "Downloading Gradle failed (attempt $i)." && sleep $((3 ** $i)); };
|
|
done
|
|
working-directory: ./support/android/apk/
|
|
- name: Setup Key Store for APK Signing
|
|
env:
|
|
KEYSTORE_BASE64: ${{ secrets.APK_KEYSTORE_BASE64 }}
|
|
if: ${{ env.KEYSTORE_BASE64 != '' }}
|
|
run: |
|
|
APK_SIGNING_KEY_STORE_PATH="${PWD}/servo_keystore.jks"
|
|
echo "${KEYSTORE_BASE64}" | base64 -d > "${APK_SIGNING_KEY_STORE_PATH}"
|
|
echo "APK_SIGNING_KEY_STORE_PATH=${APK_SIGNING_KEY_STORE_PATH}" >> ${GITHUB_ENV}
|
|
- name: Build (arch ${{ matrix.target }} profile ${{ inputs.profile }})
|
|
env:
|
|
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }}
|
|
APK_SIGNING_KEY_STORE_PASS: ${{ secrets.APK_SIGNING_KEY_STORE_PASS }}
|
|
APK_SIGNING_KEY_ALIAS: ${{ secrets.APK_SIGNING_KEY_ALIAS }}
|
|
APK_SIGNING_KEY_PASS: ${{ secrets.APK_SIGNING_KEY_PASS }}
|
|
run: |
|
|
python3 ./mach build --use-crown --locked --target ${{ matrix.target }} --${{ inputs.profile }}
|
|
cp -r target/cargo-timings target/cargo-timings-android-${{ matrix.target }}
|
|
# TODO: This is disabled since APK crashes during startup.
|
|
# See https://github.com/servo/servo/issues/31134
|
|
# - name: Script tests
|
|
# run: ./mach test-android-startup
|
|
- name: Archive build timing
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cargo-timings-android-${{ matrix.target }}
|
|
# Using a wildcard here ensures that the archive includes the path.
|
|
path: target/cargo-timings-*
|
|
- name: Upload nightly
|
|
if: ${{ inputs.upload && contains(matrix.target, 'aarch64') }}
|
|
run: |
|
|
python3 ./mach upload-nightly android \
|
|
--secret-from-environment \
|
|
--github-release-id ${{ inputs.github-release-id }}
|
|
env:
|
|
S3_UPLOAD_CREDENTIALS: ${{ secrets.S3_UPLOAD_CREDENTIALS }}
|
|
NIGHTLY_REPO_TOKEN: ${{ secrets.NIGHTLY_REPO_TOKEN }}
|
|
NIGHTLY_REPO: ${{ github.repository_owner }}/servo-nightly-builds
|
|
- name: Generate artifact attestation for APK
|
|
if: ${{ inputs.upload }}
|
|
uses: actions/attest-build-provenance@v1
|
|
with:
|
|
subject-path: target/android/${{ matrix.target }}/${{ inputs.profile }}/servoapp.apk
|
|
- name: Upload APK artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ inputs.profile }}-binary-android-${{ matrix.target }}
|
|
path: target/android/${{ matrix.target }}/${{ inputs.profile }}/servoapp.apk
|
|
- name: Generate artifact attestation for AAR
|
|
if: ${{ inputs.upload }}
|
|
uses: actions/attest-build-provenance@v1
|
|
with:
|
|
subject-path: target/android/${{ matrix.target }}/${{ inputs.profile }}/servoview.aar
|
|
- name: Upload AAR artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ inputs.profile }}-library-android-${{ matrix.target }}
|
|
path: target/android/${{ matrix.target }}/${{ inputs.profile }}/servoview.aar
|