Skip to content

Android Builds

Android Builds #68

Workflow file for this run

name: Android Builds
on:
pull_request:
types: [opened, reopened, synchronize]
workflow_dispatch:
inputs:
use_expanded_matrix:
description: 'Use an expanded matrix?'
default: '0'
required: true
env:
CCACHE_DIR: ${{ github.workspace }}/ccache_dir
GITHUB_TOKEN: ${{ github.token }}
xcodeVersion: "14.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:
prepare_matrix:
runs-on: ubuntu-20.04
outputs:
matrix_os: ${{ steps.export-result.outputs.matrix_os }}
matrix_architecture: ${{ steps.export-result.outputs.matrix_architecture }}
matrix_python_version: ${{ steps.export-result.outputs.matrix_python_version }}
steps:
- uses: actions/checkout@v3
with:
submodules: false
- name: Use expanded matrix
if: github.event.inputs.use_expanded_matrix == '1'
run: |
echo "EXPANDED_MATRIX_PARAM=-e=1" >> $GITHUB_ENV
- id: export-result
run: |
echo "matrix_os=$( python scripts/gha/print_matrix_configuration.py -w android -k os ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
echo "matrix_architecture=$( python scripts/gha/print_matrix_configuration.py -w android -k architecture ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
echo "matrix_python_version=$( python scripts/gha/print_matrix_configuration.py -w android -k python_version ${EXPANDED_MATRIX_PARAM} )" >> $GITHUB_OUTPUT
build:
name: android-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
needs: prepare_matrix
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(needs.prepare_matrix.outputs.matrix_os) }}
architecture: ${{ fromJson(needs.prepare_matrix.outputs.matrix_architecture) }}
python_version: ${{ fromJson(needs.prepare_matrix.outputs.matrix_python_version) }}
steps:
- name: setup Xcode version (macos)
if: runner.os == 'macOS'
run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer
- name: Force Java 8 (macOS)
if: startsWith(matrix.os, 'macos')
shell: bash
run: echo "JAVA_HOME=${JAVA_HOME_8_X64}" >> $GITHUB_ENV
- 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
- name: Check expanded matrix config
if: github.event.inputs.expanded_matrix == '1'
run: |
echo "Enabling expanded build and test matrix."
echo "USE_EXPANDED_MATRIX=1" >> $GITHUB_ENV
- uses: actions/checkout@v3
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@v4
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.architecture }}
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v1.1
- name: Cache NDK
id: cache_ndk
uses: actions/cache@v3
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: Install prerequisites
shell: bash
run: |
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
- name: Add strings.exe to PATH (Windows only)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
# strings.exe was installed in repo root by install_prereqs.sh.
# There is another conflicting strings executable on Github runners.
# "C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\bin\strings.exe"
# Make sure to prepend the one in our repo root to the path.
echo "${{ github.workspace }}" >> $GITHUB_PATH
- name: Run strings.exe once to accept license(Windows only)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
# This invocation is just to accept the license. Otherwise the command
# fails during build process. Also, running a command with just this
# flag makes the process exit with code 127 and stops the workflow.
# We ignore the error and continue with the rest of the steps.
strings -accepteula || true
- name: Cache ccache files
id: cache_ccache
uses: actions/cache@v3
with:
path: ccache_dir
key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }}
- name: Build SDK
shell: bash
run: |
build_scripts/android/build.sh android_build .
- name: Stats for ccache (mac and linux)
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: ccache -s
- name: Print built libraries
shell: bash
run: |
find android_build -name "*.aar"
find android_build -name "*.jar"
mkdir -p "${{ github.workspace }}/BuildRoot/Library/firebase/usr/android"
for file in $(find ${firebase_dir} -name "*.aar"); do
cp "$file" "${{ github.workspace }}/BuildRoot/Library/firebase/usr/android"
done
- uses: actions/upload-artifact@v3
with:
name: firebase-android-${{ matrix.architecture }}-${{ matrix.os }}
path: ${{ github.workspace }}/BuildRoot/Library/firebase