Merge pull request #27098 from backstage/rugvip/since
cli: repo test tweaks
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': minor
|
||||
---
|
||||
|
||||
The `repo test` command will no longer default to watch mode if the `--since` flag is provided.
|
||||
@@ -172,7 +172,11 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
|
||||
}
|
||||
|
||||
// Run in watch mode unless in CI, coverage mode, or running all tests
|
||||
if (!process.env.CI && !hasFlags('--coverage', '--watch', '--watchAll')) {
|
||||
if (
|
||||
!opts.since &&
|
||||
!process.env.CI &&
|
||||
!hasFlags('--coverage', '--watch', '--watchAll')
|
||||
) {
|
||||
const isGitRepo = () =>
|
||||
runCheck('git', 'rev-parse', '--is-inside-work-tree');
|
||||
const isMercurialRepo = () => runCheck('hg', '--cwd', '.', 'root');
|
||||
@@ -217,6 +221,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
|
||||
return packageGraph;
|
||||
}
|
||||
|
||||
let selectedProjects: string[] | undefined = undefined;
|
||||
if (opts.since && !hasFlags('--selectProjects')) {
|
||||
const graph = await getPackageGraph();
|
||||
const changedPackages = await graph.listChangedPackages({
|
||||
@@ -224,19 +229,20 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
|
||||
analyzeLockfile: true,
|
||||
});
|
||||
|
||||
const packageNames = Array.from(
|
||||
selectedProjects = Array.from(
|
||||
graph.collectPackageNames(
|
||||
changedPackages.map(pkg => pkg.name),
|
||||
pkg => pkg.allLocalDependents.keys(),
|
||||
),
|
||||
);
|
||||
|
||||
if (packageNames.length === 0) {
|
||||
if (selectedProjects.length === 0) {
|
||||
console.log(`No packages changed since ${opts.since}`);
|
||||
return;
|
||||
}
|
||||
|
||||
args.push('--selectProjects', ...packageNames);
|
||||
selectedProjects = selectedProjects.filter(pkg => pkg.includes('app'));
|
||||
args.push('--selectProjects', ...selectedProjects);
|
||||
}
|
||||
|
||||
// This is the only thing that is not implemented by jest.run(), so we do it here instead
|
||||
@@ -346,7 +352,9 @@ export async function command(opts: OptionValues, cmd: Command): Promise<void> {
|
||||
projectHashes.set(packageName, sha);
|
||||
|
||||
if (cache?.includes(sha)) {
|
||||
console.log(`Skipped ${packageName} due to cache hit`);
|
||||
if (!selectedProjects || selectedProjects.includes(packageName)) {
|
||||
console.log(`Skipped ${packageName} due to cache hit`);
|
||||
}
|
||||
outputSuccessCache.push(sha);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user