From 51925eda31cdf22d1ecfc5f90e252077c56fcabd Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Fri, 11 Aug 2023 22:07:42 +0200 Subject: [PATCH] [Android][ci] Separate Android client build from the Android Manager build to speed-up CI Signed-off-by: Vitalii Koshura --- .github/workflows/android.yml | 180 ++++++++++++++++++++++++------ android/build_component.sh | 19 +++- android/ci_build_vcpkg_client.sh | 28 ++++- android/ci_build_vcpkg_manager.sh | 18 ++- 4 files changed, 203 insertions(+), 42 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 01402cb49c5..78953143421 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -35,12 +35,12 @@ env: AWS_DEFAULT_REGION: us-west-2 jobs: - build: - name: ${{ matrix.type }}-build + build-client: + name: client-${{ matrix.type }}-build runs-on: ubuntu-latest strategy: matrix: - type: [manager, libs, apps, libs-cmake] + type: [armv6, arm, arm64, x86, x86_64] fail-fast: false steps: - uses: actions/checkout@v3 @@ -53,6 +53,84 @@ jobs: sudo apt-get -qq update sudo apt-get install -y libncurses5 + - name: Check if build is running from origin repo + if: ${{ success() && env.AWS_ACCESS_KEY_ID != 0 && env.AWS_SECRET_ACCESS_KEY != 0 }} + run: | + echo "VCPKG_BINARY_SOURCES=clear;x-aws,s3://vcpkg.cache.boinc/,readwrite" >> $GITHUB_ENV + + - name: Check if build is running from fork + if: ${{ success() && (env.AWS_ACCESS_KEY_ID == 0 || env.AWS_SECRET_ACCESS_KEY == 0) }} + run: | + echo "VCPKG_BINARY_SOURCES=clear;x-aws-config,no-sign-request;x-aws,s3://vcpkg.cache.boinc/,read" >> $GITHUB_ENV + + - name: Unset ANDROID_NDK_ROOT environment variable + if: ${{ success() }} + run: | + echo ANDROID_NDK_ROOT="" >> $GITHUB_ENV + + - name: Build client with vcpkg + if: ${{ success() }} + run: ./android/ci_build_vcpkg_client.sh --arch ${{ matrix.type }} + + - name: Prepare logs on failure + if: ${{ failure() }} + run: python ./deploy/prepare_deployment.py logs + + - name: Upload logs on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: android_logs_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} + path: deploy/logs.7z + + - name: Upload client on success + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: android_client_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} + path: android/BOINC/app/src/main/assets/ + + build-manager: + name: manager-build + runs-on: ubuntu-latest + needs: build-client + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Download armv6 client + uses: actions/download-artifact@v3 + with: + name: linux-package_armv6_${{ github.event.pull_request.head.sha }} + path: pkgs/ + + - name: Download arm client + uses: actions/download-artifact@v3 + with: + name: linux-package_arm_${{ github.event.pull_request.head.sha }} + path: pkgs/ + + - name: Download arm64 client + uses: actions/download-artifact@v3 + with: + name: linux-package_arm64_${{ github.event.pull_request.head.sha }} + path: pkgs/ + + - name: Download x86 client + uses: actions/download-artifact@v3 + with: + name: linux-package_x86_${{ github.event.pull_request.head.sha }} + path: pkgs/ + + - name: Download x86_64 client + uses: actions/download-artifact@v3 + with: + name: linux-package_x86_64_${{ github.event.pull_request.head.sha }} + path: pkgs/ + - name: Setup Java uses: actions/setup-java@v3 with: @@ -62,6 +140,72 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@v2 + - name: Build manager with vcpkg + run: ./android/ci_build_vcpkg_manager.sh --skip-client-build + + - name: Prepare logs on failure + if: ${{ failure() }} + run: python ./deploy/prepare_deployment.py logs + + - name: Upload logs on failure + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: android_logs_manager_${{ github.event.pull_request.head.sha }} + path: deploy/logs.7z + + - name: Prepare artifacts for deploy + run: python ./deploy/prepare_deployment.py android_manager + + - name: Upload generic artifacts + uses: actions/upload-artifact@v3 + with: + name: android_manager_${{ github.event.pull_request.head.sha }} + path: deploy/android_manager.7z + + - name: Upload xiaomi manager + uses: actions/upload-artifact@v3 + with: + name: android_xiaomi_manager_${{ github.event.pull_request.head.sha }} + path: deploy/android_manager_xiaomi.7z + + - name: Upload armv6 only manager + uses: actions/upload-artifact@v3 + with: + name: android_armv6_manager_${{ github.event.pull_request.head.sha }} + path: deploy/android_manager_armv6.7z + + - name: Upload JUnit Tests Results + uses: actions/upload-artifact@v3 + if: always() + with: + name: Android_tests_results + path: android/BOINC/app/build/test-results/testDebugUnitTest/TEST-*.xml + + - name: Upload coverage report + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true + verbose: false + + build: + name: ${{ matrix.type }}-build + runs-on: ubuntu-latest + strategy: + matrix: + type: [libs, apps, libs-cmake] + fail-fast: false + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Install dependencies + run: | + sudo add-apt-repository universe + sudo apt-get -qq update + sudo apt-get install -y libncurses5 + - name: Check if build is running from origin repo if: ${{ success() && env.AWS_ACCESS_KEY_ID != 0 && env.AWS_SECRET_ACCESS_KEY != 0 }} run: | @@ -77,10 +221,6 @@ jobs: run: | echo ANDROID_NDK_ROOT="" >> $GITHUB_ENV - - name: Build manager with vcpkg - if: ${{ success() && matrix.type == 'manager' }} - run: ./android/ci_build_vcpkg_manager.sh - - name: Build libs with vcpkg if: ${{ success() && matrix.type == 'libs' }} run: ./android/ci_build_vcpkg_libraries.sh @@ -114,29 +254,3 @@ jobs: with: name: android_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} path: deploy/android_${{ matrix.type }}.7z - - name: Upload xiaomi manager - uses: actions/upload-artifact@v3 - if: ${{ contains(matrix.type, 'manager') }} - with: - name: android_xiaomi_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} - path: deploy/android_${{ matrix.type }}_xiaomi.7z - - name: Upload armv6 only manager - uses: actions/upload-artifact@v3 - if: ${{ contains(matrix.type, 'manager') }} - with: - name: android_armv6_${{ matrix.type }}_${{ github.event.pull_request.head.sha }} - path: deploy/android_${{ matrix.type }}_armv6.7z - - - name: Upload JUnit Tests Results - uses: actions/upload-artifact@v3 - if: always() && matrix.type == 'manager' # run this step even if previous step failed - with: - name: Android_tests_results - path: android/BOINC/app/build/test-results/testDebugUnitTest/TEST-*.xml - - - name: Upload coverage report - uses: codecov/codecov-action@v3 - if: ${{ success() && matrix.type == 'manager' }} - with: - fail_ci_if_error: true - verbose: false diff --git a/android/build_component.sh b/android/build_component.sh index d665903b3d2..733207a6196 100755 --- a/android/build_component.sh +++ b/android/build_component.sh @@ -15,6 +15,7 @@ fi ci="" component="" +arch="" while [ $# -gt 0 ]; do key="$1" @@ -26,6 +27,10 @@ while [ $# -gt 0 ]; do component=$2 shift ;; + --arch) + arch=$2 + shift + ;; *) echo "unrecognized option $key" ;; @@ -42,10 +47,14 @@ cd android rm -rf /tmp/vcpkg_updated -./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch armv6 -./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch arm -./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch arm64 -./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch x86 -./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch x86_64 +if [ "x$arch" = "x" ]; then + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch armv6 + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch arm + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch arm64 + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch x86 + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch x86_64 +else + ./buildAndroidBOINC-CI.sh --cache_dir "$ANDROID_TC" --build_dir "$BUILD_DIR" --silent $ci --component $component --arch $arch +fi cd .. diff --git a/android/ci_build_vcpkg_client.sh b/android/ci_build_vcpkg_client.sh index 3f5b27877b3..63a4875c920 100755 --- a/android/ci_build_vcpkg_client.sh +++ b/android/ci_build_vcpkg_client.sh @@ -13,6 +13,28 @@ if [ ! -d "android" ]; then exit 1 fi -echo '===== BOINC Client for all platforms build start =====' -android/build_component.sh --ci --component client -echo '===== BOINC Client for all platforms build done =====' +arch="" + +while [ $# -gt 0 ]; do + key="$1" + case $key in + --arch) + arch=$2 + shift + ;; + *) + echo "unrecognized option $key" + ;; + esac + shift # past argument or value +done + +if [ "x$arch" = "x" ]; then + echo '===== BOINC Client for all platforms build start =====' + android/build_component.sh --ci --component client + echo '===== BOINC Client for all platforms build done =====' +else + echo '===== BOINC Client for '$arch' build start =====' + android/build_component.sh --ci --component client --arch $arch + echo '===== BOINC Client for '$arch' build done =====' +fi diff --git a/android/ci_build_vcpkg_manager.sh b/android/ci_build_vcpkg_manager.sh index dbc55277d48..57635476281 100755 --- a/android/ci_build_vcpkg_manager.sh +++ b/android/ci_build_vcpkg_manager.sh @@ -13,7 +13,23 @@ if [ ! -d "android" ]; then exit 1 fi -android/ci_build_vcpkg_client.sh +skip_client_build="" +while [ $# -gt 0 ]; do + key="$1" + case $key in + --skip-client-build) + skip_client_build="yes" + ;; + *) + echo "unrecognized option $key" + ;; + esac + shift # past argument or value +done + +if [ "x$skip_client_build" = "x" ]; then + android/ci_build_vcpkg_client.sh +fi cd android/BOINC