Skip to content

Conversation

@shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented May 14, 2025

Why

This part of the codebase was missing test coverage. I plan on changing the execution of commands to inline the script content and these tests are required to ensure I don't break anything (relevant discussion: #2862 (comment))

// Variant of [Execv] that runs the given script through a shell
func ShellExecv(content, dir string, env []string) error {
newOpts, err := shellExecvOpts(content, dir, env)
opts, err := shellExecvOpts(content, dir, env)
Copy link
Contributor Author

@shreyas-goenka shreyas-goenka May 14, 2025

Choose a reason for hiding this comment

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

small typo fix based on: #2862 (comment)


# Disable on Mac
#mac = false
#darwin = false
Copy link
Contributor Author

@shreyas-goenka shreyas-goenka May 14, 2025

Choose a reason for hiding this comment

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

Fixes small typo, Mac OS is "darwin", not "mac" for GOOS. You need to set darwin = false for this to work.

@shreyas-goenka shreyas-goenka changed the title Add test for build command execution Add tests for shell execution on artifacts build May 14, 2025
@shreyas-goenka shreyas-goenka marked this pull request as ready for review May 14, 2025 13:53
@shreyas-goenka shreyas-goenka marked this pull request as draft May 14, 2025 14:05
@shreyas-goenka shreyas-goenka marked this pull request as ready for review May 14, 2025 14:09
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

How escape characters are interpreted by default depends on the shell.

But why are you testing that behavior here? It adds nuance to these test cases that isn't instrumental for the logic we implement. If you drop the echo with the newlines from the test, all comments about newlines can be removed, and we retain the same level of coverage from my pov.

@shreyas-goenka
Copy link
Contributor Author

@pietern That was intentionally added to assert that the shell a user chooses in executable is the one commands are being run on. This was not tested before.

I looked into ways to do this assertion and the new line method was the best I could find. echo $SHELL does not work because the $SHELL environment variable is inherited from any parent shells used to spawn the child shell.

@shreyas-goenka shreyas-goenka requested a review from pietern May 22, 2025 12:12

>>> [CLI] bundle deploy
Building my_artifact...
Warn: my_artifact: Build succeeded
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, this message was removed in #2987 so you probably need to regenerate the tests.

@denik denik temporarily deployed to test-trigger-is June 5, 2025 12:53 — with GitHub Actions Inactive
@shreyas-goenka shreyas-goenka added this pull request to the merge queue Jun 6, 2025
Merged via the queue into main with commit 48fdfb2 Jun 6, 2025
10 checks passed
@shreyas-goenka shreyas-goenka deleted the add-shell-test branch June 6, 2025 14:30
github-merge-queue bot pushed a commit that referenced this pull request Jun 13, 2025
## Changes
This PR inlines the script content using the `-c` flag in bash and sh
instead of passing them in via `-e <file>`.

## Why
Based on discussion in
#2862 (comment).
Getting rid of the temp file means we no longer have to clean up the
temporary file created.

## Tests
Tests that were added in: #2884
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.

4 participants