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

APIs to support Terminal integration #638

Merged
merged 11 commits into from
Aug 6, 2024
Merged

APIs to support Terminal integration #638

merged 11 commits into from
Aug 6, 2024

Conversation

sourishkrout
Copy link
Member

@sourishkrout sourishkrout commented Jul 24, 2024

First stab at providing a session fork/rollup terminal. To make this work following provisional changes were necessary:

  1. Beta subcommand to source the current state of the environment, i.e. eval $(runme beta env source...) - similar to how eval $(ssh-agent) works.
  2. Subcommand hits gRPC directly, will likely want to move this to an abstraction later.
  3. Had to silent some of the autoconf errors since it currently relies on the presence of runme.yaml - will walk this back as part of building out runme beta cmds & autoconf. However, don't want to hold up Runme Terminal progress.
  4. Inserted leading spaces into the trap mechanism to skip shell history.

@sourishkrout sourishkrout marked this pull request as draft July 24, 2024 20:41
@sourishkrout sourishkrout force-pushed the seb/terminal branch 4 times, most recently from da505d6 to 0646c78 Compare July 30, 2024 23:35
@sourishkrout sourishkrout marked this pull request as ready for review July 31, 2024 01:02
@sourishkrout
Copy link
Member Author

Please review @adambabik. The beta sub cmds are provisional to enable the integration. We'll clean this up as part of a consolidated effort to build out the remaining CLI gap.

@sourishkrout
Copy link
Member Author

Also, any idea why TestTerminalCommand_EnvPropagation is so flakey?

Copy link
Collaborator

@adambabik adambabik left a comment

Choose a reason for hiding this comment

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

I added a few comments but no blockers.

internal/cmd/beta/beta_cmd.go Outdated Show resolved Hide resolved
internal/cmd/beta/beta_cmd.go Outdated Show resolved Hide resolved
internal/cmd/beta/beta_cmd.go Outdated Show resolved Hide resolved
internal/cmd/beta/beta_cmd.go Outdated Show resolved Hide resolved
internal/command/command_terminal.go Outdated Show resolved Hide resolved
internal/command/env_shell.go Show resolved Hide resolved
@adambabik
Copy link
Collaborator

Also, any idea why TestTerminalCommand_EnvPropagation is so flakey?

It relies on the output of bash, but looking at the stack trace in the CI, it seems that _, err = stdinW.Write([]byte{0x04}) // EOT does not necessarily works as expected. Maybe you can try to replace it with _, err = stdinW.Write([]byte("exit\n")). This might be more reliable than sending a signal via stdin.

On macOS it seems fine:

go test -count=5 -timeout 10s -run ^TestTerminalCommand_EnvPropagation$ github.com/stateful/runme/v3/internal/command

@sourishkrout
Copy link
Member Author

On macOS it seems fine:

go test -count=5 -timeout 10s -run ^TestTerminalCommand_EnvPropagation$ github.com/stateful/runme/v3/internal/command

Yep, it runs pretty reliable on macOS but does the inverse on Linux/CI

Copy link

sonarcloud bot commented Aug 6, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
8.7% Duplication on New Code (required ≤ 5%)

See analysis details on SonarCloud

@sourishkrout sourishkrout merged commit 760505e into main Aug 6, 2024
6 of 7 checks passed
@sourishkrout sourishkrout deleted the seb/terminal branch August 6, 2024 17:19
@adambabik
Copy link
Collaborator

On macOS it seems fine:

go test -count=5 -timeout 10s -run ^TestTerminalCommand_EnvPropagation$ github.com/stateful/runme/v3/internal/command

Yep, it runs pretty reliable on macOS but does the inverse on Linux/CI

I tried to replicate it in a Docker container and it seems much more stable after this change. Usually it's a good indicator for running in the CI. Let's keep an eye on it.

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.

2 participants