Skip to content

Commit 2826738

Browse files
authored
Merge branch 'main' into daymon-sharedpreferences-work
2 parents 5c004c5 + a362e45 commit 2826738

File tree

59 files changed

+2180
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2180
-248
lines changed

.github/workflows/dataconnect.yml

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ jobs:
6464
with:
6565
node-version: ${{ env.FDC_NODEJS_VERSION }}
6666

67-
- name: install firebase-tools
67+
- name: Install Firebase Tools ("firebase" command-line tool)
6868
run: |
69+
set -euo pipefail
6970
set -v
7071
mkdir -p ${{ env.FDC_FIREBASE_TOOLS_DIR }}
7172
cd ${{ env.FDC_FIREBASE_TOOLS_DIR }}
7273
echo '{}' > package.json
7374
npm install --fund=false --audit=false --save --save-exact firebase-tools@${{ env.FDC_FIREBASE_TOOLS_VERSION }}
7475
75-
- name: Restore Gradle cache
76+
- name: Restore Gradle Cache
7677
id: restore-gradle-cache
7778
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
7879
if: github.event_name != 'schedule'
@@ -84,9 +85,11 @@ jobs:
8485
restore-keys: |
8586
gradle-cache-jqnvfzw6w7-
8687
87-
- name: tool versions
88+
- name: Print Command-Line Tool Versions
8889
continue-on-error: true
8990
run: |
91+
set -euo pipefail
92+
9093
function run_cmd {
9194
echo "==============================================================================="
9295
echo "Running Command: $*"
@@ -105,6 +108,7 @@ jobs:
105108
106109
- name: Gradle assembleDebugAndroidTest
107110
run: |
111+
set -euo pipefail
108112
set -v
109113
110114
# Speed up build times and also avoid configuring firebase-crashlytics-ndk
@@ -117,23 +121,24 @@ jobs:
117121
${{ (inputs.gradleInfoLog && '--info') || '' }} \
118122
:firebase-dataconnect:assembleDebugAndroidTest
119123
120-
- name: Save Gradle cache
124+
- name: Save Gradle Cache
121125
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
122126
if: github.event_name == 'schedule'
123127
with:
124128
path: |
125129
~/.gradle/caches
126130
~/.gradle/wrapper
127-
key: ${{ steps.restore-gradle-cache.outputs.cache-primary-key }}
131+
key: gradle-cache-jqnvfzw6w7-${{ github.run_id }}
128132

129-
- name: Enable KVM group permissions for Android Emulator
133+
- name: Enable KVM Group Permissions for Android Emulator
130134
run: |
135+
set -euo pipefail
131136
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
132137
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
133138
sudo udevadm control --reload-rules
134139
sudo udevadm trigger --name-match=kvm
135140
136-
- name: Restore AVD cache
141+
- name: Restore AVD Cache
137142
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
138143
if: github.event_name != 'schedule'
139144
id: restore-avd-cache
@@ -146,28 +151,30 @@ jobs:
146151
avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-
147152
148153
- name: Create AVD
149-
if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-hit != 'true'
154+
if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-matched-key == ''
150155
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0
151156
with:
152157
api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}
153158
arch: x86_64
154159
force-avd-creation: false
155160
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
156161
disable-animations: true
157-
script: echo "Generated AVD snapshot for caching."
162+
script: 'echo "Generated AVD snapshot for caching; event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}"'
158163

159-
- name: Save AVD cache
164+
- name: Save AVD Cache
160165
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
161166
if: github.event_name == 'schedule'
162167
with:
163168
path: |
164169
~/.android/avd/*
165170
~/.android/adb*
166-
key: ${{ steps.restore-avd-cache.outputs.cache-primary-key }}
171+
key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }}
167172

168-
- name: Data Connect Emulator
173+
- name: Data Connect Emulator Start
174+
id: data-connect-emulator
169175
run: |
170-
set -x
176+
set -euo pipefail
177+
set -xv
171178
172179
echo 'emulator.postgresConnectionUrl=postgresql://postgres:[email protected]:5432?sslmode=disable' > firebase-dataconnect/dataconnect.local.properties
173180
@@ -176,14 +183,29 @@ jobs:
176183
:firebase-dataconnect:connectors:runDebugDataConnectEmulator \
177184
>firebase.emulator.dataconnect.log 2>&1 &
178185
179-
- name: Firebase Auth Emulator
186+
echo "FIREBASE_DATA_CONNECT_EMULATOR_PID=$!" >> "$GITHUB_ENV"
187+
188+
- name: Firebase Auth Emulator Start
189+
id: firebase-auth-emulator
180190
run: |
181-
set -x
191+
set -euo pipefail
192+
set -xv
193+
182194
cd firebase-dataconnect/emulator
183195
${{ env.FDC_FIREBASE_COMMAND }} emulators:start --only=auth >firebase.emulator.auth.log 2>&1 &
184196
185-
- name: Capture Logcat Logs
186-
run: adb logcat >logcat.log &
197+
echo "FIREBASE_AUTH_EMULATOR_PID=$!" >> "$GITHUB_ENV"
198+
199+
- name: Logcat Log Capture Start
200+
id: logcat-capture
201+
continue-on-error: true
202+
run: |
203+
set -euo pipefail
204+
set -xv
205+
206+
"$ANDROID_HOME/platform-tools/adb" logcat >logcat.log 2>&1 &
207+
208+
echo "LOGCAT_PID=$!" >> "$GITHUB_ENV"
187209
188210
- name: Gradle connectedCheck
189211
id: connectedCheck
@@ -201,25 +223,26 @@ jobs:
201223
script: |
202224
set -eux && ./gradlew ${{ (inputs.gradleInfoLog && '--info') || '' }} :firebase-dataconnect:connectedCheck :firebase-dataconnect:connectors:connectedCheck
203225
204-
- name: Upload log file artifacts
226+
- name: Upload Log Files
205227
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
206228
with:
207229
name: integration_test_logs
208230
path: "**/*.log"
209231
if-no-files-found: warn
210232
compression-level: 9
211233

212-
- name: Upload Gradle build report artifacts
234+
- name: Upload Gradle Build Reports
213235
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
214236
with:
215237
name: integration_test_gradle_build_reports
216238
path: firebase-dataconnect/**/build/reports/
217239
if-no-files-found: warn
218240
compression-level: 9
219241

220-
- name: Verify "Gradle connectedCheck" step was successful
242+
- name: Verify "Gradle connectedCheck" Step Was Successful
221243
if: steps.connectedCheck.outcome != 'success'
222244
run: |
245+
set -euo pipefail
223246
echo 'Failing because the outcome of the "Gradle connectedCheck" step ("${{ steps.connectedCheck.outcome }}") was not successful'
224247
exit 1
225248
@@ -236,3 +259,27 @@ jobs:
236259
- uses: docker://rhysd/actionlint:1.7.7
237260
with:
238261
args: -color /github/workspace/.github/workflows/dataconnect.yml
262+
263+
send-notifications:
264+
needs: [integration-test, actionlint-dataconnect-yml]
265+
if: always()
266+
permissions:
267+
issues: write
268+
runs-on: ubuntu-latest
269+
steps:
270+
- name: Post Comment on Issue #6857
271+
if: github.event_name == 'schedule'
272+
env:
273+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274+
run: |
275+
set -euo pipefail
276+
277+
cat >message.txt <<EOF
278+
Result of workflow ${{ github.workflow }} at ${{ github.ref }}: ${{ job.status }}
279+
${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
280+
job=${{ github.job }} run_id=${{ github.run_id }} run_number=${{ github.run_number }} run_attempt=${{ github.run_attempt }}
281+
EOF
282+
283+
echo "Posting comment on GitHub Issue: https://github.com/firebase/firebase-android-sdk/issues/6857:"
284+
cat message.txt
285+
gh issue comment 6857 --body-file message.txt -R ${{ github.repository }}

.github/workflows/fireci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- run: |
2525
pytest ci/fireci
2626
- run: |
27-
mypy --config-file ci/fireci/setup.cfg ci/fireci/
27+
mypy --config-file ci/fireci/pyproject.toml ci/fireci/

ci/fireci/pyproject.toml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
11
[build-system]
2-
requires = ["setuptools ~= 58.0"]
2+
requires = ["setuptools ~= 70.0"]
33
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "fireci"
7+
version = "0.1"
8+
dependencies = [
9+
"protobuf==3.20.3",
10+
"click==8.1.7",
11+
"google-cloud-storage==2.18.2",
12+
"mypy==1.6.0",
13+
"numpy==1.24.4",
14+
"pandas==1.5.3",
15+
"PyGithub==1.58.2",
16+
"pystache==0.6.0",
17+
"requests==2.31.0",
18+
"seaborn==0.12.2",
19+
"PyYAML==6.0.1",
20+
"termcolor==2.4.0",
21+
"pytest"
22+
]
23+
24+
[project.scripts]
25+
fireci = "fireci.main:cli"
26+
27+
[tool.setuptools]
28+
packages = ["fireci", "fireciplugins"]
29+
30+
[tool.mypy]
31+
strict_optional = false
32+
33+
[[tool.mypy.overrides]]
34+
module = [
35+
"google.cloud",
36+
"matplotlib",
37+
"matplotlib.pyplot",
38+
"pandas",
39+
"pystache",
40+
"requests",
41+
"seaborn",
42+
"yaml"
43+
]
44+
ignore_missing_imports = true

ci/fireci/setup.cfg

Lines changed: 0 additions & 45 deletions
This file was deleted.

ci/run.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
# limitations under the License.
1616

1717
set -e
18+
set -x
1819

1920
DIRECTORY=$(cd `dirname $0` && pwd)
20-
pip3 install -e $DIRECTORY/fireci >> /dev/null
21+
python3 -m ensurepip --upgrade
22+
python3 -m pip install --upgrade setuptools
23+
python3 -m pip install --upgrade pip
24+
python3 -m pip install --upgrade wheel
25+
python3 -m pip install -e $DIRECTORY/fireci >> /dev/null
2126
fireci $@

encoders/protoc-gen-firebase-encoders/src/main/kotlin/com/google/firebase/encoders/proto/codegen/Types.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ data class ProtoField(
190190

191191
val lowerCamelCaseName: String
192192
get() {
193-
return SNAKE_CASE_REGEX.replace(name) { it.value.replace("_", "").toUpperCase() }
193+
return SNAKE_CASE_REGEX.replace(name) { it.value.replace("_", "").uppercase() }
194194
}
195195

196196
val camelCaseName: String

firebase-config/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
2-
2+
[fixed] Fixed an issue where the connection to the real-time Remote Config backend could remain
3+
open in the background.
34

45
# 22.1.0
56
* [feature] Added support for custom signal targeting in Remote Config. Use `setCustomSignals` API for setting custom signals and use them to build custom targeting conditions in Remote Config.

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigAutoFetch.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class ConfigAutoFetch {
5454
private final ConfigUpdateListener retryCallback;
5555
private final ScheduledExecutorService scheduledExecutorService;
5656
private final Random random;
57+
private boolean isInBackground;
5758

5859
public ConfigAutoFetch(
5960
HttpURLConnection httpURLConnection,
@@ -69,6 +70,7 @@ public ConfigAutoFetch(
6970
this.retryCallback = retryCallback;
7071
this.scheduledExecutorService = scheduledExecutorService;
7172
this.random = new Random();
73+
this.isInBackground = false;
7274
}
7375

7476
private synchronized void propagateErrors(FirebaseRemoteConfigException exception) {
@@ -87,6 +89,10 @@ private synchronized boolean isEventListenersEmpty() {
8789
return this.eventListeners.isEmpty();
8890
}
8991

92+
public void setIsInBackground(boolean isInBackground) {
93+
this.isInBackground = isInBackground;
94+
}
95+
9096
private String parseAndValidateConfigUpdateMessage(String message) {
9197
int left = message.indexOf('{');
9298
int right = message.lastIndexOf('}');
@@ -105,15 +111,29 @@ public void listenForNotifications() {
105111
return;
106112
}
107113

114+
// Maintain a reference to the InputStream to guarantee its closure upon completion or in case
115+
// of an exception.
116+
InputStream inputStream = null;
108117
try {
109-
InputStream inputStream = httpURLConnection.getInputStream();
118+
inputStream = httpURLConnection.getInputStream();
110119
handleNotifications(inputStream);
111-
inputStream.close();
112120
} catch (IOException ex) {
113-
// Stream was interrupted due to a transient issue and the system will retry the connection.
114-
Log.d(TAG, "Stream was cancelled due to an exception. Retrying the connection...", ex);
121+
// If the real-time connection is at an unexpected lifecycle state when the app is
122+
// backgrounded, it's expected closing the httpURLConnection will throw an exception.
123+
if (!isInBackground) {
124+
// Otherwise, the real-time server connection was closed due to a transient issue.
125+
Log.d(TAG, "Real-time connection was closed due to an exception.", ex);
126+
}
115127
} finally {
116-
httpURLConnection.disconnect();
128+
if (inputStream != null) {
129+
try {
130+
// Only need to close the InputStream, ConfigRealtimeHttpClient will disconnect
131+
// HttpUrlConnection
132+
inputStream.close();
133+
} catch (IOException ex) {
134+
Log.d(TAG, "Exception thrown when closing connection stream. Retrying connection...", ex);
135+
}
136+
}
117137
}
118138
}
119139

@@ -186,7 +206,6 @@ private void handleNotifications(InputStream inputStream) throws IOException {
186206
}
187207

188208
reader.close();
189-
inputStream.close();
190209
}
191210

192211
private void autoFetch(int remainingAttempts, long targetVersion) {

0 commit comments

Comments
 (0)