Skip to content

Commit d26a5f8

Browse files
authored
Run Firestore CI from Android Emulator instead (#6094)
Run Firestore Integration tests from Android Emulator, this brings down the tests runtime to around 10 minutes from 40. There are several changes in this PR: 1. Take firestore out of ci_tests.yml. 2. Create firestore_ci_tests.yml so that other SDKs do not have to setup emulators. 3. Revert #6057. This PR is causing failures like: https://github.com/firebase/firebase-android-sdk/actions/runs/9910054539/job/27379655403?pr=6094 after we switch to emulator, may be related to its more concurrent nature. 4. Commented out a test that fails on CI.
1 parent 515ab8f commit d26a5f8

29 files changed

+434
-292
lines changed

.github/workflows/ci_tests.yml

Lines changed: 2 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ jobs:
112112
fail-fast: false
113113
matrix:
114114
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
115+
exclude:
116+
- module: :firebase-firestore
115117

116118
steps:
117119
- uses: actions/[email protected]
@@ -144,119 +146,6 @@ jobs:
144146
run: |
145147
./gradlew ${{matrix.module}}:deviceCheck withErrorProne -PtargetBackend="prod"
146148
147-
firestore_custom_integ_tests:
148-
name: "Firestore Custom Instrumentation Tests Against Named DB"
149-
runs-on: ubuntu-22.04
150-
needs:
151-
- determine_changed
152-
# only run on post submit or PRs not originating from forks.
153-
if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore')
154-
strategy:
155-
fail-fast: false
156-
157-
steps:
158-
- uses: actions/[email protected]
159-
with:
160-
fetch-depth: 2
161-
submodules: true
162-
163-
- name: Set up JDK 17
164-
uses: actions/[email protected]
165-
with:
166-
java-version: 17
167-
distribution: temurin
168-
cache: gradle
169-
170-
- name: Add google-services.json
171-
env:
172-
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
173-
run: |
174-
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
175-
- uses: google-github-actions/auth@v2
176-
with:
177-
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
178-
- uses: google-github-actions/setup-gcloud@v2
179-
180-
# create composite indexes with Terraform
181-
- name: Setup Terraform
182-
uses: hashicorp/setup-terraform@v2
183-
- name: Terraform Init
184-
run: |
185-
cd firebase-firestore
186-
terraform init
187-
continue-on-error: true
188-
- name: Terraform Apply
189-
if: github.event_name == 'pull_request'
190-
run: |
191-
cd firebase-firestore
192-
193-
# Define a temporary file, redirect both stdout and stderr to the file
194-
output_file=$(mktemp)
195-
if ! terraform apply -var-file=../google-services.json -auto-approve > "$output_file" 2>&1 ; then
196-
cat "$output_file"
197-
if cat "$output_file" | grep -q "index already exists"; then
198-
echo "==================================================================================="
199-
echo -e "\e[93m\e[1mTerraform apply failed due to index already exists; We can safely ignore this error.\e[0m"
200-
echo "==================================================================================="
201-
fi
202-
exit 1
203-
fi
204-
rm -f "$output_file"
205-
continue-on-error: true
206-
207-
- name: Firestore Named DB Integ Tests
208-
env:
209-
FIREBASE_CI: 1
210-
FTL_RESULTS_BUCKET: android-ci
211-
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
212-
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
213-
run: |
214-
./gradlew firebase-firestore:deviceCheck withErrorProne -PtargetBackend="prod" -PtargetDatabaseId="test-db"
215-
216-
217-
firestore_nightly_integ_tests:
218-
name: "Firestore Instrumentation Tests Against Nightly Environment"
219-
runs-on: ubuntu-22.04
220-
needs:
221-
- determine_changed
222-
# only run on post submit or PRs not originating from forks.
223-
if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore')
224-
strategy:
225-
fail-fast: false
226-
227-
steps:
228-
- uses: actions/[email protected]
229-
with:
230-
fetch-depth: 2
231-
submodules: true
232-
233-
- name: Set up JDK 17
234-
uses: actions/[email protected]
235-
with:
236-
java-version: 17
237-
distribution: temurin
238-
cache: gradle
239-
240-
- name: Add google-services.json
241-
env:
242-
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.NIGHTLY_INTEG_TESTS_GOOGLE_SERVICES }}
243-
run: |
244-
echo $INTEG_TESTS_GOOGLE_SERVICES > google-services.json
245-
- uses: google-github-actions/auth@v2
246-
with:
247-
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
248-
- uses: google-github-actions/setup-gcloud@v2
249-
250-
- name: Firestore Nightly Integ Tests
251-
env:
252-
FIREBASE_CI: 1
253-
FTL_RESULTS_BUCKET: android-ci
254-
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
255-
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
256-
run: |
257-
./gradlew firebase-firestore:deviceCheck withErrorProne -PtargetBackend="nightly"
258-
259-
260149
publish-test-results:
261150
name: "Publish Tests Results"
262151
needs:
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
name: Firestore CI Tests
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
determine_changed:
13+
name: "Determine changed modules"
14+
runs-on: ubuntu-latest
15+
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request'
16+
outputs:
17+
modules: ${{ steps.changed-modules.outputs.modules }}
18+
steps:
19+
- uses: actions/[email protected]
20+
with:
21+
fetch-depth: 2
22+
submodules: true
23+
24+
- name: Set up JDK 17
25+
uses: actions/[email protected]
26+
with:
27+
java-version: 17
28+
distribution: temurin
29+
cache: gradle
30+
31+
- id: changed-modules
32+
run: |
33+
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json
34+
echo modules=$(cat modules.json) >> $GITHUB_OUTPUT
35+
36+
integ_tests:
37+
name: "System Tests"
38+
# only run on post submit or PRs not originating from forks.
39+
if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore')
40+
runs-on: ubuntu-latest
41+
needs:
42+
- determine_changed
43+
strategy:
44+
fail-fast: false
45+
46+
steps:
47+
- uses: actions/[email protected]
48+
with:
49+
fetch-depth: 2
50+
submodules: true
51+
52+
- name: Enable KVM
53+
run: |
54+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
55+
sudo udevadm control --reload-rules
56+
sudo udevadm trigger --name-match=kvm
57+
58+
- name: Set up JDK 17
59+
uses: actions/[email protected]
60+
with:
61+
java-version: 17
62+
distribution: temurin
63+
cache: gradle
64+
65+
- name: Add google-services.json
66+
env:
67+
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
68+
run: |
69+
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
70+
- uses: google-github-actions/auth@v2
71+
with:
72+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
73+
- uses: google-github-actions/setup-gcloud@v2
74+
- name: firebase-firestore Integ Tests
75+
uses: reactivecircus/android-emulator-runner@v2
76+
env:
77+
FIREBASE_CI: 1
78+
FTL_RESULTS_BUCKET: android-ci
79+
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
80+
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
81+
with:
82+
api-level: 31
83+
arch: x86_64
84+
ram-size: 4096M
85+
heap-size: 4096M
86+
script: |
87+
adb logcat -v time > logcat.txt &
88+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod"
89+
- name: Upload logs
90+
if: failure()
91+
uses: actions/[email protected]
92+
with:
93+
name: logcat.txt
94+
path: logcat.txt
95+
retention-days: 7
96+
if-no-files-found: ignore
97+
98+
99+
named_integ_tests:
100+
name: "System Tests With Named DB"
101+
runs-on: ubuntu-latest
102+
needs:
103+
- determine_changed
104+
# only run on post submit or PRs not originating from forks.
105+
if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore')
106+
strategy:
107+
fail-fast: false
108+
109+
steps:
110+
- uses: actions/[email protected]
111+
with:
112+
fetch-depth: 2
113+
submodules: true
114+
115+
- name: Enable KVM
116+
run: |
117+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
118+
sudo udevadm control --reload-rules
119+
sudo udevadm trigger --name-match=kvm
120+
121+
- name: Set up JDK 17
122+
uses: actions/[email protected]
123+
with:
124+
java-version: 17
125+
distribution: temurin
126+
cache: gradle
127+
128+
- name: Add google-services.json
129+
env:
130+
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
131+
run: |
132+
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
133+
- uses: google-github-actions/auth@v2
134+
with:
135+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
136+
- uses: google-github-actions/setup-gcloud@v2
137+
138+
# create composite indexes with Terraform
139+
- name: Setup Terraform
140+
uses: hashicorp/setup-terraform@v2
141+
- name: Terraform Init
142+
run: |
143+
cd firebase-firestore
144+
terraform init
145+
continue-on-error: true
146+
- name: Terraform Apply
147+
if: github.event_name == 'pull_request'
148+
run: |
149+
cd firebase-firestore
150+
151+
# Define a temporary file, redirect both stdout and stderr to the file
152+
output_file=$(mktemp)
153+
if ! terraform apply -var-file=../google-services.json -auto-approve > "$output_file" 2>&1 ; then
154+
cat "$output_file"
155+
if cat "$output_file" | grep -q "index already exists"; then
156+
echo "==================================================================================="
157+
echo -e "\e[93m\e[1mTerraform apply failed due to index already exists; We can safely ignore this error.\e[0m"
158+
echo "==================================================================================="
159+
fi
160+
exit 1
161+
fi
162+
rm -f "$output_file"
163+
continue-on-error: true
164+
165+
- name: Firestore Named DB Integ Tests
166+
timeout-minutes: 20
167+
uses: reactivecircus/android-emulator-runner@v2
168+
env:
169+
FIREBASE_CI: 1
170+
FTL_RESULTS_BUCKET: android-ci
171+
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
172+
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
173+
with:
174+
api-level: 31
175+
arch: x86_64
176+
ram-size: 4096M
177+
heap-size: 4096M
178+
script: |
179+
adb logcat -v time > logcat.txt &
180+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod"
181+
- name: Upload logs
182+
if: failure()
183+
uses: actions/[email protected]
184+
with:
185+
name: named-db-logcat.txt
186+
path: logcat.txt
187+
retention-days: 7
188+
if-no-files-found: ignore
189+
190+
firestore_nightly_integ_tests:
191+
name: "System Tests Against Nightly"
192+
runs-on: ubuntu-latest
193+
needs:
194+
- determine_changed
195+
# only run on post submit or PRs not originating from forks.
196+
if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore')
197+
strategy:
198+
fail-fast: false
199+
200+
steps:
201+
- uses: actions/[email protected]
202+
with:
203+
fetch-depth: 2
204+
submodules: true
205+
206+
- name: Enable KVM
207+
run: |
208+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
209+
sudo udevadm control --reload-rules
210+
sudo udevadm trigger --name-match=kvm
211+
212+
- name: Set up JDK 17
213+
uses: actions/[email protected]
214+
with:
215+
java-version: 17
216+
distribution: temurin
217+
cache: gradle
218+
219+
- name: Add google-services.json
220+
env:
221+
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.NIGHTLY_INTEG_TESTS_GOOGLE_SERVICES }}
222+
run: |
223+
echo $INTEG_TESTS_GOOGLE_SERVICES > google-services.json
224+
- uses: google-github-actions/auth@v2
225+
with:
226+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
227+
- uses: google-github-actions/setup-gcloud@v2
228+
229+
- name: Firestore Nightly Integ Tests
230+
uses: reactivecircus/android-emulator-runner@v2
231+
env:
232+
FIREBASE_CI: 1
233+
FTL_RESULTS_BUCKET: android-ci
234+
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
235+
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
236+
with:
237+
api-level: 31
238+
arch: x86_64
239+
ram-size: 4096M
240+
heap-size: 4096M
241+
script: |
242+
adb logcat -v time > logcat.txt &
243+
./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="nightly"
244+
- name: Upload logs
245+
if: failure()
246+
uses: actions/[email protected]
247+
with:
248+
name: nightly-logcat.txt
249+
path: logcat.txt
250+
retention-days: 7
251+
if-no-files-found: ignore
252+
253+
check-required-tests:
254+
runs-on: ubuntu-latest
255+
if: always()
256+
name: Check all required Firestore tests results
257+
needs: [integ_tests, named_integ_tests]
258+
steps:
259+
- name: Check test matrix
260+
if: needs.integ_tests.result == 'failure' || needs.named_integ_tests.result == 'failure'
261+
run: exit 1

0 commit comments

Comments
 (0)