From cc5e5118bcb64b58060d20b62dec4f23fb4626e9 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Fri, 20 Oct 2023 21:54:35 +0200 Subject: [PATCH] fix(core): use correct dep action type in stackGraph event --- core/src/graph/actions.ts | 16 +++++++++++++++- .../src/actions/action-configs-to-graph.ts | 5 +++++ core/test/unit/src/config-graph.ts | 19 +++++++++++++++++++ core/test/unit/src/garden.ts | 3 +++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/core/src/graph/actions.ts b/core/src/graph/actions.ts index ac16734573b..56fdc4cf323 100644 --- a/core/src/graph/actions.ts +++ b/core/src/graph/actions.ts @@ -700,9 +700,23 @@ function dependenciesFromActionConfig( const deps: ActionDependency[] = config.dependencies.map((d) => { try { const { kind, name } = parseActionReference(d) + const depKey = actionReferenceToString(d) + const depConfig = configsByKey[depKey] + if (!depConfig) { + throw new ConfigurationError({ + message: `${description} references depdendency ${depKey}, but no such action could be found`, + }) + } // FIXME @eysi: We're setting the "parent" config type as the dep type which is not correct // and we need to the dep type. - return { kind, name, type: config.type, explicit: true, needsExecutedOutputs: false, needsStaticOutputs: false } + return { + kind, + name, + type: depConfig.type, + explicit: true, + needsExecutedOutputs: false, + needsStaticOutputs: false, + } } catch (error) { throw new ValidationError({ message: `Invalid dependency specified: ${error}`, diff --git a/core/test/unit/src/actions/action-configs-to-graph.ts b/core/test/unit/src/actions/action-configs-to-graph.ts index 044eae240d2..986b7c60a1e 100644 --- a/core/test/unit/src/actions/action-configs-to-graph.ts +++ b/core/test/unit/src/actions/action-configs-to-graph.ts @@ -241,6 +241,7 @@ describe("actionConfigsToGraph", () => { explicit: true, kind: "Build", name: "foo", + type: "test", needsExecutedOutputs: false, needsStaticOutputs: false, }, @@ -288,6 +289,7 @@ describe("actionConfigsToGraph", () => { { explicit: true, kind: "Build", + type: "test", name: "foo", needsExecutedOutputs: false, needsStaticOutputs: false, @@ -337,6 +339,7 @@ describe("actionConfigsToGraph", () => { { explicit: false, kind: "Build", + type: "test", name: "foo", fullRef: ["actions", "build", "foo", "version"], needsExecutedOutputs: false, @@ -387,6 +390,7 @@ describe("actionConfigsToGraph", () => { { explicit: false, kind: "Build", + type: "test", name: "foo", fullRef: ["actions", "build", "foo", "outputs", "bar"], needsExecutedOutputs: true, @@ -437,6 +441,7 @@ describe("actionConfigsToGraph", () => { { explicit: false, kind: "Build", + type: "container", name: "foo", fullRef: ["actions", "build", "foo", "outputs", "deploymentImageName"], needsExecutedOutputs: false, diff --git a/core/test/unit/src/config-graph.ts b/core/test/unit/src/config-graph.ts index 3f732d5fe9e..7608fc12c9b 100644 --- a/core/test/unit/src/config-graph.ts +++ b/core/test/unit/src/config-graph.ts @@ -1477,84 +1477,98 @@ describe("ConfigGraph (module-based configs)", () => { expect(rendered.nodes).to.include.deep.members([ { kind: "Build", + type: "test", name: "module-a", key: "module-a", disabled: false, }, { kind: "Build", + type: "test", name: "module-b", key: "module-b", disabled: false, }, { kind: "Build", + type: "test", name: "module-c", key: "module-c", disabled: false, }, { kind: "Test", + type: "test", name: "module-c-unit", key: "module-c-unit", disabled: false, }, { kind: "Test", + type: "test", name: "module-c-integ", key: "module-c-integ", disabled: false, }, { kind: "Run", + type: "test", name: "task-c", key: "task-c", disabled: false, }, { kind: "Deploy", + type: "test", name: "service-c", key: "service-c", disabled: false, }, { kind: "Test", + type: "test", name: "module-a-unit", key: "module-a-unit", disabled: false, }, { kind: "Test", + type: "test", name: "module-a-integration", key: "module-a-integration", disabled: false, }, { kind: "Run", + type: "test", name: "task-a", key: "task-a", disabled: false, }, { kind: "Test", + type: "test", name: "module-b-unit", key: "module-b-unit", disabled: false, }, { kind: "Run", + type: "test", name: "task-b", key: "task-b", disabled: false, }, { kind: "Deploy", + type: "test", name: "service-a", key: "service-a", disabled: false, }, { kind: "Deploy", + type: "test", name: "service-b", key: "service-b", disabled: false, @@ -1571,6 +1585,7 @@ describe("ConfigGraphNode", () => { const res = node.render() expect(res).to.eql({ kind: "Build", + type: "container", name: "module-a", key: "module-a", disabled: false, @@ -1582,6 +1597,7 @@ describe("ConfigGraphNode", () => { const res = node.render() expect(res).to.eql({ kind: "Deploy", + type: "container", name: "service-a", key: "service-a", disabled: false, @@ -1593,6 +1609,7 @@ describe("ConfigGraphNode", () => { const res = node.render() expect(res).to.eql({ kind: "Run", + type: "container", name: "task-a", key: "task-a", disabled: false, @@ -1604,6 +1621,7 @@ describe("ConfigGraphNode", () => { const res = node.render() expect(res).to.eql({ kind: "Test", + type: "container", name: "module-a.test-a", key: "module-a.test-a", disabled: false, @@ -1615,6 +1633,7 @@ describe("ConfigGraphNode", () => { const res = node.render() expect(res).to.eql({ kind: "Test", + type: "container", name: "module-a.test-a", key: "module-a.test-a", disabled: true, diff --git a/core/test/unit/src/garden.ts b/core/test/unit/src/garden.ts index 813d292bb27..e8c2d21cddc 100644 --- a/core/test/unit/src/garden.ts +++ b/core/test/unit/src/garden.ts @@ -4301,6 +4301,7 @@ describe("Garden", () => { { explicit: true, kind: "Build", + type: "foo", name: "foo", needsExecutedOutputs: false, needsStaticOutputs: false, @@ -4363,6 +4364,7 @@ describe("Garden", () => { { explicit: true, kind: "Build", + type: "test", name: "foo", needsExecutedOutputs: false, needsStaticOutputs: false, @@ -4492,6 +4494,7 @@ describe("Garden", () => { { explicit: true, kind: "Build", + type: "foo", name: "foo", needsExecutedOutputs: false, needsStaticOutputs: false,