|
1 |
| -name: Android builds |
| 1 | +name: Android Builds |
2 | 2 |
|
3 | 3 | on:
|
| 4 | + schedule: |
| 5 | + - cron: "0 9 * * *" # 9am UTC = 1am PST / 2am PDT. for all testapps except firestore |
| 6 | + pull_request: |
| 7 | + types: [opened, reopened, synchronize] |
4 | 8 | workflow_dispatch:
|
5 | 9 | inputs:
|
6 | 10 | apis:
|
7 |
| - description: 'CSV of apis whose quickstart examples we should build' |
| 11 | + description: 'CSV of apis to build and test' |
| 12 | + default: 'admob,analytics,auth,database,dynamic_links,firestore,functions,gma,messaging,remote_config,storage' |
| 13 | + required: true |
| 14 | + |
| 15 | +env: |
| 16 | + CCACHE_DIR: ${{ github.workspace }}/ccache_dir |
| 17 | + GITHUB_TOKEN: ${{ github.token }} |
| 18 | + xcodeVersion: "13.3.1" # Only affects Mac runners, and only for prerequisites. |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} |
| 22 | + cancel-in-progress: true |
8 | 23 |
|
9 | 24 | jobs:
|
10 |
| - build: |
| 25 | + check_and_prepare: |
11 | 26 | runs-on: ubuntu-latest
|
| 27 | + outputs: |
| 28 | + apis: ${{ steps.set_outputs.outputs.apis }} |
12 | 29 | steps:
|
13 |
| - - name: noop |
14 |
| - run: true |
| 30 | + - id: set_outputs |
| 31 | + run: | |
| 32 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 33 | + apis="${{ github.event.inputs.apis }}" |
| 34 | + else |
| 35 | + apis="admob,analytics,auth,database,dynamic_links,firestore,functions,gma,messaging,remote_config,storage" |
| 36 | + fi |
| 37 | + echo apis: ${apis} |
| 38 | + echo "::set-output name=apis::${apis}" |
| 39 | +
|
| 40 | + build: |
| 41 | + name: android-${{ matrix.os }}-${{ matrix.architecture }}-${{ matrix.python_version }} |
| 42 | + runs-on: ${{ matrix.os }} |
| 43 | + needs: [check_and_prepare] |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + os: [macos-12, ubuntu-latest, windows-latest] |
| 48 | + architecture: [x64] |
| 49 | + python_version: [3.7] |
| 50 | + steps: |
| 51 | + - name: setup Xcode version (macos) |
| 52 | + if: runner.os == 'macOS' |
| 53 | + run: sudo xcode-select -s /Applications/Xcode_${{ env.xcodeVersion }}.app/Contents/Developer |
| 54 | + |
| 55 | + - name: Store git credentials for all git commands |
| 56 | + # Forces all git commands to use authenticated https, to prevent throttling. |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + git config --global credential.helper 'store --file /tmp/git-credentials' |
| 60 | + echo 'https://${{ github.token }}@github.com' > /tmp/git-credentials |
| 61 | +
|
| 62 | + - name: Enable Git Long-paths Support |
| 63 | + if: runner.os == 'Windows' |
| 64 | + run: git config --system core.longpaths true |
| 65 | + |
| 66 | + - uses: actions/checkout@v2 |
| 67 | + with: |
| 68 | + submodules: true |
| 69 | + |
| 70 | + - name: Set env variables for subsequent steps (all) |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + echo "MATRIX_UNIQUE_NAME=${{ matrix.os }}-${{ matrix.architecture }}" >> $GITHUB_ENV |
| 74 | + echo "GHA_INSTALL_CCACHE=1" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + - name: Setup python |
| 77 | + uses: actions/setup-python@v2 |
| 78 | + with: |
| 79 | + python-version: ${{ matrix.python_version }} |
| 80 | + architecture: ${{ matrix.architecture }} |
| 81 | + |
| 82 | + - name: Add msbuild to PATH |
| 83 | + if: startsWith(matrix.os, 'windows') |
| 84 | + |
| 85 | + |
| 86 | + - name: Cache NDK |
| 87 | + id: cache_ndk |
| 88 | + uses: actions/cache@v2 |
| 89 | + with: |
| 90 | + path: /tmp/android-ndk-r21e |
| 91 | + key: android-ndk-${{ matrix.os }}-r21e |
| 92 | + |
| 93 | + - name: Check cached NDK |
| 94 | + shell: bash |
| 95 | + if: steps.cache_ndk.outputs.cache-hit != 'true' |
| 96 | + run: | |
| 97 | + # If the NDK failed to download from the cache, but there is a |
| 98 | + # /tmp/android-ndk-r21e directory, it's incomplete, so remove it. |
| 99 | + if [[ -d "/tmp/android-ndk-r21e" ]]; then |
| 100 | + echo "Removing incomplete download of NDK" |
| 101 | + rm -rf /tmp/android-ndk-r21e |
| 102 | + fi |
| 103 | +
|
| 104 | + - name: Update homebrew (avoid bintray errors) |
| 105 | + uses: nick-invision/retry@v2 |
| 106 | + if: startsWith(matrix.os, 'macos') |
| 107 | + with: |
| 108 | + timeout_minutes: 10 |
| 109 | + max_attempts: 3 |
| 110 | + command: | |
| 111 | + # Temporarily here until Github runners have updated their version of |
| 112 | + # homebrew. This prevents errors arising from the shut down of |
| 113 | + # binutils, used by older version of homebrew for hosting packages. |
| 114 | + brew update |
| 115 | +
|
| 116 | + - name: Install prerequisites |
| 117 | + uses: nick-invision/retry@v2 |
| 118 | + with: |
| 119 | + timeout_minutes: 10 |
| 120 | + max_attempts: 3 |
| 121 | + shell: bash |
| 122 | + command: | |
| 123 | + scripts/build_scripts/android/install_prereqs.sh |
| 124 | + echo "NDK_ROOT=/tmp/android-ndk-r21e" >> $GITHUB_ENV |
| 125 | + echo "ANDROID_NDK_HOME=/tmp/android-ndk-r21e" >> $GITHUB_ENV |
| 126 | + pip install -r scripts/build_scripts/python_requirements.txt |
| 127 | + python scripts/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}" |
| 128 | +
|
| 129 | + - name: Download C++ SDK |
| 130 | + shell: bash |
| 131 | + run: | |
| 132 | + set +e |
| 133 | + # Retry up to 10 times because Curl has a tendency to timeout on |
| 134 | + # Github runners. |
| 135 | + for retry in {1..10} error; do |
| 136 | + if [[ $retry == "error" ]]; then exit 5; fi |
| 137 | + curl -LSs \ |
| 138 | + "https://firebase.google.com/download/cpp" \ |
| 139 | + --output firebase_cpp_sdk.zip && break |
| 140 | + sleep 300 |
| 141 | + done |
| 142 | + set -e |
| 143 | + mkdir /tmp/downloaded_sdk |
| 144 | + unzip -q firebase_cpp_sdk.zip -d /tmp/downloaded_sdk/ |
| 145 | + rm -f firebase_cpp_sdk.zip |
| 146 | +
|
| 147 | + - name: Cache ccache files |
| 148 | + id: cache_ccache |
| 149 | + uses: actions/cache@v2 |
| 150 | + with: |
| 151 | + path: ccache_dir |
| 152 | + key: dev-test-ccache-${{ env.MATRIX_UNIQUE_NAME }} |
| 153 | + |
| 154 | + - name: Build testapp |
| 155 | + shell: bash |
| 156 | + run: | |
| 157 | + set -x |
| 158 | + python scripts/build_scripts/build_testapps.py --p Android \ |
| 159 | + --t ${{ needs.check_and_prepare.outputs.apis }} \ |
| 160 | + --output_directory "${{ github.workspace }}" \ |
| 161 | + --artifact_name "android-${{ matrix.os }}" \ |
| 162 | + --noadd_timestamp \ |
| 163 | + --short_output_paths \ |
| 164 | + --gha_build \ |
| 165 | + --packaged_sdk /tmp/downloaded_sdk/firebase_cpp_sdk |
| 166 | +
|
| 167 | + - name: Stats for ccache (mac and linux) |
| 168 | + if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') |
| 169 | + run: ccache -s |
| 170 | + |
| 171 | + - name: Prepare results summary artifact |
| 172 | + if: ${{ !cancelled() }} |
| 173 | + shell: bash |
| 174 | + run: | |
| 175 | + if [ ! -f build-results-android-${{ matrix.os }}.log.json ]; then |
| 176 | + echo "__SUMMARY_MISSING__" > build-results-android-${{ matrix.os }}.log.json |
| 177 | + fi |
| 178 | +
|
| 179 | + - name: Upload Android integration tests artifact |
| 180 | + uses: actions/upload-artifact@v3 |
| 181 | + if: ${{ !cancelled() }} |
| 182 | + with: |
| 183 | + name: testapps-android-${{ matrix.os }} |
| 184 | + path: testapps-android-${{ matrix.os }} |
| 185 | + retention-days: ${{ env.artifactRetentionDays }} |
| 186 | + |
| 187 | + - name: Upload Android build results artifact |
| 188 | + uses: actions/upload-artifact@v3 |
| 189 | + if: ${{ !cancelled() }} |
| 190 | + with: |
| 191 | + name: log-artifact |
| 192 | + path: build-results-android-${{ matrix.os }}* |
| 193 | + retention-days: ${{ env.artifactRetentionDays }} |
| 194 | + |
| 195 | + - name: Download log artifacts |
| 196 | + if: ${{ needs.check_and_prepare.outputs.pr_number && failure() && !cancelled() }} |
| 197 | + uses: actions/download-artifact@v3 |
| 198 | + with: |
| 199 | + path: test_results |
| 200 | + name: log-artifact |
| 201 | + |
| 202 | + - name: Summarize build results |
| 203 | + if: ${{ !cancelled() }} |
| 204 | + shell: bash |
| 205 | + run: | |
| 206 | + cat build-results-android-${{ matrix.os }}.log |
| 207 | + if [[ "${{ job.status }}" != "success" ]]; then |
| 208 | + exit 1 |
| 209 | + fi |
0 commit comments