diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..8566502f --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,13 @@ +task: + name: Build with AOSP + only_if: $CIRRUS_PR_LABELS =~ ".*aosp-build.*" + timeout_in: 120m + container: + image: ubuntu:23.04 + cpu: 8 + memory: 32G + build_script: + - ./.github/scripts/build_aosp.sh aosp_arm64 userdebug android-14.0.0_r1 + always: + seedvault_artifacts: + path: $CIRRUS_WORKING_DIR/Seedvault.apk diff --git a/.github/scripts/build_aosp.sh b/.github/scripts/build_aosp.sh new file mode 100755 index 00000000..1cd2e4c1 --- /dev/null +++ b/.github/scripts/build_aosp.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y git-core gnupg flex bison build-essential zip curl zlib1g-dev \ + libc6-dev-i386 libncurses5 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev \ + libxml2-utils xsltproc unzip fontconfig python3 npm pip e2fsprogs python3-protobuf \ + fonts-dejavu diffutils rsync ccache + +npm install --global yarn + +mkdir -p ~/bin +curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo +chmod a+x ~/bin/repo +ln -s /usr/bin/python3 /usr/bin/python +export PATH=~/bin:$PATH + +set -e + +retry() { + set +e + local max_attempts=${ATTEMPTS-5} + local timeout=${TIMEOUT-1} + local attempt=0 + local exitCode=0 + + while [[ $attempt < $max_attempts ]] + do + "$@" + exitCode=$? + + if [[ $exitCode == 0 ]] + then + break + fi + + echo "Failure! Retrying ($*) in $timeout.." + sleep "${timeout}" + attempt=$(( attempt + 1 )) + timeout=$(( timeout * 2 )) + done + + if [[ $exitCode != 0 ]] + then + echo "Failed too many times! ($*)" + fi + + set -e + + return $exitCode +} + +DEVICE=$1 +TARGET=$2 +BRANCH=$3 + +git config --global user.email "seedvault@example.com" +git config --global user.name "Seedvault CI" + +retry curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo +chmod a+x ~/bin/repo + +mkdir -p /aosp +cd /aosp +retry yes | repo init -u https://android.googlesource.com/platform/manifest -b "$BRANCH" --depth=1 + +mkdir -p .repo/local_manifests +cat << EOF > .repo/local_manifests/seedvault.xml + + + + + + + + +EOF + +retry repo sync -c -j8 --fail-fast --force-sync + +# Cirrus CI seems to (possibly) reschedule tasks that aren't sending out logs for a while? +while true; do echo "Still building..."; sleep 30; done & + +source build/envsetup.sh +lunch $DEVICE-$TARGET +m -j6 Seedvault + +mv /aosp/out/target/product/generic_arm64/system/system_ext/priv-app/Seedvault/Seedvault.apk "$CIRRUS_WORKING_DIR"