mirror of
https://github.com/hanzoai/firebase-js-sdk.git
synced 2026-09-24 16:59:10 +00:00
* test(auth): fix flakiness in browser integration and webdriver tests * Fix WebDriver email sign-in test flakiness by using robust JS click/fill * Ensure deleteApp is called even if resetEmulator fails * test(auth): catch emulator and deleteApp cleanup errors to prevent failing afterEach hook * build: do not throw on missing deploying token if deployment is not needed * build: add --include-dependencies to build_changed so dependents compile successfully * build: workaround glob-stream singular glob Node 22 bug in firestore integration tests * chore: revert allowEmpty: true
105 lines
3.0 KiB
TypeScript
105 lines
3.0 KiB
TypeScript
/**
|
|
* @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 { TestReason, getTestTasks, filterTasks, logTasks } from './tasks';
|
|
import { spawn } from 'child-process-promise';
|
|
import chalk from 'chalk';
|
|
import { resolve } from 'path';
|
|
import * as yargs from 'yargs';
|
|
import { testConfig, TestConfig } from './testConfig';
|
|
const root = resolve(__dirname, '../..');
|
|
|
|
const argv = yargs
|
|
.options({
|
|
buildAll: {
|
|
type: 'boolean',
|
|
desc: 'if true, build all packages. Used in Test Auth workflow because Auth tests depends on the firebase package'
|
|
}
|
|
})
|
|
.parseSync();
|
|
|
|
const allTestConfigNames = Object.keys(testConfig);
|
|
const inputTestConfigName = argv._[0].toString();
|
|
|
|
if (!inputTestConfigName) {
|
|
throw Error(`
|
|
A config name is required. Valid names include ${allTestConfigNames.join(
|
|
', '
|
|
)}.
|
|
To add a new config, update scripts/ci-test/testConfig.ts
|
|
`);
|
|
}
|
|
|
|
if (!allTestConfigNames.includes(inputTestConfigName)) {
|
|
throw Error(`
|
|
Invalid config name. Valid names include ${allTestConfigNames.join(', ')}.
|
|
To add a new config, update scripts/ci-test/testConfig.ts
|
|
`);
|
|
}
|
|
|
|
const config = testConfig[inputTestConfigName]!;
|
|
|
|
buildForTests(config, argv);
|
|
|
|
interface Options {
|
|
buildAll?: boolean;
|
|
}
|
|
|
|
async function buildForTests(
|
|
config: TestConfig,
|
|
{ buildAll = false }: Options
|
|
) {
|
|
try {
|
|
const testTasks = filterTasks(await getTestTasks(), config);
|
|
// print tasks for info
|
|
logTasks(testTasks);
|
|
if (testTasks.length === 0) {
|
|
console.log(chalk`{green No test tasks. Skipping all builds }`);
|
|
return;
|
|
}
|
|
|
|
// build all and return
|
|
if (buildAll) {
|
|
await spawn('yarn', ['build'], { stdio: 'inherit', cwd: root });
|
|
return;
|
|
}
|
|
|
|
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('build');
|
|
lernaCmd.push('--include-dependencies');
|
|
await spawn('npx', lernaCmd, { stdio: 'inherit', cwd: root });
|
|
} catch (e) {
|
|
console.error(chalk`{red ${e}}`);
|
|
process.exit(1);
|
|
}
|
|
}
|