Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
fix: Runner build if it's a part of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Max committed Sep 16, 2020
1 parent 7a3c429 commit f4c8b42
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
10 changes: 8 additions & 2 deletions core/dependency-graph/src/DependencyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,16 @@ export class Graph<T = string> {
this.addNode(node);
}
for (const [key, nodes] of graph.inEdges) {
this.inEdges.set(key, new Set(nodes));
this.inEdges.set(
key,
new Set([...(this.inEdges.get(key) ?? []), ...nodes])
);
}
for (const [key, nodes] of graph.outEdges) {
this.outEdges.set(key, new Set(nodes));
this.outEdges.set(
key,
new Set([...(this.outEdges.get(key) ?? []), ...nodes])
);
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions core/garment/src/garment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
RunnerMeta,
validateOptions,
file,
InputFn
InputFn,
getSchema,
renderOptions
} from '@garment/runner';
import {
Action,
Expand Down Expand Up @@ -357,7 +359,7 @@ async function garmentFromWorkspace(
const rootDir =
subscription.type === 'glob'
? subscription.input.rootDir
: subscription.baseDir
: subscription.baseDir;

const files = Object.keys(changes)
.map(changedFilePath =>
Expand Down Expand Up @@ -556,7 +558,12 @@ async function garmentFromWorkspace(
const context = getRunnerContext({
workspace,
project,
options,
options: renderOptions({
options,
workspace,
project,
schema: getSchema(runner)
}),
outputDir: tempOutputDir,
cacheProvider,
defaultCacheKeys: [runner.name, runner.version],
Expand Down Expand Up @@ -968,9 +975,15 @@ async function garmentFromWorkspace(
});
}
const { batch } = batchesByRunner.get(action.runner.handlerPath)!;

batch.push({
project: action.project,
options: action.options
options: renderOptions({
options: action.options,
workspace,
project: action.project,
schema: getSchema(action.runner)
})
});
}
for (const { runner, batch } of batchesByRunner.values()) {
Expand Down
28 changes: 4 additions & 24 deletions core/scheduler/src/getActionGraph.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { Graph } from '@garment/dependency-graph';
import {
getRunnerMeta,
getSchema,
renderOptions,
requireQuery,
RunnerMeta
} from '@garment/runner';
import { getRunnerMeta, requireQuery, RunnerMeta } from '@garment/runner';
import {
Project,
ResolvedTaskConfig,
Expand All @@ -14,9 +8,9 @@ import {
Workspace
} from '@garment/workspace';
import * as multimatch from 'multimatch';
import * as objectHash from 'object-hash';
import * as Path from 'path';
import { Action, Input, RunnerAction } from './Action';
import * as objectHash from 'object-hash';

import globParent = require('glob-parent');

Expand Down Expand Up @@ -141,20 +135,6 @@ export function getActionGraph(opts: GetActionGraphOptions) {
restRunners[runner]
);

let transformedOptions = normalizedOptions;
let runnerProject = workspace.projects.getByPath(
runnerMeta.handlerPath
);
if (!(runnerProject && runnerProject.tasks['build'])) {
const schema = getSchema(runnerMeta);
transformedOptions = renderOptions({
options: normalizedOptions,
workspace,
project,
schema
});
}

let resolvedInput: Input | undefined;

if (typeof input === 'string') {
Expand Down Expand Up @@ -237,7 +217,7 @@ export function getActionGraph(opts: GetActionGraphOptions) {
watch: skipWatch ? false : watch,
lifecycle,
project,
options: { ...normalizedOptions, ...transformedOptions },
options: normalizedOptions,
output: output
? arrayfy(output).map(_ => project.resolvePathTemplate(_))
: undefined,
Expand Down Expand Up @@ -285,7 +265,7 @@ export function getActionGraph(opts: GetActionGraphOptions) {
const runnerProject = workspace.projects.getByPath(
addedAction.runner.handlerPath
);
if (runnerProject) {
if (runnerProject && buildDependencies !== false) {
// We need to first build the runner
const runnerActionGraph = getActionGraphByTask(
'build',
Expand Down

0 comments on commit f4c8b42

Please sign in to comment.