Skip to content

Commit

Permalink
Merge master into release
Browse files Browse the repository at this point in the history
  • Loading branch information
google-oss-bot authored Aug 22, 2023
2 parents 03337aa + 309f7a9 commit 31623d7
Show file tree
Hide file tree
Showing 20 changed files with 464 additions and 779 deletions.
6 changes: 6 additions & 0 deletions .changeset/eleven-lamps-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@firebase/auth': minor
'firebase': minor
---

Remove dependency on @react-native-async-storage/async-storage and add warnings to remind React Native users to manually import it.
6 changes: 6 additions & 0 deletions .changeset/nervous-cups-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/firestore": patch
"@firebase/webchannel-wrapper": patch
---

Fix how we enable fetch streams.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#######################################################################################################

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

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

# Changeset
.changeset @firebase/jssdk-changeset-approvers @firebase/firestore-js-team @firebase/jssdk-global-approvers
.changeset @firebase/jssdk-changeset-approvers @firebase/firestore-js-team @firebase/jssdk-global-approvers
22 changes: 11 additions & 11 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ jobs:
continue-on-error: true

test-firestore-integration:
name: Firestore Integration Tests
strategy:
fail-fast: false
matrix:
persistence: ['memory', 'persistence']
name: Firestore Integration Tests (${{ matrix.persistence }})
needs: build
runs-on: ubuntu-latest
steps:
Expand All @@ -207,15 +211,11 @@ jobs:
node-version: 16.x
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: Set start timestamp env var
run: echo "FIREBASE_CI_TEST_START_TIME=$(date +%s)" >> $GITHUB_ENV
- name: Run unit tests
run: |
xvfb-run yarn lerna run --concurrency 4 test:ci --scope firebase-firestore-integration-test
node scripts/print_test_logs.js
- run: cp config/ci.config.json config/project.json
- run: yarn
- run: yarn build:${{ matrix.persistence }}
working-directory: integration/firestore
- run: xvfb-run yarn karma:singlerun
working-directory: integration/firestore
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}
168 changes: 150 additions & 18 deletions .github/workflows/test-changed-firestore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Test Firestore

on: pull_request

env:
artifactRetentionDays: 14

jobs:
test-chrome:
name: Test Firestore on Chrome and Node If Changed
build:
name: Build Firestore

runs-on: ubuntu-latest
outputs:
changed: ${{ steps.set-output.outputs.CHANGED }}

steps:
- name: Checkout Repo
Expand All @@ -28,40 +34,166 @@ jobs:
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed firestore
- name: Run tests if firestore or its dependencies has changed
run: yarn test:changed firestore
id: build
run: |
set -o pipefail
yarn build:changed firestore | tee ${{ runner.temp }}/yarn.log.txt
continue-on-error: false
- name: Check if Firestore is changed
id: check-changed
run: egrep "Skipping all" ${{ runner.temp }}/yarn.log.txt
# Continue when "Skipping all" is not found
continue-on-error: true
- name: set output
# This means "Skipping all" was not found
if: steps.check-changed.outcome != 'success'
id: set-output
run: echo "CHANGED=true" >> "$GITHUB_OUTPUT";
- name: Archive build
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
run: |
tar -cf build.tar --exclude=.git .
gzip build.tar
- name: Upload build archive
if: ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
uses: actions/upload-artifact@v3
with:
name: build.tar.gz
path: build.tar.gz
retention-days: ${{ env.artifactRetentionDays }}

test-firefox:
name: Test Firestore on Firefox If Changed
compat-test-chrome:
name: Test Firestore Compatible
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.changed == 'true'}}
steps:
- name: Set up Node (14)
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Download build archive
uses: actions/download-artifact@v3
with:
name: build.tar.gz
- name: Unzip build artifact
run: tar xf build.tar.gz
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: cp config/ci.config.json config/project.json
- name: Run compat tests
run: cd packages/firestore-compat && yarn run test:ci

test-chrome:
name: Test Firestore
strategy:
matrix:
test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.changed == 'true'}}
steps:
- name: Set up Node (14)
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Download build archive
uses: actions/download-artifact@v3
with:
name: build.tar.gz
- name: Unzip build artifact
run: tar xf build.tar.gz
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: cp config/ci.config.json config/project.json
- name: Run tests
run: cd packages/firestore && yarn run ${{ matrix.test-name }}

compat-test-firefox:
name: Test Firestore Compatible on Firefox
# Whatever version of Firefox comes with 22.04 is causing Firefox
# startup to hang when launched by karma. Need to look further into
# why.
runs-on: ubuntu-20.04
needs: build
if: ${{ needs.build.outputs.changed == 'true'}}
steps:
- name: install Firefox stable
run: |
sudo apt-get update
sudo apt-get install firefox
- name: Set up Node (14)
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Download build archive
uses: actions/download-artifact@v3
with:
name: build.tar.gz
- name: Unzip build artifact
run: tar xf build.tar.gz
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: cp config/ci.config.json config/project.json
- name: Run compat tests
run: cd packages/firestore-compat && xvfb-run yarn run test:ci
env:
BROWSERS: 'Firefox'

test-firefox:
name: Test Firestore on Firefox
strategy:
matrix:
test-name: ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
# Whatever version of Firefox comes with 22.04 is causing Firefox
# startup to hang when launched by karma. Need to look further into
# why.
runs-on: ubuntu-20.04
needs: build
if: ${{ needs.build.outputs.changed == 'true'}}
steps:
- name: install Firefox stable
run: |
sudo apt-get update
sudo apt-get install firefox
- name: Checkout Repo
uses: actions/checkout@master
- name: Download build archive
uses: actions/download-artifact@v3
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
name: build.tar.gz
- name: Unzip build artifact
run: tar xf build.tar.gz
- name: Set up Node (14)
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed firestore
- name: Run tests if firestore or its dependencies has changed
run: xvfb-run yarn test:changed firestore
run: cp config/ci.config.json config/project.json
- name: Run tests
run: cd packages/firestore && xvfb-run yarn run ${{ matrix.test-name }}
env:
BROWSERS: 'Firefox'

# A job that fails if any required job in the test matrix fails,
# to be used as a required check for merging.
check-required-tests:
runs-on: ubuntu-latest
if: always()
name: Check all required tests results
needs: [build, test-chrome, compat-test-chrome]
steps:
- name: Check test matrix
if: needs.build.result == 'failure' || needs.test-chrome.result == 'failure' || needs.compat-test-chrome.result == 'failure'
run: exit 1
6 changes: 0 additions & 6 deletions config/karma.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,5 @@ const config = {
config.mochaReporter = {
showDiff: true
};
// Make it easy to spot failed tests in CI
if (process.env.CI) {
config.mochaReporter = {
output: 'minimal'
};
}

module.exports = config;
5 changes: 0 additions & 5 deletions config/mocharc.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ const config = {
exit: true
};

// use min reporter in CI to make it easy to spot failed tests
if (process.env.CI) {
config.reporter = 'min';
}

// Firestore uses babel to compile tests in Nodejs
if (process.env.NO_TS_NODE) {
delete config.require;
Expand Down
8 changes: 4 additions & 4 deletions config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ module.exports = {
);
}),
new NodePolyfillPlugin(),
new webpack.EnvironmentPlugin([
'RTDB_EMULATOR_PORT',
'RTDB_EMULATOR_NAMESPACE'
])
new webpack.EnvironmentPlugin({
'RTDB_EMULATOR_PORT': false,
'RTDB_EMULATOR_NAMESPACE': false
})
]
};
5 changes: 2 additions & 3 deletions integration/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
"build:persistence": "INCLUDE_FIRESTORE_PERSISTENCE=true gulp compile-tests",
"build:memory": "INCLUDE_FIRESTORE_PERSISTENCE=false gulp compile-tests",
"karma:singlerun": "karma start --single-run",
"prettier": "prettier --write '*.js' '*.ts'",
"test": "yarn build:memory; karma start --single-run; yarn build:persistence; karma start --single-run;",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
"test:persistence": " yarn build:persistence; karma start --single-run",
"test:persistence:debug": "yarn build:persistence; karma start --auto-watch --browsers Chrome",
"test:memory": "yarn build:memory; karma start --single-run",
Expand All @@ -32,6 +31,6 @@
"ts-loader": "8.4.0",
"typescript": "4.2.2",
"webpack": "5.76.0",
"webpack-stream": "6.1.2"
"webpack-stream": "7.0.0"
}
}
45 changes: 37 additions & 8 deletions packages/auth/index.rn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
*/

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

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

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

export { getReactNativePersistence };
export { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';

const NO_PERSISTENCE_WARNING = `
You are initializing Firebase Auth for React Native without providing
AsyncStorage. Auth state will default to memory persistence and will not
persist between sessions. In order to persist auth state, install the package
"@react-native-async-storage/async-storage" and provide it to
initializeAuth:
import { initializeAuth, getReactNativePersistence } from 'firebase/auth';
import ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';
const auth = initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
`;

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

return initializeAuth(app, {
persistence: getReactNativePersistence(ReactNativeAsyncStorage)
});
// Only warn if getAuth() is called before initializeAuth()
_logWarn(NO_PERSISTENCE_WARNING);

return initializeAuthOriginal(app);
}

/**
* Wrapper around base `initializeAuth()` for RN users only, which
* shows the warning message if no persistence is provided.
* Double-checked potential collision with `export * from './index.shared'`
* as `./index.shared` also exports `initializeAuth()`, and the final
* bundle does correctly export only this `initializeAuth()` function
* and not the one from index.shared.
*/
export function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth {
if (!deps?.persistence) {
_logWarn(NO_PERSISTENCE_WARNING);
}
return initializeAuthOriginal(app, deps);
}

registerAuth(ClientPlatform.REACT_NATIVE);
Loading

0 comments on commit 31623d7

Please sign in to comment.