Skip to content

Android Builds

Android Builds #865

Workflow file for this run

name: Android Builds
on:
schedule:
- cron: "0 9 * * *" # 9am UTC = 1am PST / 2am PDT. for all testapps except firestore
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
apis:
description: 'CSV of apis to build and test'
default: 'analytics,auth,database,dynamic_links,firestore,functions,gma,messaging,remote_config,storage'
required: true
env:
CCACHE_DIR: ${{ github.workspace }}/ccache_dir
GITHUB_TOKEN: ${{ github.token }}
xcodeVersion: "13.3.1" # Only affects Mac runners, and only for prerequisites.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
check_and_prepare:
runs-on: ubuntu-latest
outputs:
apis: ${{ steps.set_outputs.outputs.apis }}
steps:
- id: set_outputs
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
apis="${{ github.event.inputs.apis }}"
else
apis="analytics,auth,database,dynamic_links,firestore,functions,gma,messaging,remote_config,storage"
fi
echo apis: ${apis}
echo "::set-output name=apis::${apis}"
build:
name: android-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
needs: [check_and_prepare]
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-latest, windows-latest]
architecture: [x64]
python_version: [3.7]
steps:
- name: setup Xcode version (macos)
if: runner.os == 'macOS'
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
- name: Store git credentials for all git commands
# Forces all git commands to use authenticated https, to prevent throttling.
shell: bash
run: |
git config --global credential.helper 'store --file /tmp/git-credentials'
echo 'https://${{ github.token }}@github.com' > /tmp/git-credentials
- name: Enable Git Long-paths Support
if: runner.os == 'Windows'
run: git config --system core.longpaths true
- uses: actions/checkout@v2
with:
submodules: true
- name: Set env variables for subsequent steps (all)
shell: bash
run: |
echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.architecture }}" >> $GITHUB_ENV
echo "GHA_INSTALL_CCACHE=1" >> $GITHUB_ENV
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.architecture }}
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v1.0.2
- name: Cache NDK
id: cache_ndk
uses: actions/cache@v2
with:
path: /tmp/android-ndk-r21e
key: android-ndk-${{ matrix.os }}-r21e
- name: Check cached NDK
shell: bash
if: steps.cache_ndk.outputs.cache-hit != 'true'
run: |
# If the NDK failed to download from the cache, but there is a
# /tmp/android-ndk-r21e directory, it's incomplete, so remove it.
if [[ -d "/tmp/android-ndk-r21e" ]]; then
echo "Removing incomplete download of NDK"
rm -rf /tmp/android-ndk-r21e
fi
- name: Update homebrew (avoid bintray errors)
uses: nick-invision/retry@v2
if: startsWith(matrix.os, 'macos')
with:
timeout_minutes: 10
max_attempts: 3
command: |
# Temporarily here until Github runners have updated their version of
# homebrew. This prevents errors arising from the shut down of
# binutils, used by older version of homebrew for hosting packages.
brew update
- name: Install prerequisites
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: |
scripts/build_scripts/android/install_prereqs.sh
echo "NDK_ROOT=/tmp/android-ndk-r21e" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=/tmp/android-ndk-r21e" >> $GITHUB_ENV
pip install -r scripts/build_scripts/python_requirements.txt
python scripts/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
- name: Download C++ SDK
shell: bash
run: |
set +e
# Retry up to 10 times because Curl has a tendency to timeout on
# Github runners.
for retry in {1..10} error; do
if [[ $retry == "error" ]]; then exit 5; fi
curl -LSs \
"https://firebase.google.com/download/cpp" \
--output firebase_cpp_sdk.zip && break
sleep 300
done
set -e
mkdir /tmp/downloaded_sdk
unzip -q firebase_cpp_sdk.zip -d /tmp/downloaded_sdk/
rm -f firebase_cpp_sdk.zip
- name: Cache ccache files
id: cache_ccache
uses: actions/cache@v2
with:
path: ccache_dir
key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }}
- name: Build testapp
shell: bash
run: |
set -x
python scripts/build_scripts/build_testapps.py --p Android \
--t ${{ needs.check_and_prepare.outputs.apis }} \
--output_directory "${{ github.workspace }}" \
--artifact_name "android-${{ matrix.os }}" \
--noadd_timestamp \
--short_output_paths \
--gha_build \
--packaged_sdk /tmp/downloaded_sdk/firebase_cpp_sdk
- name: Stats for ccache (mac and linux)
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: ccache -s
- name: Prepare results summary artifact
if: ${{ !cancelled() }}
shell: bash
run: |
if [ ! -f build-results-android-${{ matrix.os }}.log.json ]; then
echo "__SUMMARY_MISSING__" > build-results-android-${{ matrix.os }}.log.json
fi
- name: Upload Android integration tests artifact
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: testapps-android-${{ matrix.os }}
path: testapps-android-${{ matrix.os }}
retention-days: ${{ env.artifactRetentionDays }}
- name: Upload Android build results artifact
uses: actions/upload-artifact@v3
if: ${{ !cancelled() }}
with:
name: log-artifact
path: build-results-android-${{ matrix.os }}*
retention-days: ${{ env.artifactRetentionDays }}
- name: Download log artifacts
if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }}
uses: actions/download-artifact@v3
with:
path: test_results
name: log-artifact
- name: Summarize build results
if: ${{ !cancelled() }}
shell: bash
run: |
cat build-results-android-${{ matrix.os }}.log
if [[ "${{ job.status }}" != "success" ]]; then
exit 1
fi