Skip to content

Commit

Permalink
fix(core): extraneous build step in stack graph when no build is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Dec 12, 2019
1 parent 715abe0 commit f452c00
Show file tree
Hide file tree
Showing 31 changed files with 264 additions and 226 deletions.
2 changes: 0 additions & 2 deletions dashboard/src/containers/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export default () => {
const nodesWithStatus: RenderedNodeWithStatus[] = graph.nodes.map((node) => {
let taskState: TaskState = "taskComplete"
switch (node.type) {
case "publish":
break
case "deploy":
taskState = (services[node.name] && services[node.name].taskState) || taskState
break
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/contexts/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React, { useState, useContext } from "react"
import { ServiceIngress } from "garden-service/build/src/types/service"
import { RenderedNodeType } from "garden-service/build/src/config-graph"
import { DependencyGraphNodeType } from "garden-service/build/src/config-graph"
import { PickFromUnion } from "garden-service/build/src/util/util"

interface UiState {
Expand Down Expand Up @@ -44,7 +44,7 @@ export type OverviewSupportedFilterKeys =
| "tasksInfo"
| "tests"
| "testsInfo"
export type StackGraphSupportedFilterKeys = PickFromUnion<RenderedNodeType, "test" | "deploy" | "build" | "run">
export type StackGraphSupportedFilterKeys = PickFromUnion<DependencyGraphNodeType, "test" | "deploy" | "build" | "run">
export type EntityResultSupportedTypes = StackGraphSupportedFilterKeys | "task"
export type SelectedEntity = {
type: EntityResultSupportedTypes
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class ActionRouter implements TypeGuard {
this.moduleActionHandlers = <WrappedModuleActionMap>fromPairs(moduleActionNames.map((n) => [n, {}]))
this.loadedPlugins = keyBy(loadedPlugins, "name")

garden.log.silly(`Creating ActionRouter with ${configuredPlugins.length} configured plugins`)
garden.log.silly(`Creating ActionRouter with ${configuredPlugins.length} configured providers`)

for (const plugin of configuredPlugins) {
const handlers = plugin.handlers || {}
Expand Down
14 changes: 7 additions & 7 deletions garden-service/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
StringsParameter,
PrepareParams,
} from "./base"
import { getBuildTasks } from "../tasks/build"
import { TaskResults } from "../task-graph"
import dedent = require("dedent")
import dedent from "dedent"
import { processModules } from "../process"
import { printHeader } from "../logger/util"
import { startServer, GardenServer } from "../server/server"
import { flatten } from "lodash"
import { BuildTask } from "../tasks/build"

const buildArguments = {
modules: new StringsParameter({
Expand Down Expand Up @@ -93,13 +93,13 @@ export class BuildCommand extends Command<Args, Opts> {
footerLog,
modules,
watch: opts.watch,
handler: async (_, module) => getBuildTasks({ garden, log, module, force: opts.force }),
changeHandler: async (_, module) => {
const dependantModules = (await graph.getDependants("build", module.name, true)).build
handler: async (_, module) => BuildTask.factory({ garden, log, module, force: opts.force }),
changeHandler: async (newGraph, module) => {
const deps = await newGraph.getDependants("build", module.name, true)
const tasks = [module]
.concat(dependantModules)
.concat(deps.build)
.filter((m) => moduleNames.includes(m.name))
.map((m) => getBuildTasks({ garden, log, module: m, force: true }))
.map((m) => BuildTask.factory({ garden, log, module: m, force: true }))
return flatten(await Promise.all(tasks))
},
})
Expand Down
4 changes: 2 additions & 2 deletions garden-service/src/commands/run/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RunResult } from "../../types/plugin/base"
import { BooleanParameter, Command, CommandParams, StringParameter, CommandResult, StringsParameter } from "../base"
import { printRuntimeContext } from "./run"
import { printHeader } from "../../logger/util"
import { getBuildTasks } from "../../tasks/build"
import { BuildTask } from "../../tasks/build"
import { dedent, deline } from "../../util/string"
import { prepareRuntimeContext } from "../../runtime-context"

Expand Down Expand Up @@ -85,7 +85,7 @@ export class RunModuleCommand extends Command<Args, Opts> {

const actions = await garden.getActionRouter()

const buildTasks = await getBuildTasks({
const buildTasks = await BuildTask.factory({
garden,
log,
module,
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/commands/run/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class RunServiceCommand extends Command<Args, Opts> {
})
const dependencyResults = await garden.processTasks(await deployTask.getDependencies())

const dependencies = await graph.getDependencies("service", serviceName, false)
const dependencies = await graph.getDependencies("deploy", serviceName, false)
const serviceStatuses = getServiceStatuses(dependencyResults)
const taskResults = getRunTaskResults(dependencyResults)

Expand Down
Loading

0 comments on commit f452c00

Please sign in to comment.