-
Notifications
You must be signed in to change notification settings - Fork 128
214 lines (189 loc) · 7.25 KB
/
android.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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.12]
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@v5
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.architecture }}
- uses: actions/setup-java@v4
with:
java-version: 11
distribution: temurin
- name: Add msbuild to PATH
if: startsWith(matrix.os, 'windows')
uses: microsoft/[email protected]
- 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