Skip to content

Commit 377edcc

Browse files
authored
dataconnect: integration tests added to github actions workflows (#6638)
1 parent cf5fe2e commit 377edcc

File tree

3 files changed

+218
-3
lines changed

3 files changed

+218
-3
lines changed

.github/workflows/dataconnect.yml

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: Data Connect Integration Tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
javaVersion:
7+
androidEmulatorApiLevel:
8+
nodeJsVersion:
9+
firebaseToolsVersion:
10+
gradleInfoLog:
11+
type: boolean
12+
pull_request:
13+
paths:
14+
- .github/workflows/dataconnect.yml
15+
- 'firebase-dataconnect/**'
16+
- '!firebase-dataconnect/demo/**'
17+
- '!firebase-dataconnect/scripts/**'
18+
- '!firebase-dataconnect/**/*.md'
19+
- '!firebase-dataconnect/**/*.txt'
20+
schedule:
21+
- cron: '0 11 * * *' # Run nightly at 11am UTC (3am Pacific, 6am Eastern)
22+
23+
env:
24+
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
25+
FDC_ANDROID_EMULATOR_API_LEVEL: ${{ inputs.androidEmulatorApiLevel || '34' }}
26+
FDC_NODEJS_VERSION: ${{ inputs.nodeJsVersion || '20' }}
27+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '13.29.1' }}
28+
FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools
29+
FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
integration-test:
37+
continue-on-error: false
38+
runs-on: ubuntu-latest
39+
40+
services:
41+
postgres:
42+
image: postgres
43+
env:
44+
POSTGRES_PASSWORD: password
45+
options: >-
46+
--health-cmd pg_isready
47+
--health-interval 10s
48+
--health-timeout 5s
49+
--health-retries 5
50+
ports:
51+
- 5432:5432
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
show-progress: false
57+
58+
- uses: actions/setup-java@v4
59+
with:
60+
java-version: ${{ env.FDC_JAVA_VERSION }}
61+
distribution: temurin
62+
63+
- uses: actions/setup-node@v4
64+
with:
65+
node-version: ${{ env.FDC_NODEJS_VERSION }}
66+
67+
- name: install firebase-tools
68+
run: |
69+
set -v
70+
mkdir -p ${{ env.FDC_FIREBASE_TOOLS_DIR }}
71+
cd ${{ env.FDC_FIREBASE_TOOLS_DIR }}
72+
echo '{}' > package.json
73+
npm install --fund=false --audit=false --save --save-exact firebase-tools@${{ env.FDC_FIREBASE_TOOLS_VERSION }}
74+
75+
- name: Restore Gradle cache
76+
uses: actions/cache/restore@v4
77+
if: github.event_name != 'schedule'
78+
with:
79+
path: |
80+
~/.gradle/caches
81+
~/.gradle/wrapper
82+
key: gradle-cache-jqnvfzw6w7
83+
84+
- name: tool versions
85+
continue-on-error: true
86+
run: |
87+
set +e -v
88+
uname -a
89+
which java
90+
java -version
91+
which javac
92+
javac -version
93+
which node
94+
node --version
95+
${{ env.FDC_FIREBASE_COMMAND }} --version
96+
./gradlew --version
97+
98+
- name: Gradle assembleDebugAndroidTest
99+
run: |
100+
set -v
101+
102+
# Speed up build times and also avoid configuring firebase-crashlytics-ndk
103+
# which is finicky integrating with the Android NDK.
104+
echo >> gradle.properties
105+
echo "org.gradle.configureondemand=true" >> gradle.properties
106+
107+
./gradlew \
108+
--profile \
109+
${{ (inputs.gradleInfoLog && '--info') || '' }} \
110+
:firebase-dataconnect:assembleDebugAndroidTest
111+
112+
- name: Save Gradle cache
113+
uses: actions/cache/save@v4
114+
if: github.event_name == 'schedule'
115+
with:
116+
path: |
117+
~/.gradle/caches
118+
~/.gradle/wrapper
119+
key: gradle-cache-jqnvfzw6w7
120+
121+
- name: Enable KVM group permissions for Android Emulator
122+
run: |
123+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
124+
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
125+
sudo udevadm control --reload-rules
126+
sudo udevadm trigger --name-match=kvm
127+
128+
- name: Restore AVD cache
129+
uses: actions/cache/restore@v4
130+
if: github.event_name != 'schedule'
131+
id: avd-cache
132+
with:
133+
path: |
134+
~/.android/avd/*
135+
~/.android/adb*
136+
key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}
137+
138+
- run: echo "github.event_name == '${{ github.event_name }}' steps.avd-cache.outputs.cache-hit == '${{ steps.avd-cache.outputs.cache-hit }}'"
139+
140+
- name: Create AVD
141+
if: github.event_name == 'schedule' || steps.avd-cache.outputs.cache-hit != 'true'
142+
uses: reactivecircus/android-emulator-runner@v2
143+
with:
144+
api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}
145+
arch: x86_64
146+
force-avd-creation: false
147+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
148+
disable-animations: false
149+
script: echo "Generated AVD snapshot for caching."
150+
151+
- name: Save AVD cache
152+
uses: actions/cache/save@v4
153+
if: github.event_name == 'schedule'
154+
with:
155+
path: |
156+
~/.android/avd/*
157+
~/.android/adb*
158+
key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}
159+
160+
- name: Data Connect Emulator
161+
run: |
162+
set -x
163+
164+
echo 'emulator.postgresConnectionUrl=postgresql://postgres:[email protected]:5432?sslmode=disable' > firebase-dataconnect/dataconnect.local.properties
165+
166+
./gradlew \
167+
${{ (inputs.gradleInfoLog && '--info') || '' }} \
168+
:firebase-dataconnect:connectors:runDebugDataConnectEmulator \
169+
>firebase.emulator.dataconnect.log 2>&1 &
170+
171+
- name: Firebase Auth Emulator
172+
run: |
173+
set -x
174+
cd firebase-dataconnect/emulator
175+
${{ env.FDC_FIREBASE_COMMAND }} emulators:start --only=auth >firebase.emulator.auth.log 2>&1 &
176+
177+
- name: Gradle connectedCheck
178+
uses: reactivecircus/android-emulator-runner@v2
179+
with:
180+
api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}
181+
arch: x86_64
182+
force-avd-creation: false
183+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
184+
disable-animations: true
185+
script: |
186+
set -eux && ./gradlew ${{ (inputs.gradleInfoLog && '--info') || '' }} :firebase-dataconnect:connectedCheck :firebase-dataconnect:connectors:connectedCheck
187+
188+
- uses: actions/upload-artifact@v4
189+
if: true
190+
with:
191+
name: logs
192+
path: "**/*.log"
193+
if-no-files-found: warn
194+
compression-level: 9
195+
196+
- uses: actions/upload-artifact@v4
197+
with:
198+
name: gradle_build_reports
199+
path: firebase-dataconnect/**/build/reports/
200+
if-no-files-found: warn
201+
compression-level: 9
202+
203+
# Check this yml file with "actionlint": https://github.com/rhysd/actionlint
204+
# To run actionlint yourself, run `brew install actionlint` followed by
205+
# `actionlint .github/workflows/dataconnect.yml`
206+
actionlint-dataconnect-yml:
207+
continue-on-error: false
208+
runs-on: ubuntu-latest
209+
steps:
210+
- uses: actions/checkout@v4
211+
with:
212+
show-progress: false
213+
- uses: docker://rhysd/actionlint:1.7.7
214+
with:
215+
args: -color /github/workspace/.github/workflows/dataconnect.yml

firebase-dataconnect/src/androidTest/kotlin/com/google/firebase/dataconnect/QueryRefIntegrationTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import io.kotest.matchers.shouldBe
3131
import io.kotest.matchers.types.shouldBeInstanceOf
3232
import io.kotest.property.Arb
3333
import io.kotest.property.arbitrary.next
34-
import kotlin.time.Duration.Companion.seconds
34+
import kotlin.time.Duration.Companion.minutes
3535
import kotlinx.coroutines.Dispatchers
3636
import kotlinx.coroutines.async
3737
import kotlinx.coroutines.test.runTest
@@ -388,7 +388,7 @@ class QueryRefIntegrationTest : DataConnectIntegrationTestBase() {
388388

389389
@Test
390390
fun executeShouldSupportMassiveConcurrency() =
391-
runTest(timeout = 60.seconds) {
391+
runTest(timeout = 5.minutes) {
392392
val latch = SuspendingCountDownLatch(25_000)
393393
val query = personSchema.getPerson(id = "foo")
394394

firebase-dataconnect/src/androidTest/kotlin/com/google/firebase/dataconnect/QuerySubscriptionIntegrationTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class QuerySubscriptionIntegrationTest : DataConnectIntegrationTestBase() {
303303
.toList()
304304

305305
assertSoftly {
306-
withClue("results.size") { results.size shouldBeInRange 1..2000 }
306+
withClue("results.size") { results.size shouldBeInRange 1..5000 }
307307
results.forEachIndexed { i, result ->
308308
withClue("results[$i]") { result.shouldHavePersonWithName("NewName") }
309309
}

0 commit comments

Comments
 (0)