-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow overriding
source.path
in remote actions (when using `s…
…ource.repository`) (#6750)
- Loading branch information
Showing
31 changed files
with
319 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: garden.io/v1 | ||
kind: Project | ||
name: test-project-remote-action | ||
environments: | ||
- name: local |
10 changes: 10 additions & 0 deletions
10
core/test/data/test-project-remote-action/remote-action-a/garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kind: Build | ||
name: remote-action-a | ||
type: exec | ||
spec: | ||
# This command tests presence of Docker | ||
# and in turn, if the action is running in the right subdirectory (remote repository root) | ||
command: [ls, Dockerfile] | ||
source: | ||
repository: | ||
url: https://github.com/garden-io/garden-example-remote-module-jworker.git#8f6da155581a567ffa28c410174d43d74eb4cb9b |
11 changes: 11 additions & 0 deletions
11
core/test/data/test-project-remote-action/remote-action-b/garden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
kind: Build | ||
name: remote-action-b | ||
type: exec | ||
spec: | ||
# This command tests presence of Worker.java | ||
# and in turn, if the action is running in the right subdirectory (src/main/java/worker) | ||
command: [ls, Worker.java] | ||
source: | ||
path: src/main/java/worker | ||
repository: | ||
url: https://github.com/garden-io/garden-example-remote-module-jworker.git#8f6da155581a567ffa28c410174d43d74eb4cb9b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2018-2024 Garden Technologies, Inc. <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { expect } from "chai" | ||
|
||
import type { Garden } from "../../../../src/garden.js" | ||
import { gardenPlugin } from "../../../../src/plugins/exec/exec.js" | ||
import type { ActionLog } from "../../../../src/logger/log-entry.js" | ||
import { createActionLog } from "../../../../src/logger/log-entry.js" | ||
import { getDataDir } from "../../../helpers.js" | ||
import { makeTestGarden } from "../../../helpers.js" | ||
import type { ConfigGraph } from "../../../../src/graph/config-graph.js" | ||
|
||
import { ACTION_RUNTIME_LOCAL } from "../../../../src/plugin/base.js" | ||
import { BuildTask } from "../../../../src/tasks/build.js" | ||
|
||
describe("remote actions", () => { | ||
context("test-project based tests", () => { | ||
const testProjectRoot = getDataDir("test-project-remote-action") | ||
const plugin = gardenPlugin | ||
|
||
let garden: Garden | ||
// let execProvider: ExecProvider | ||
let graph: ConfigGraph | ||
let log: ActionLog | ||
|
||
beforeEach(async () => { | ||
garden = await makeTestGarden(testProjectRoot, { plugins: [plugin] }) | ||
graph = await garden.getConfigGraph({ log: garden.log, emit: false }) | ||
// execProvider = await garden.resolveProvider({ log: garden.log, name: "exec" }) | ||
// const ctx = await garden.getPluginContext({ provider: execProvider, templateContext: undefined, events: undefined }) | ||
log = createActionLog({ log: garden.log, actionName: "", actionKind: "" }) | ||
await garden.clearBuilds() | ||
}) | ||
|
||
it("remote action source path should default to repository root", async () => { | ||
const action = graph.getBuild("remote-action-a") | ||
const resolvedAction = await garden.resolveAction({ action, log, graph }) | ||
|
||
const task = new BuildTask({ | ||
garden, | ||
action: resolvedAction, | ||
graph, | ||
log, | ||
force: true, | ||
}) | ||
|
||
const results = await garden.processTasks({ tasks: [task], throwOnError: true }) | ||
|
||
expect(results.results.getResult(task)?.result?.detail).to.eql({ | ||
buildLog: "Dockerfile", | ||
fresh: true, | ||
runtime: ACTION_RUNTIME_LOCAL, | ||
}) | ||
}) | ||
|
||
it("if remote action specifies source path, it should be relative from remote repository", async () => { | ||
const action = graph.getBuild("remote-action-b") | ||
const resolvedAction = await garden.resolveAction({ action, log, graph }) | ||
|
||
const task = new BuildTask({ | ||
garden, | ||
action: resolvedAction, | ||
graph, | ||
log, | ||
force: true, | ||
}) | ||
|
||
const results = await garden.processTasks({ tasks: [task], throwOnError: true }) | ||
|
||
expect(results.results.getResult(task)?.result?.detail).to.eql({ | ||
buildLog: "Worker.java", | ||
fresh: true, | ||
runtime: ACTION_RUNTIME_LOCAL, | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.