-
Notifications
You must be signed in to change notification settings - Fork 264
boxcli: add basic tests for devbox shell #83
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
Conversation
679447c
to
1f3f9aa
Compare
brew update | ||
brew install dash zsh | ||
- name: Install Nix | ||
run: sh <(curl -L https://nixos.org/nix/install) --daemon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does nix get installed every single time the test runs? Can we cache this somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does install on every run. There might be a way to cache it, but I haven't looked into it yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ask because if we install nix every single time, devbox shell would be quite slow given we have to install the nix store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of installing nix, could we use a base image that has nix pre-installed? (for example, the same one we use in the dockerfile)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nvm, I see you're purposefully trying to test macos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing Nix does slow things down a lot. With these tests the total CI time is about 5 minutes.
I want to look into caching the Nix and Homebrew packages with the cache action, but as a first step I wanted to get the tests working.
1052675
to
187c509
Compare
Add tests that check that `devbox shell` launches successfully on the platforms (Linux and macOS) and shells (bash, dash, and zsh) that we support. Specifically, each test runs the equivalent of typing the following into your terminal: cd `mktemp -d` devbox init devbox add hello devbox shell hello exit exit The bulk of this change is the addition of some test helpers that handle launching shells and interacting with them. For now they live in the same file as the `boxcli` shell tests, but we can move them into their own `shelltest` package later on if necessary. With these test helpers in place, it should be a lot easier to add tests for more complicated scenarios. In order to run these tests in CI, the GitHub test jobs now install Nix along with some additional shells. They also run on both ubuntu-latest and macos-12 to make sure things work on both systems. The lint job also runs on Ubuntu and macOS to make sure that we don't inadvertently add platform-specific code that won't compile.
187c509
to
aeb809b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
func TestShellHelloBash(t *testing.T) { testShellHello(t, "bash") } | ||
func TestShellHelloDash(t *testing.T) { testShellHello(t, "dash") } | ||
func TestShellHelloZsh(t *testing.T) { testShellHello(t, "zsh") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanted to be really exhaustive, this could be the list:
- Bash
- Cmd
- Dash
- Elvish
- Fish
- Ion
- Nushell
- PowerShell
- Tcsh
- Xonsh
- Zsh
This is based on the list that starship
works with: https://starship.rs/guide/#%F0%9F%9A%80-installation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are a bunch more we could support. It's a bit of work because we have to implement the detection and using a custom shellrc. I should probably add some documentation on which shells we officially test and support.
Summary
Add tests that check that
devbox shell
launches successfully on the platforms (Linux and macOS) and shells (bash, dash, and zsh) that we support. Specifically, each test runs the equivalent of typing the following into your terminal:The bulk of this change is the addition of some test helpers that handle launching shells and interacting with them. For now they live in the same file as the
boxcli
shell tests, but we can move them into their ownshelltest
package later on if necessary. With these test helpers in place, it should be a lot easier to add tests for more complicated scenarios.In order to run these tests in CI, the GitHub test jobs now install Nix along with some additional shells. They also run on both ubuntu-latest and macos-12 to make sure things work on both systems. The lint job also runs on Ubuntu and macOS to make sure that we don't inadvertently add platform-specific code that won't compile.
How was it tested?
go test