Skip to content

Commit 31623d7

Browse files
Merge master into release
2 parents 03337aa + 309f7a9 commit 31623d7

File tree

20 files changed

+464
-779
lines changed

20 files changed

+464
-779
lines changed

.changeset/eleven-lamps-give.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/auth': minor
3+
'firebase': minor
4+
---
5+
6+
Remove dependency on @react-native-async-storage/async-storage and add warnings to remind React Native users to manually import it.

.changeset/nervous-cups-relax.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@firebase/firestore": patch
3+
"@firebase/webchannel-wrapper": patch
4+
---
5+
6+
Fix how we enable fetch streams.

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#######################################################################################################
99

1010
# These owners will be the default owners for everything in the repo.
11-
* @dwyfrequency @hsubox76 @firebase/jssdk-global-approvers
11+
* @firebase/jssdk-global-approvers
1212

1313
# Database Code
1414
packages/database @maneesht @jsdt @jmwski @firebase/jssdk-global-approvers
@@ -74,4 +74,4 @@ scripts/docgen/content-sources/ @egilmorez @firebase/jssdk-global-approvers
7474
docs-devsite/ @egilmorez @markarndt @kevinthecheung
7575

7676
# Changeset
77-
.changeset @firebase/jssdk-changeset-approvers @firebase/firestore-js-team @firebase/jssdk-global-approvers
77+
.changeset @firebase/jssdk-changeset-approvers @firebase/firestore-js-team @firebase/jssdk-global-approvers

.github/workflows/test-all.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ jobs:
186186
continue-on-error: true
187187

188188
test-firestore-integration:
189-
name: Firestore Integration Tests
189+
strategy:
190+
fail-fast: false
191+
matrix:
192+
persistence: ['memory', 'persistence']
193+
name: Firestore Integration Tests (${{ matrix.persistence }})
190194
needs: build
191195
runs-on: ubuntu-latest
192196
steps:
@@ -207,15 +211,11 @@ jobs:
207211
node-version: 16.x
208212
- name: Bump Node memory limit
209213
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
210-
- name: Test setup and yarn install
211-
run: |
212-
cp config/ci.config.json config/project.json
213-
yarn
214-
- name: Set start timestamp env var
215-
run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV
216-
- name: Run unit tests
217-
run: |
218-
xvfb-run yarn lerna run --concurrency 4 test:ci --scope firebase-firestore-integration-test
219-
node scripts/print_test_logs.js
214+
- run: cp config/ci.config.json config/project.json
215+
- run: yarn
216+
- run: yarn build:${{ matrix.persistence }}
217+
working-directory: integration/firestore
218+
- run: xvfb-run yarn karma:singlerun
219+
working-directory: integration/firestore
220220
env:
221221
FIREBASE_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}

.github/workflows/test-changed-firestore.yml

Lines changed: 150 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: Test Firestore
22

33
on: pull_request
44

5+
env:
6+
artifactRetentionDays: 14
7+
58
jobs:
6-
test-chrome:
7-
name: Test Firestore on Chrome and Node If Changed
9+
build:
10+
name: Build Firestore
11+
812
runs-on: ubuntu-latest
13+
outputs:
14+
changed: ${{ steps.set-output.outputs.CHANGED }}
915

1016
steps:
1117
- name: Checkout Repo
@@ -28,40 +34,166 @@ jobs:
2834
cp config/ci.config.json config/project.json
2935
yarn
3036
- name: build
31-
run: yarn build:changed firestore
32-
- name: Run tests if firestore or its dependencies has changed
33-
run: yarn test:changed firestore
37+
id: build
38+
run: |
39+
set -o pipefail
40+
yarn build:changed firestore | tee ${{ runner.temp }}/yarn.log.txt
41+
continue-on-error: false
42+
- name: Check if Firestore is changed
43+
id: check-changed
44+
run: egrep "Skipping all" ${{ runner.temp }}/yarn.log.txt
45+
# Continue when "Skipping all" is not found
46+
continue-on-error: true
47+
- name: set output
48+
# This means "Skipping all" was not found
49+
if: steps.check-changed.outcome != 'success'
50+
id: set-output
51+
run: echo "CHANGED=true" >> "$GITHUB_OUTPUT";
52+
- name: Archive build
53+
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
54+
run: |
55+
tar -cf build.tar --exclude=.git .
56+
gzip build.tar
57+
- name: Upload build archive
58+
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
59+
uses: actions/upload-artifact@v3
60+
with:
61+
name: build.tar.gz
62+
path: build.tar.gz
63+
retention-days: ${{ env.artifactRetentionDays }}
3464

35-
test-firefox:
36-
name: Test Firestore on Firefox If Changed
65+
compat-test-chrome:
66+
name: Test Firestore Compatible
67+
runs-on: ubuntu-latest
68+
needs: build
69+
if: ${{ needs.build.outputs.changed == 'true'}}
70+
steps:
71+
- name: Set up Node (14)
72+
uses: actions/setup-node@v3
73+
with:
74+
node-version: 14.x
75+
- name: install Chrome stable
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install google-chrome-stable
79+
- name: Download build archive
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: build.tar.gz
83+
- name: Unzip build artifact
84+
run: tar xf build.tar.gz
85+
- name: Bump Node memory limit
86+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
87+
- name: Test setup and yarn install
88+
run: cp config/ci.config.json config/project.json
89+
- name: Run compat tests
90+
run: cd packages/firestore-compat && yarn run test:ci
91+
92+
test-chrome:
93+
name: Test Firestore
94+
strategy:
95+
matrix:
96+
test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
97+
runs-on: ubuntu-latest
98+
needs: build
99+
if: ${{ needs.build.outputs.changed == 'true'}}
100+
steps:
101+
- name: Set up Node (14)
102+
uses: actions/setup-node@v3
103+
with:
104+
node-version: 14.x
105+
- name: install Chrome stable
106+
run: |
107+
sudo apt-get update
108+
sudo apt-get install google-chrome-stable
109+
- name: Download build archive
110+
uses: actions/download-artifact@v3
111+
with:
112+
name: build.tar.gz
113+
- name: Unzip build artifact
114+
run: tar xf build.tar.gz
115+
- name: Bump Node memory limit
116+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
117+
- name: Test setup and yarn install
118+
run: cp config/ci.config.json config/project.json
119+
- name: Run tests
120+
run: cd packages/firestore && yarn run ${{ matrix.test-name }}
121+
122+
compat-test-firefox:
123+
name: Test Firestore Compatible on Firefox
37124
# Whatever version of Firefox comes with 22.04 is causing Firefox
38125
# startup to hang when launched by karma. Need to look further into
39126
# why.
40127
runs-on: ubuntu-20.04
128+
needs: build
129+
if: ${{ needs.build.outputs.changed == 'true'}}
130+
steps:
131+
- name: install Firefox stable
132+
run: |
133+
sudo apt-get update
134+
sudo apt-get install firefox
135+
- name: Set up Node (14)
136+
uses: actions/setup-node@v3
137+
with:
138+
node-version: 14.x
139+
- name: Download build archive
140+
uses: actions/download-artifact@v3
141+
with:
142+
name: build.tar.gz
143+
- name: Unzip build artifact
144+
run: tar xf build.tar.gz
145+
- name: Bump Node memory limit
146+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
147+
- name: Test setup and yarn install
148+
run: cp config/ci.config.json config/project.json
149+
- name: Run compat tests
150+
run: cd packages/firestore-compat && xvfb-run yarn run test:ci
151+
env:
152+
BROWSERS: 'Firefox'
41153

154+
test-firefox:
155+
name: Test Firestore on Firefox
156+
strategy:
157+
matrix:
158+
test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
159+
# Whatever version of Firefox comes with 22.04 is causing Firefox
160+
# startup to hang when launched by karma. Need to look further into
161+
# why.
162+
runs-on: ubuntu-20.04
163+
needs: build
164+
if: ${{ needs.build.outputs.changed == 'true'}}
42165
steps:
43166
- name: install Firefox stable
44167
run: |
45168
sudo apt-get update
46169
sudo apt-get install firefox
47-
- name: Checkout Repo
48-
uses: actions/checkout@master
170+
- name: Download build archive
171+
uses: actions/download-artifact@v3
49172
with:
50-
# This makes Actions fetch all Git history so run-changed script can diff properly.
51-
fetch-depth: 0
173+
name: build.tar.gz
174+
- name: Unzip build artifact
175+
run: tar xf build.tar.gz
52176
- name: Set up Node (14)
53177
uses: actions/setup-node@v3
54178
with:
55179
node-version: 14.x
56180
- name: Bump Node memory limit
57181
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
58182
- name: Test setup and yarn install
59-
run: |
60-
cp config/ci.config.json config/project.json
61-
yarn
62-
- name: build
63-
run: yarn build:changed firestore
64-
- name: Run tests if firestore or its dependencies has changed
65-
run: xvfb-run yarn test:changed firestore
183+
run: cp config/ci.config.json config/project.json
184+
- name: Run tests
185+
run: cd packages/firestore && xvfb-run yarn run ${{ matrix.test-name }}
66186
env:
67187
BROWSERS: 'Firefox'
188+
189+
# A job that fails if any required job in the test matrix fails,
190+
# to be used as a required check for merging.
191+
check-required-tests:
192+
runs-on: ubuntu-latest
193+
if: always()
194+
name: Check all required tests results
195+
needs: [build, test-chrome, compat-test-chrome]
196+
steps:
197+
- name: Check test matrix
198+
if: needs.build.result == 'failure' || needs.test-chrome.result == 'failure' || needs.compat-test-chrome.result == 'failure'
199+
run: exit 1

config/karma.base.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,5 @@ const config = {
8787
config.mochaReporter = {
8888
showDiff: true
8989
};
90-
// Make it easy to spot failed tests in CI
91-
if (process.env.CI) {
92-
config.mochaReporter = {
93-
output: 'minimal'
94-
};
95-
}
9690

9791
module.exports = config;

config/mocharc.node.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ const config = {
2929
exit: true
3030
};
3131

32-
// use min reporter in CI to make it easy to spot failed tests
33-
if (process.env.CI) {
34-
config.reporter = 'min';
35-
}
36-
3732
// Firestore uses babel to compile tests in Nodejs
3833
if (process.env.NO_TS_NODE) {
3934
delete config.require;

config/webpack.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ module.exports = {
115115
);
116116
}),
117117
new NodePolyfillPlugin(),
118-
new webpack.EnvironmentPlugin([
119-
'RTDB_EMULATOR_PORT',
120-
'RTDB_EMULATOR_NAMESPACE'
121-
])
118+
new webpack.EnvironmentPlugin({
119+
'RTDB_EMULATOR_PORT': false,
120+
'RTDB_EMULATOR_NAMESPACE': false
121+
})
122122
]
123123
};

integration/firestore/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
77
"build:persistence": "INCLUDE_FIRESTORE_PERSISTENCE=true gulp compile-tests",
88
"build:memory": "INCLUDE_FIRESTORE_PERSISTENCE=false gulp compile-tests",
9+
"karma:singlerun": "karma start --single-run",
910
"prettier": "prettier --write '*.js' '*.ts'",
10-
"test": "yarn build:memory; karma start --single-run; yarn build:persistence; karma start --single-run;",
11-
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
1211
"test:persistence": " yarn build:persistence; karma start --single-run",
1312
"test:persistence:debug": "yarn build:persistence; karma start --auto-watch --browsers Chrome",
1413
"test:memory": "yarn build:memory; karma start --single-run",
@@ -32,6 +31,6 @@
3231
"ts-loader": "8.4.0",
3332
"typescript": "4.2.2",
3433
"webpack": "5.76.0",
35-
"webpack-stream": "6.1.2"
34+
"webpack-stream": "7.0.0"
3635
}
3736
}

packages/auth/index.rn.ts

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
*/
2424

2525
import { FirebaseApp, getApp, _getProvider } from '@firebase/app';
26-
import { Auth } from './src/model/public_types';
26+
import { Auth, Dependencies } from './src/model/public_types';
2727

28-
import { initializeAuth } from './src';
28+
import { initializeAuth as initializeAuthOriginal } from './src';
2929
import { registerAuth } from './src/core/auth/register';
3030
import { ClientPlatform } from './src/core/util/version';
31-
import { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
32-
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
31+
import { _logWarn } from './src/core/util/log';
3332

3433
// Core functionality shared by all clients
3534
export * from './index.shared';
@@ -49,7 +48,21 @@ export {
4948
// MFA
5049
export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
5150

52-
export { getReactNativePersistence };
51+
export { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
52+
53+
const NO_PERSISTENCE_WARNING = `
54+
You are initializing Firebase Auth for React Native without providing
55+
AsyncStorage. Auth state will default to memory persistence and will not
56+
persist between sessions. In order to persist auth state, install the package
57+
"@react-native-async-storage/async-storage" and provide it to
58+
initializeAuth:
59+
60+
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
61+
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
62+
const auth = initializeAuth(app, {
63+
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
64+
});
65+
`;
5366

5467
export function getAuth(app: FirebaseApp = getApp()): Auth {
5568
const provider = _getProvider(app, 'auth');
@@ -58,9 +71,25 @@ export function getAuth(app: FirebaseApp = getApp()): Auth {
5871
return provider.getImmediate();
5972
}
6073

61-
return initializeAuth(app, {
62-
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
63-
});
74+
// Only warn if getAuth() is called before initializeAuth()
75+
_logWarn(NO_PERSISTENCE_WARNING);
76+
77+
return initializeAuthOriginal(app);
78+
}
79+
80+
/**
81+
* Wrapper around base `initializeAuth()` for RN users only, which
82+
* shows the warning message if no persistence is provided.
83+
* Double-checked potential collision with `export * from './index.shared'`
84+
* as `./index.shared` also exports `initializeAuth()`, and the final
85+
* bundle does correctly export only this `initializeAuth()` function
86+
* and not the one from index.shared.
87+
*/
88+
export function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth {
89+
if (!deps?.persistence) {
90+
_logWarn(NO_PERSISTENCE_WARNING);
91+
}
92+
return initializeAuthOriginal(app, deps);
6493
}
6594

6695
registerAuth(ClientPlatform.REACT_NATIVE);

0 commit comments

Comments
 (0)