Skip to content

Merge pull request #1131 from Chilledheart/core_move_logging_misc #2890

Merge pull request #1131 from Chilledheart/core_move_logging_misc

Merge pull request #1131 from Chilledheart/core_move_logging_misc #2890

name: Build Artifacts (Android Binary)
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
pull_request:
branches: [master, develop]
paths-ignore:
- '**/*.md'
- '.circleci/**'
- '.cirrus.yml'
push:
branches: [master, develop]
paths-ignore:
- '**/*.md'
- '.circleci/**'
- '.cirrus.yml'
release:
types: [published]
schedule:
- cron: '0 16 * * *'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
env:
CACHE_EPOCH: 131-1
GOPROXY: direct
jobs:
android-binary-release:
strategy:
fail-fast: false
matrix:
include:
- arch: x86
build_type: Release
qemu_suffix: i386
rust_target: i686-linux-android
apilevel: 24
- arch: x64
build_type: Release
qemu_suffix: amd64
rust_target: x86_64-linux-android
apilevel: 24
- arch: arm
build_type: Release
qemu_suffix: armel
rust_target: armv7-linux-androideabi
apilevel: 24
- arch: arm64
build_type: Release
qemu_suffix: aarch64
rust_target: aarch64-linux-android
apilevel: 24
runs-on: ubuntu-20.04
env:
ARCH: ${{ matrix.arch }}
BUILD_TYPE: ${{ matrix.build_type }}
SYSROOT: ${{ github.workspace }}/android-sysroot-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Checkout with shallow submodules
run: |
# unshallow must come first otherwise submodule may be get unshallowed
git fetch --tags --unshallow
git submodule update --init --depth 1
- name: Patch libcxxabi for both of armel and armhf
if: ${{ matrix.arch == 'armel' || matrix.arch == 'arm' }}
run: |
cd third_party/libc++abi
patch -p1 < v8-6.7.17-fix-gcc-unwind-header.patch
- name: Cache toolchain
id: toolchain-cache
uses: actions/cache@v4
with:
path: |
third_party/llvm-build/Release+Asserts
key: ${{ runner.os }}-toolchain-${{ hashFiles('CLANG_REVISION') }}-v${{ env.CACHE_EPOCH }}
- name: Cache tun2proxy build stage
id: tun2proxy-cache
uses: actions/cache@v4
with:
path: |
third_party/tun2proxy/target/${{ matrix.rust_target }}/release/libtun2proxy.a
key: ${{ runner.os }}-rust-${{ matrix.rust_target }}-tun2proxy-${{ hashFiles('RUST_REVISION') }}-${{ hashFiles('RUST_CARGO_REVISION') }}-${{ hashFiles('third_party/tun2proxy/Cargo.toml') }}-v${{ env.CACHE_EPOCH }}-v1
- name: Cache crashpad build stage
id: crashpad-cache
uses: actions/cache@v4
with:
path: |
third_party/crashpad
key: ${{ runner.os }}-android-${{ matrix.arch }}-crashpad-${{ hashFiles('CRASHPAD_COMMIT') }}-v${{ env.CACHE_EPOCH }}-16k-alignment-no-stripped
- name: Cache gradle
uses: actions/cache@v4
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('android/gradle/wrapper/*') }}-${{ hashFiles('android/**/*.gradle') }}
- name: Cache qemu-user
id: qemu-user-cache
uses: actions/cache@v4
with:
path: |
qemu-user*.deb
key: ${{ runner.os }}-qemu-9.1.0-ds-8
- name: Cache sysroot
id: sysroot-cache
uses: actions/cache@v4
with:
path: |
${{ env.SYSROOT }}
key: android-sysroot-${{ matrix.arch }}-v1
- uses: actions/setup-go@v5
with:
go-version: '>=1.20.0'
cache-dependency-path: |
tools/go.sum
third_party/boringssl/src/go.sum
- name: Build build tool
run: |
cd tools
go build
#- uses: actions/setup-java@v4
# with:
# distribution: 'temurin'
# java-version: '17'
- name: Replace JAVA_HOME (pin to java 17)
run: |
echo "JAVA_HOME=${JAVA_HOME_17_X64}" >> $GITHUB_ENV
- name: Replace Android NDK (pin to r26c)
run: |
echo "ANDROID_NDK_VER=26.3.11579264" >> $GITHUB_ENV
- name: "Install dependency: prebuilt clang and clang-tidy binaries"
if: ${{ steps.toolchain-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/download-clang-prebuilt-binaries.py
rm -f third_party/llvm-build/Release+Asserts/*.tgz
- name: "Install dependency: qemu user cache"
if: ${{ steps.qemu-user-cache.outputs.cache-hit != 'true' }}
run: |
wget http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-user_9.1.0+ds-8_amd64.deb
- name: Change ubuntu mirror
run: |
sudo sed -i 's/azure.archive.ubuntu.com/azure.archive.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update -qq
- name: Populate depedencies
run: |
sudo apt-get update -qq
sudo apt-get install -y cmake ninja-build pkgconf gettext bubblewrap
# libc6-i386 interferes with x86 build
sudo apt remove libc6-i386
sudo dpkg -i qemu-user_*.deb
- name: Populate dependencie (cmake, overwrite)
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.29.8/cmake-3.29.8-linux-x86_64.tar.gz
sudo tar -C /usr/local --strip-components=1 -xf cmake-3.29.8-linux-x86_64.tar.gz
cmake --version
rm -f *.tar.gz
- name: Build Binary (tun2proxy)
if: ${{ steps.tun2proxy-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/setup-android-rust.sh
WITH_OS=android WITH_CPU=${{ matrix.arch }} ./scripts/build-tun2proxy.sh
- name: Build Binary (prebuild stage for crashpad)
if: ${{ steps.crashpad-cache.outputs.cache-hit != 'true' }}
run: |
# FIXME required by next step, need to copy to current clang with ndk's libunwind.a
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-no-build -no-configure
- name: Build Binary (crashpad)
if: ${{ steps.crashpad-cache.outputs.cache-hit != 'true' }}
run: |
WITH_OS=android WITH_CPU=${{ matrix.arch }} SKIP_STRIP=1 ./scripts/build-crashpad.sh
- name: Build Binary
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc -no-packaging
- name: "Install dependency: android sysroot (test purpose)"
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' }}
run: |
./scripts/get-android-sys.sh ${{ matrix.arch }} "${{ matrix.SYSROOT }}"
- name: Run tests (x86 and x64)
if: ${{ matrix.arch == 'x86' || matrix.arch == 'x64' }}
run: |
# android sysimg doesn't like resolv.conf
mkdir -p $SYSROOT/etc/ssl/certs $SYSROOT/dev $SYSROOT/proc $SYSROOT/data/local/tmp
bwrap --die-with-parent --ro-bind $SYSROOT / \
--ro-bind /sys /sys \
--ro-bind /etc/ssl/certs /etc/ssl/certs \
--proc /proc --dev /dev \
--unshare-all --share-net \
--bind $PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }} /data/local/tmp \
/data/local/tmp/yass_test
- name: Run tests (non x86, under qemu emulation)
if: ${{ matrix.arch != 'x86' && matrix.arch != 'x64' }}
run: |
# TMPDIR is required by leveldb unittests
qemu-${{ matrix.qemu_suffix }} -L $SYSROOT \
-E TMPDIR=$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }} \
$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }}/yass_test
- name: Install the Release certificate
if: ${{ github.event_name == 'release' }}
env:
SIGNING_STORE_BASE64: ${{ secrets.SIGNING_STORE_BASE64 }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: |
echo -n "$SIGNING_STORE_BASE64" | base64 --decode > $RUNNER_TEMP/release.jks
echo "SIGNING_STORE_PATH=$RUNNER_TEMP/release.jks" >> $GITHUB_ENV
echo "SIGNING_STORE_PASSWORD=$SIGNING_STORE_PASSWORD" >> $GITHUB_ENV
echo "SIGNING_KEY_ALIAS=$SIGNING_KEY_ALIAS" >> $GITHUB_ENV
echo "SIGNING_KEY_PASSWORD=$SIGNING_KEY_PASSWORD" >> $GITHUB_ENV
- name: Build AAB bundle
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc -android-aab
- name: Build APK package
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system android \
-build-benchmark -build-test -nc
- name: Clean up keychain and provisioning profile
if: ${{ always() }}
run: |
if [ ! -z $SIGNING_STORE_PATH ]; then
rm -f $SIGNING_STORE_PATH
fi
- name: Upload dist tarball (including debuginfo)
if: ${{ github.event_name == 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} yass*.tgz yass*.apk yass*.aab yass*.aab.idsig