Skip to content

Commit

Permalink
Move build_and_test_android from ci.yml to pkgci.yml. (iree-org#18070)
Browse files Browse the repository at this point in the history
Progress on iree-org#16203 and
iree-org#17957.

This migrates `.github/workflows/build_and_test_android.yml` to
`.github/workflows/pkgci_test_android.yml`.

**For now, this only builds for Android, it does not run tests or use
real Android devices at all**.

The previous workflow
* Relied on the "install" directory from a CMake build 
* Ran on large self-hosted CPU build machines
* Built within Docker (using
[`build_tools/docker/dockerfiles/android.Dockerfile`](https://github.com/iree-org/iree/blob/main/build_tools/docker/dockerfiles/android.Dockerfile))
* Used GCP/GCS for remote ccache storage
* Used GCP/GCS for passing files between jobs
* Ran tests on self-hosted lab machines (I think a raspberry pi
connected to some physical Android devices)

The new workflow
* Relies on Python packages produced by pkgci_build_packages
* Runs on standard GitHub-hosted runners
* Installs dependencies that it needs on-demand (ninja, Android NDK),
without using Docker
* Uses caches provided by GitHub Actions for ccache storage
* Could use Artifacts provided by GitHub Actions for passing files
between jobs
* Could run tests on self-hosted lab machines or Android emulators

I made some attempts at passing files from the build job to a test job
but ran into some GitHub Actions debugging that was tricky. Leaving the
remaining migration work there to contributors at Google or other
parties directly interested in Android CI infrastructure.

ci-exactly: build_packages, test_android
  • Loading branch information
ScottTodd authored Aug 5, 2024
1 parent 4a1f619 commit a7a1be3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 172 deletions.
152 changes: 0 additions & 152 deletions .github/workflows/build_and_test_android.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,25 +356,6 @@ jobs:
# "${DOCKER_IMAGE}" \
# "${TEST_SCRIPT}"

# Android cross-compilation and test is separated from cross_compile_and_test
# because some tests need to run on physical devices instead of emulators. And
# we need a fine-control on which tests only run on postsubmit as some devices
# are not scalable (while we want to test with Android emulator on ARM VMs on
# presubmit), which requires dynamic matrix generation (because "if" condition
# can't access matrix variable to skip certain matrix jobs for presubmit).
build_and_test_android:
needs: [setup, build_all]
if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'build_and_test_android')
uses: ./.github/workflows/build_and_test_android.yml
with:
runner-group: ${{ needs.setup.outputs.runner-group }}
runner-env: ${{ needs.setup.outputs.runner-env }}
write-caches: ${{ needs.setup.outputs.write-caches }}
is-pr: ${{ fromJson(needs.setup.outputs.is-pr) }}
install-dir: ${{ needs.build_all.outputs.install-dir }}
install-dir-archive: ${{ needs.build_all.outputs.install-dir-archive }}
install-dir-gcs-artifact: ${{ needs.build_all.outputs.install-dir-gcs-artifact }}

##############################################################################

# Depends on all the other jobs to provide a single anchor that indicates the
Expand Down Expand Up @@ -402,7 +383,6 @@ jobs:

# Crosscompilation
# - cross_compile_and_test
- build_and_test_android
steps:
- name: "Checking out repository"
uses: actions/[email protected]
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pkgci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ jobs:
needs: [setup, build_packages]
if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_tensorflow_cpu')
uses: ./.github/workflows/pkgci_test_tensorflow_cpu.yml

test_android:
needs: [setup, build_packages]
if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'test_android')
uses: ./.github/workflows/pkgci_test_android.yml
with:
write-caches: ${{ needs.setup.outputs.write-caches }}
91 changes: 91 additions & 0 deletions .github/workflows/pkgci_test_android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2024 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Workflow for Android cross-compilation and test jobs.
# The concurrency of this workflow is controlled by the caller's job.

name: PkgCI Test Android

on:
workflow_call:
inputs:
artifact_run_id:
type: string
default: ""
write-caches:
required: true
type: string
workflow_dispatch:
inputs:
artifact_run_id:
type: string
default: ""
write-caches:
required: true
type: string

permissions:
contents: read

jobs:
cross_compile:
runs-on: ubuntu-20.04
env:
PACKAGE_DOWNLOAD_DIR: ${{ github.workspace }}/.packages
VENV_DIR: ${{ github.workspace }}/.venv
IREE_TARGET_BUILD_DIR: build-android-arm_64
steps:
# General setup.
- name: "Checking out repository"
uses: actions/[email protected]
- name: "Checking out runtime submodules"
run: ./build_tools/scripts/git/update_runtime_submodules.sh
- uses: actions/[email protected]
with:
# Must match the subset of versions built in pkgci_build_packages.
python-version: "3.11"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
save: ${{ inputs.write-caches == 1 }}
- uses: actions/[email protected]
with:
name: linux_x86_64_release_packages
path: ${{ env.PACKAGE_DOWNLOAD_DIR }}
- name: Setup base venv
run: |
./build_tools/pkgci/setup_venv.py ${VENV_DIR} \
--artifact-path=${PACKAGE_DOWNLOAD_DIR} \
--fetch-gh-workflow=${{ inputs.artifact_run_id }}
- name: Install build dependencies
run: |
sudo apt update
sudo apt install -y ninja-build
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- uses: nttld/setup-ndk@v1
with:
ndk-version: r25b
- name: Build for Android
env:
IREE_HOST_BIN_DIR: ${{ env.VENV_DIR }}/bin
IREE_READ_REMOTE_CCACHE: 0
IREE_WRITE_REMOTE_CCACHE: 0
IREE_READ_LOCAL_CCACHE: 1
IREE_WRITE_LOCAL_CCACHE: ${{ inputs.write-caches }}
BUILD_PRESET: test
run: build_tools/cmake/build_android.sh

# TODO: run tests on physical devices or emulators
# * Emulators can run on the same host that ran the build
# * Physical devices could either
# A) be connected to a self-hosted build machine that runs the compiler,
# connects over ADB, and run tests
# B) be connected to a self-hosted run machine that downloads already
# compiled artifacts from a build machine and just connects over ADB
# to run tests

0 comments on commit a7a1be3

Please sign in to comment.