Skip to content

Hide messages from build tools and test runners for passed packages #2988

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 6 commits into from
Apr 27, 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
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: yarn build
run: yarn build
- name: Run unit tests
run: xvfb-run yarn test
run: xvfb-run yarn test:ci
- name: Generate coverage file
run: yarn ci:coverage
- name: Run coverage
Expand Down
3 changes: 2 additions & 1 deletion integration/browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"version": "0.2.1",
"scripts": {
"pretest": "mkdirp dist && browserify src/namespace.test.js -o dist/namespace.test.js",
"test": "karma start --single-run"
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.14.2"
Expand Down
3 changes: 2 additions & 1 deletion integration/firebase-typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"version": "0.2.1",
"scripts": {
"test": "tsc"
"test": "tsc",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.14.2"
Expand Down
1 change: 1 addition & 0 deletions integration/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build:persistence": "INCLUDE_FIRESTORE_PERSISTENCE=true gulp compile-tests",
"build:memory": "INCLUDE_FIRESTORE_PERSISTENCE=false gulp compile-tests",
"test": "yarn build:memory; karma start --single-run; yarn build:persistence; karma start --single-run;",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:persistence": " yarn build:persistence; karma start --single-run",
"test:memory": "yarn build:memory; karma start --single-run",
"test:debug:persistence": "yarn build:deps; yarn build:persistence; karma start --auto-watch --browsers Chrome",
Expand Down
3 changes: 2 additions & 1 deletion integration/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"version": "0.2.1",
"scripts": {
"test": "karma start --single-run"
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.14.2"
Expand Down
3 changes: 2 additions & 1 deletion integration/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"private": true,
"scripts": {
"pretest": "webpack",
"test": "karma start --single-run"
"test": "karma start --single-run",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"dependencies": {
"firebase": "7.14.2"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"release": "node scripts/release/cli.js",
"pretest": "node tools/pretest.js",
"test": "lerna run --concurrency 4 --stream test",
"test:ci": "lerna run --concurrency 4 --stream test:ci",
"test:exp": "lerna run --concurrency 4 --stream --scope @firebase/*-exp --scope firebase-exp test",
"pretest:coverage": "mkdirp coverage",
"ci:coverage": "lcov-result-merger 'packages/**/lcov.info' 'lcov-all.info'",
Expand Down
1 change: 1 addition & 0 deletions packages-exp/app-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"build:deps": "lerna run --scope @firebase/app-exp --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
"type-check": "tsc -p . --noEmit",
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:deps": "lerna run --scope @firebase/'{app,analytics}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && yarn run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run --nocache",
"type-check": "tsc -p . --noEmit",
"prepare": "yarn build"
Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build:deps": "lerna run --scope @firebase/app --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"type-check": "tsc -p . --noEmit",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
Expand Down
3 changes: 2 additions & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"generate-test-files": "./buildtools/generate_test_files.sh",
"prepare": "yarn build",
"serve": "yarn build && yarn generate-test-files && gulp serve",
"test": "yarn generate-test-files && ./buildtools/run_tests.sh"
"test": "yarn generate-test-files && ./buildtools/run_tests.sh",
"test:ci": "node ../../scripts/run_tests_in_ci.js"
},
"license": "Apache-2.0",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/component --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"type-check": "tsc -p . --noEmit",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../config/mocharc.node.js",
Expand Down
1 change: 1 addition & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/'{app,database}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:emulator",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:all": "run-p lint test:browser test:node",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
Expand Down
1 change: 1 addition & 0 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"prettier": "prettier --write '*.ts' '*.js' 'src/**/*.js' 'test/**/*.js' 'src/**/*.ts' 'test/**/*.ts'",
"test": "run-s lint test:all",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:all": "run-p test:browser test:travis test:minified",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
Expand Down
1 change: 1 addition & 0 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/'{app,functions}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"type-check": "tsc -p . --noEmit",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
Expand Down
1 change: 1 addition & 0 deletions packages/installations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/'{app,installations}' --include-dependencies build",
"test": "yarn type-check && yarn test:karma && yarn lint",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:karma": "karma start --single-run",
"test:debug": "karma start --browsers=Chrome --auto-watch",
"type-check": "tsc -p . --noEmit",
Expand Down
1 change: 1 addition & 0 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:deps": "lerna run --scope @firebase/logger --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers Chrome --auto-watch",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
Expand Down
1 change: 1 addition & 0 deletions packages/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:deps": "lerna run --scope @firebase/'{app,messaging}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p test:karma type-check lint",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:karma": "karma start --single-run",
"test:debug": "karma start --browsers=Chrome --auto-watch",
"prepare": "yarn build",
Expand Down
1 change: 1 addition & 0 deletions packages/performance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/'{app,performance}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:debug": "karma start --browsers=Chrome --auto-watch",
"prepare": "yarn build",
Expand Down
1 change: 1 addition & 0 deletions packages/remote-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/'{app,remote-config}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:debug": "karma start --browsers=Chrome --auto-watch",
"prettier": "prettier --write '{src,test}/**/*.{js,ts}'",
Expand Down
1 change: 1 addition & 0 deletions packages/rxfire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dev": "rollup -c -w",
"prepare": "yarn build",
"test": "run-p lint test:browser",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:browser:debug": "karma start --browsers=Chrome --auto-watch"
},
Expand Down
1 change: 1 addition & 0 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:deps": "lerna run --scope @firebase/'{app,storage}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p test:browser lint",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"prepare": "yarn build",
"prettier": "prettier --write 'src/**/*.ts' 'test/**/*.ts'"
Expand Down
1 change: 1 addition & 0 deletions packages/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"build:deps": "lerna run --scope @firebase/'{app,template}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --config ../../config/mocharc.node.js",
"type-check": "tsc -p . --noEmit",
Expand Down
1 change: 1 addition & 0 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build:deps": "lerna run --scope @firebase/testing --include-dependencies build",
"dev": "rollup -c -w",
"test": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"prepare": "yarn build"
},
"license": "Apache-2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"build:deps": "lerna run --scope @firebase/util --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"type-check": "tsc -p . --noEmit",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha test/**/*.test.* --config ../../config/mocharc.node.js",
Expand Down
8 changes: 6 additions & 2 deletions scripts/run_changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const simpleGit = require('simple-git/promise');
const root = resolve(__dirname, '..');
const git = simpleGit(root);

// use test:ci command in CI
const testCommand = !!process.env.CI ? 'test:ci' : 'test';
/**
* Changes to these files warrant running all tests.
*/
Expand Down Expand Up @@ -148,7 +150,7 @@ async function runTests(pathList) {
if (!pathList) return;
for (const testPath of pathList) {
try {
await spawn('yarn', ['--cwd', testPath, 'test'], {
await spawn('yarn', ['--cwd', testPath, testCommand], {
stdio: 'inherit'
});
} catch (e) {
Expand All @@ -161,7 +163,7 @@ async function main() {
try {
const { testAll, changedPackages = {} } = await getChangedPackages();
if (testAll) {
await spawn('yarn', ['test'], {
await spawn('yarn', [testCommand], {
stdio: 'inherit'
});
} else {
Expand All @@ -178,6 +180,8 @@ async function main() {
console.log(chalk`{yellow ${filename} (depends on modified files)}`);
}
}

changedPackages['packages/app'] = 'direct';
await runTests(alwaysRunTestPaths);
await runTests(Object.keys(changedPackages));
}
Expand Down
47 changes: 47 additions & 0 deletions scripts/run_tests_in_ci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @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.
*/

const { argv } = require('yargs');
const path = require('path');
const { spawn } = require('child-process-promise');

(async () => {
const myPath = argv._[0] || '.'; // default to the current directory
const dir = path.resolve(myPath);
const { name } = require(`${dir}/package.json`);

let stdout = '';
let stderr = '';
try {
const testProcess = spawn('yarn', ['--cwd', dir, 'test']);

testProcess.childProcess.stdout.on('data', data => {
stdout += data.toString();
});
testProcess.childProcess.stderr.on('data', data => {
stderr += data.toString();
});

await testProcess;
console.log('Success: ' + name);
} catch (e) {
console.error('Failure: ' + name);
console.log(stdout);
console.error(stderr);
process.exit(1);
}
})();