Skip to content

Commit 5211acf

Browse files
authored
Build only packages needed for testing (#3668)
* build only packages needed for testing * ignore firebase and firebase-exp * revert yarn.lock * test app * make a separate workflow for firebase namespace test * early return if no test tasks * test fcm * Revert "test fcm" This reverts commit a0599e8. * Revert "test app" This reverts commit 73f817c. * put auxiliary libs into a separate workflow * test firebase * small change * update yarn.lock * fix obvious errors * fix script issues * run auth tests in a separate workflow * rename test name to make more sense on Github * try separating firestore and firestore integration into different workflows
1 parent eb55e6f commit 5211acf

23 files changed

+382
-408
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test Auth
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: If Changed
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (10)
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 10.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Test setup and yarn install
25+
run: |
26+
cp config/ci.config.json config/project.json
27+
yarn
28+
- name: Run tests on changed packages
29+
run: xvfb-run yarn test:changed:auth
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test rxFire, @firebase/testing and @firebase/rules-unit-testing
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: If Changed
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (10)
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 10.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Test setup and yarn install
25+
run: |
26+
cp config/ci.config.json config/project.json
27+
yarn
28+
- name: Run tests
29+
run: xvfb-run yarn test:changed:auxiliary

.github/workflows/test-changed-fcm-integration.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: pull_request
44

55
jobs:
66
test:
7-
name: Test FCM integration
7+
name: If Changed
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -25,7 +25,5 @@ jobs:
2525
run: |
2626
cp config/ci.config.json config/project.json
2727
yarn
28-
- name: yarn build
29-
run: yarn build
3028
- name: Run tests if FCM or its dependenceies has changed
3129
run: xvfb-run yarn test:changed:fcm
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test Firestore Integration
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: If Changed
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (10)
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 10.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Test setup and yarn install
25+
run: |
26+
cp config/ci.config.json config/project.json
27+
yarn
28+
- name: Run tests if firestore or its dependenceies has changed
29+
run: xvfb-run yarn test:changed:firestore

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: pull_request
44

55
jobs:
66
test:
7-
name: Test Firestore
7+
name: If Changed
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -25,7 +25,5 @@ jobs:
2525
run: |
2626
cp config/ci.config.json config/project.json
2727
yarn
28-
- name: yarn build
29-
run: yarn build
3028
- name: Run tests if firestore or its dependenceies has changed
3129
run: xvfb-run yarn test:changed:firestore

.github/workflows/test-changed.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ jobs:
2525
run: |
2626
cp config/ci.config.json config/project.json
2727
yarn
28-
- name: yarn build
29-
run: yarn build
3028
- name: Run tests on changed packages
3129
run: xvfb-run yarn test:changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Test Firebase Namespace
2+
3+
on: pull_request
4+
5+
jobs:
6+
test:
7+
name: Test Firebase Namespace
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (10)
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: 10.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Test setup and yarn install
25+
run: |
26+
cp config/ci.config.json config/project.json
27+
yarn
28+
- name: yarn build
29+
run: yarn build
30+
- name: Run tests on changed packages
31+
run: xvfb-run yarn lerna run --scope firebase-namespace-integration-test test:ci

integration/firestore/firebase_export.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firebase from 'firebase/app';
19-
import 'firebase/firestore';
18+
import firebase from '@firebase/app';
19+
import '@firebase/firestore';
20+
import { FirebaseApp } from '@firebase/app-types';
21+
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';
2022

2123
// This file replaces "packages/firestore/test/integration/util/firebase_export"
2224
// and depends on the minified sources.
@@ -25,9 +27,9 @@ let appCount = 0;
2527

2628
export function newTestFirestore(
2729
projectId: string,
28-
nameOrApp?: string | firebase.app.App,
29-
settings?: firebase.firestore.Settings
30-
): firebase.firestore.Firestore {
30+
nameOrApp?: string | FirebaseApp,
31+
settings?: Settings
32+
): FirebaseFirestore {
3133
if (nameOrApp === undefined) {
3234
nameOrApp = 'test-app-' + appCount++;
3335
}

integration/firestore/firebase_export_memory.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firebase from 'firebase/app';
19-
import 'firebase/firestore/memory';
18+
import firebase from '@firebase/app';
19+
import '@firebase/firestore/memory';
20+
import { FirebaseApp } from '@firebase/app-types';
21+
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';
2022

2123
// This file replaces "packages/firestore/test/integration/util/firebase_export"
2224
// and depends on the minified sources.
@@ -25,9 +27,9 @@ let appCount = 0;
2527

2628
export function newTestFirestore(
2729
projectId: string,
28-
nameOrApp?: string | firebase.app.App,
29-
settings?: firebase.firestore.Settings
30-
): firebase.firestore.Firestore {
30+
nameOrApp?: string | FirebaseApp,
31+
settings?: Settings
32+
): FirebaseFirestore {
3133
if (nameOrApp === undefined) {
3234
nameOrApp = 'test-app-' + appCount++;
3335
}

integration/firestore/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
"test:memory": "yarn build:memory; karma start --single-run",
1414
"test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome"
1515
},
16-
"peerDependencies": {
17-
"@firebase/app": "0.x",
18-
"@firebase/firestore": "1.16.4"
19-
},
2016
"devDependencies": {
17+
"@firebase/app": "0.6.10",
18+
"@firebase/firestore": "1.16.4",
2119
"@types/mocha": "7.0.2",
2220
"gulp": "4.0.2",
2321
"gulp-filter": "6.0.0",

integration/messaging/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"pretest:manual": "node ./download-browsers.js",
77
"test": "mocha --exit",
8+
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
89
"test:manual": "mocha --exit"
910
},
1011
"devDependencies": {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@
3838
"pretest:coverage": "mkdirp coverage",
3939
"ci:coverage": "lcov-result-merger 'packages/**/lcov.info' 'lcov-all.info'",
4040
"test:coverage": "lcov-result-merger 'packages/**/lcov.info' | coveralls",
41-
"test:changed": "ts-node-script scripts/ci-test/run_changed_no_firestore.ts",
41+
"test:changed": "ts-node-script scripts/ci-test/run_changed_core.ts",
4242
"test:changed:firestore": "ts-node-script scripts/ci-test/run_changed_firestore.ts",
43+
"test:changed:firestore:integration": "ts-node-script scripts/ci-test/run_changed_firestore_integration.ts",
4344
"test:changed:fcm": "ts-node-script scripts/ci-test/run_changed_fcm_integration.ts",
45+
"test:changed:auth": "ts-node-script scripts/ci-test/run_changed_auth.ts",
46+
"test:changed:auxiliary": "ts-node-script scripts/ci-test/run_changed_auxiliary_libs.ts",
4447
"test:setup": "node tools/config.js",
4548
"test:saucelabs": "node scripts/run_saucelabs.js",
4649
"docgen:js": "node scripts/docgen/generate-docs.js --api js",

packages/firebase/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6952,7 +6952,7 @@ declare namespace firebase.messaging {
69526952
* Do not call this constructor directly. Instead, use
69536953
* {@link firebase.messaging `firebase.messaging()`}.
69546954
*
6955-
* See {@link https://firebase.google.com/docs/cloud-messaging/js/client
6955+
* See {@link https://firebase.google.com/docs/cloud-messaging/js/client
69566956
* Set Up a JavaScript Firebase Cloud Messaging Client App} for a full guide on how to use the
69576957
* Firebase Messaging service.
69586958
*

packages/firestore/register-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as types from '@firebase/firestore-types';
1919

2020
declare module '@firebase/app-types' {
2121
interface FirebaseNamespace {
22-
firestore?: {
22+
firestore: {
2323
(app?: FirebaseApp): types.FirebaseFirestore;
2424
Blob: typeof types.Blob;
2525
CollectionReference: typeof types.CollectionReference;

scripts/ci-test/build.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import { TestTask, TestReason } from './run_changed';
19+
import { spawn } from 'child-process-promise';
20+
import chalk from 'chalk';
21+
import { resolve } from 'path';
22+
const root = resolve(__dirname, '../..');
23+
24+
export async function buildForTests(
25+
testTasks: TestTask[],
26+
buildAppExp = false
27+
) {
28+
try {
29+
if (testTasks.length === 0) {
30+
console.log(chalk`{green No test tasks. Skipping all builds }`);
31+
return;
32+
}
33+
34+
// hack to build Firestore which depends on @firebase/app-exp (because of firestore exp),
35+
// but doesn't list it as a dependency in its package.json
36+
// TODO: remove once modular SDKs become official
37+
if (buildAppExp) {
38+
await spawn(
39+
'npx',
40+
[
41+
'lerna',
42+
'run',
43+
'--scope',
44+
'@firebase/app-exp',
45+
'--include-dependencies',
46+
'build'
47+
],
48+
{ stdio: 'inherit', cwd: root }
49+
);
50+
}
51+
52+
const lernaCmd = ['lerna', 'run'];
53+
console.log(chalk`{blue Running build in:}`);
54+
for (const task of testTasks) {
55+
if (task.reason === TestReason.Changed) {
56+
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
57+
} else if (task.reason === TestReason.Dependent) {
58+
console.log(
59+
chalk`{yellow ${task.pkgName} (depends on modified files)}`
60+
);
61+
} else {
62+
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
63+
}
64+
lernaCmd.push('--scope');
65+
lernaCmd.push(task.pkgName);
66+
}
67+
68+
lernaCmd.push('--include-dependencies', 'build');
69+
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
70+
} catch (e) {
71+
console.error(chalk`{red ${e}}`);
72+
}
73+
}

0 commit comments

Comments
 (0)