Skip to content
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

feat: skip count #93 #113

Merged
merged 3 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
41 changes: 38 additions & 3 deletions packages/plugins/plugin-build/src/supervisor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,44 @@ class RunSupervisor {
);
};

async addRunTarget(workspace: Workspace): Promise<void> {
async addRunTarget(
workspace: Workspace,
addToTotalJobs = false
): Promise<void> {
this.entrypoints.push(this.runGraph.addNode(workspace.relativeCwd));
const shouldRun = await this.plan(workspace);

if (addToTotalJobs) {
// Get list of dependendecies
const dependenciesCount =
1 + (await this.getDependenciesCount(workspace));

this.runReport.totalJobs = dependenciesCount;
}

if (shouldRun) {
this.runTargets.push(workspace);
}
}

getDependenciesCount = async (workspace: Workspace): Promise<number> => {
let value = 0;

for (const dependencyType of Manifest.hardDependencies) {
for (const descriptor of workspace.manifest
.getForScope(dependencyType)
.values()) {
const depWorkspace = this.project.tryWorkspaceByDescriptor(descriptor);

if (depWorkspace === null) continue;

value += 1;
}
}

return value;
};

plan = async (workspace: Workspace): Promise<boolean> => {
const parent = this.runGraph
.addNode(workspace.relativeCwd)
Expand Down Expand Up @@ -918,6 +947,12 @@ class RunSupervisor {
let output = this.formatHeader("Summary") + "\n";

if (this.runReport.runStart) {
const skipped =
this.runReport.skipCount +
(this.runReport.totalJobs -
this.runReport.skipCount -
this.runReport.failCount -
this.runReport.successCount);
const successString = formatUtils.pretty(
this.configuration,
`Success: ${this.runReport.successCount}`,
Expand All @@ -930,13 +965,13 @@ class RunSupervisor {
);
const skippedString = formatUtils.pretty(
this.configuration,
`Skipped:${this.runReport.skipCount}`,
`Skipped:${skipped}`,
lodmfjord marked this conversation as resolved.
Show resolved Hide resolved
"white"
);

const totalString = formatUtils.pretty(
this.configuration,
`Total: ${this.runGraph.runSize}`,
`Total: ${this.runReport.totalJobs}`,
"white"
);

Expand Down
4 changes: 3 additions & 1 deletion packages/plugins/plugin-build/src/supervisor/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const addTargets = async ({
project
);

supervisor.runReport.totalJobs = workspaceList.length;

for (const workspace of workspaceList) {
for (const dependencyType of Manifest.hardDependencies) {
for (const descriptor of workspace.manifest
Expand All @@ -56,7 +58,7 @@ const addTargets = async ({
await supervisor.addRunTarget(targetWorkspace);
} else {
// we're in a specific target
await supervisor.addRunTarget(targetWorkspace);
await supervisor.addRunTarget(targetWorkspace, true);
}
};

Expand Down