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

improvement: make sure artifacts are always fetched #6532

Merged
merged 10 commits into from
Oct 17, 2024

Conversation

10ko
Copy link
Member

@10ko 10ko commented Oct 11, 2024

What this PR does / why we need it:

When executing Run or Test actions of type exec, we now always try to export the artifacts.
More specifically, we make sure to fetch artifacts in the case of:

  • A spec.command failing with a non-zero exit code.
    • In this case we will only log an errror in case of failure while fetching artifacts.
  • A spec.command throwing unexpectedly.
    • Same as above, only a warning.

In case the spec.command runs successfully and the fetching fails, we maintain the current behaviour of throwing an error.

This PR closes #6524

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

vvagaytsev
vvagaytsev previously approved these changes Oct 11, 2024
Copy link
Collaborator

@vvagaytsev vvagaytsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@10ko
Copy link
Member Author

10ko commented Oct 11, 2024

Sorry I should have made it a draft. These changes do not account to all the use-cases unfortunately, since if the run command returns a non-zero exit code, it will not throw. So I am amending the code as we speak.

@vvagaytsev vvagaytsev dismissed their stale review October 11, 2024 12:06

Still a WIP PR

@10ko
Copy link
Member Author

10ko commented Oct 11, 2024

Good to go now, @vvagaytsev

core/src/plugins/exec/test.ts Outdated Show resolved Hide resolved
@@ -32,8 +32,34 @@ export type ExecRun = GardenSdkActionDefinitionActionType<typeof execRun>
execRun.addHandler("run", async ({ artifactsPath, log, action, ctx }) => {
const startedAt = new Date()
const { command, env, artifacts } = action.getSpec()
const runCommandErrors: unknown[] = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's always one element in the array, I think it's cleaner to use let here:

Suggested change
const runCommandErrors: unknown[] = []
let runCommandError: unknown | undefined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runCommandErrors is never reassigned, it will give you a type error if you use let.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's never reassigned because you push an element to the array, but why use an array in the first place if it'll never have more than one element?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaah, that's what you meant. Sorry didn't understand you from your first comment. Sure thing, that makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@10ko I've pushed a commit with the change I had in mind, does it look good to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries :D

10ko and others added 2 commits October 17, 2024 11:02
Co-authored-by: Steffen Neubauer <steffen@garden.io>
@10ko 10ko enabled auto-merge October 17, 2024 11:52
Copy link
Member

@stefreak stefreak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to merge if you think my commit is ok 👍

@10ko 10ko added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit 593c9cb Oct 17, 2024
40 checks passed
@10ko 10ko deleted the improve-fetching-artifacts branch October 17, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Test exec doesn't copy artifacts if command exits with non-0 code
3 participants