Skip to content

Build only packages needed for testing #3668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test-changed-auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test Auth

on: pull_request

jobs:
test:
name: If Changed
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (10)
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: Run tests on changed packages
run: xvfb-run yarn test:changed:auth
29 changes: 29 additions & 0 deletions .github/workflows/test-changed-auxiliary-libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test rxFire, @firebase/testing and @firebase/rules-unit-testing

on: pull_request

jobs:
test:
name: If Changed
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (10)
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: Run tests
run: xvfb-run yarn test:changed:auxiliary
4 changes: 1 addition & 3 deletions .github/workflows/test-changed-fcm-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: pull_request

jobs:
test:
name: Test FCM integration
name: If Changed
runs-on: ubuntu-latest

steps:
Expand All @@ -25,7 +25,5 @@ jobs:
run: |
cp config/ci.config.json config/project.json
yarn
- name: yarn build
run: yarn build
- name: Run tests if FCM or its dependenceies has changed
run: xvfb-run yarn test:changed:fcm
29 changes: 29 additions & 0 deletions .github/workflows/test-changed-firestore-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test Firestore Integration

on: pull_request

jobs:
test:
name: If Changed
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (10)
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: Run tests if firestore or its dependenceies has changed
run: xvfb-run yarn test:changed:firestore
4 changes: 1 addition & 3 deletions .github/workflows/test-changed-firestore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: pull_request

jobs:
test:
name: Test Firestore
name: If Changed
runs-on: ubuntu-latest

steps:
Expand All @@ -25,7 +25,5 @@ jobs:
run: |
cp config/ci.config.json config/project.json
yarn
- name: yarn build
run: yarn build
- name: Run tests if firestore or its dependenceies has changed
run: xvfb-run yarn test:changed:firestore
2 changes: 0 additions & 2 deletions .github/workflows/test-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@ jobs:
run: |
cp config/ci.config.json config/project.json
yarn
- name: yarn build
run: yarn build
- name: Run tests on changed packages
run: xvfb-run yarn test:changed
31 changes: 31 additions & 0 deletions .github/workflows/test-firebase-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test Firebase Namespace

on: pull_request

jobs:
test:
name: Test Firebase Namespace
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (10)
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: yarn build
run: yarn build
- name: Run tests on changed packages
run: xvfb-run yarn lerna run --scope firebase-namespace-integration-test test:ci
12 changes: 7 additions & 5 deletions integration/firestore/firebase_export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* limitations under the License.
*/

import * as firebase from 'firebase/app';
import 'firebase/firestore';
import firebase from '@firebase/app';
import '@firebase/firestore';
import { FirebaseApp } from '@firebase/app-types';
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';

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

export function newTestFirestore(
projectId: string,
nameOrApp?: string | firebase.app.App,
settings?: firebase.firestore.Settings
): firebase.firestore.Firestore {
nameOrApp?: string | FirebaseApp,
settings?: Settings
): FirebaseFirestore {
if (nameOrApp === undefined) {
nameOrApp = 'test-app-' + appCount++;
}
Expand Down
12 changes: 7 additions & 5 deletions integration/firestore/firebase_export_memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* limitations under the License.
*/

import * as firebase from 'firebase/app';
import 'firebase/firestore/memory';
import firebase from '@firebase/app';
import '@firebase/firestore/memory';
import { FirebaseApp } from '@firebase/app-types';
import { Settings, FirebaseFirestore } from '@firebase/firestore-types';

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

export function newTestFirestore(
projectId: string,
nameOrApp?: string | firebase.app.App,
settings?: firebase.firestore.Settings
): firebase.firestore.Firestore {
nameOrApp?: string | FirebaseApp,
settings?: Settings
): FirebaseFirestore {
if (nameOrApp === undefined) {
nameOrApp = 'test-app-' + appCount++;
}
Expand Down
6 changes: 2 additions & 4 deletions integration/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
"test:memory": "yarn build:memory; karma start --single-run",
"test:memory:debug": "yarn build:memory; karma start --auto-watch --browsers Chrome"
},
"peerDependencies": {
"@firebase/app": "0.x",
"@firebase/firestore": "1.16.4"
},
"devDependencies": {
"@firebase/app": "0.6.10",
"@firebase/firestore": "1.16.4",
"@types/mocha": "7.0.2",
"gulp": "4.0.2",
"gulp-filter": "6.0.0",
Expand Down
1 change: 1 addition & 0 deletions integration/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"pretest:manual": "node ./download-browsers.js",
"test": "mocha --exit",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test",
"test:manual": "mocha --exit"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
"pretest:coverage": "mkdirp coverage",
"ci:coverage": "lcov-result-merger 'packages/**/lcov.info' 'lcov-all.info'",
"test:coverage": "lcov-result-merger 'packages/**/lcov.info' | coveralls",
"test:changed": "ts-node-script scripts/ci-test/run_changed_no_firestore.ts",
"test:changed": "ts-node-script scripts/ci-test/run_changed_core.ts",
"test:changed:firestore": "ts-node-script scripts/ci-test/run_changed_firestore.ts",
"test:changed:firestore:integration": "ts-node-script scripts/ci-test/run_changed_firestore_integration.ts",
"test:changed:fcm": "ts-node-script scripts/ci-test/run_changed_fcm_integration.ts",
"test:changed:auth": "ts-node-script scripts/ci-test/run_changed_auth.ts",
"test:changed:auxiliary": "ts-node-script scripts/ci-test/run_changed_auxiliary_libs.ts",
"test:setup": "node tools/config.js",
"test:saucelabs": "node scripts/run_saucelabs.js",
"docgen:js": "node scripts/docgen/generate-docs.js --api js",
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6952,7 +6952,7 @@ declare namespace firebase.messaging {
* Do not call this constructor directly. Instead, use
* {@link firebase.messaging `firebase.messaging()`}.
*
* See {@link https://firebase.google.com/docs/cloud-messaging/js/client
* See {@link https://firebase.google.com/docs/cloud-messaging/js/client
* Set Up a JavaScript Firebase Cloud Messaging Client App} for a full guide on how to use the
* Firebase Messaging service.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/register-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as types from '@firebase/firestore-types';

declare module '@firebase/app-types' {
interface FirebaseNamespace {
firestore?: {
firestore: {
(app?: FirebaseApp): types.FirebaseFirestore;
Blob: typeof types.Blob;
CollectionReference: typeof types.CollectionReference;
Expand Down
73 changes: 73 additions & 0 deletions scripts/ci-test/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { TestTask, TestReason } from './run_changed';
import { spawn } from 'child-process-promise';
import chalk from 'chalk';
import { resolve } from 'path';
const root = resolve(__dirname, '../..');

export async function buildForTests(
testTasks: TestTask[],
buildAppExp = false
) {
try {
if (testTasks.length === 0) {
console.log(chalk`{green No test tasks. Skipping all builds }`);
return;
}

// hack to build Firestore which depends on @firebase/app-exp (because of firestore exp),
// but doesn't list it as a dependency in its package.json
// TODO: remove once modular SDKs become official
if (buildAppExp) {
await spawn(
'npx',
[
'lerna',
'run',
'--scope',
'@firebase/app-exp',
'--include-dependencies',
'build'
],
{ stdio: 'inherit', cwd: root }
);
}

const lernaCmd = ['lerna', 'run'];
console.log(chalk`{blue Running build in:}`);
for (const task of testTasks) {
if (task.reason === TestReason.Changed) {
console.log(chalk`{yellow ${task.pkgName} (contains modified files)}`);
} else if (task.reason === TestReason.Dependent) {
console.log(
chalk`{yellow ${task.pkgName} (depends on modified files)}`
);
} else {
console.log(chalk`{yellow ${task.pkgName} (running all tests)}`);
}
lernaCmd.push('--scope');
lernaCmd.push(task.pkgName);
}

lernaCmd.push('--include-dependencies', 'build');
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
} catch (e) {
console.error(chalk`{red ${e}}`);
}
}
Loading