Skip to content

[testing] Replace script-based tool installation with nix #3691

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

Merged
merged 1 commit into from
Feb 17, 2025
Merged

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Feb 1, 2025

Why this should be merged

Previously, binary tools like promtail and prometheus (enabling log and metrics collection) and kube and kind (enabling local kube clusters) were installed using bash scripts. A script-based approach, while simple, requires tedious and error-prone copying and committing to other repos (e.g. subnet-evm and hypersdk) that needed the same functionality.

Possible to rewrite the scripts to golang which allows usage via go run or go install. Simple enough if the versions never change, but still requires retrieving binaries, verifying their hashes for security, potentially dealing with tar archives. Still more complication if it becomes necessary to ensure the desired version is the one in the path.

Switching to nix, on the other hand, is an established way of solving the problem that doesn't involve maintaining code. Installing nix is a one-time operation not too different from homebrew, except that the result has more guarantees of reproducibility across linux and macos.

How this works

  • Replaces manual tool installation with a nix flake
  • Updates github actions to install nix where needed

How this was tested

CI, manually for direnv usage

Need to be documented in RELEASES.md?

N/A

@maru-ava maru-ava added testing This primarily focuses on testing ci This focuses on changes to the CI process labels Feb 1, 2025
@maru-ava maru-ava self-assigned this Feb 1, 2025
@maru-ava maru-ava force-pushed the nix branch 7 times, most recently from b22db15 to 827d7ea Compare February 1, 2025 23:07
@maru-ava maru-ava marked this pull request as ready for review February 1, 2025 23:18
Previously, binary tools like promtail and prometheus (enabling log
and metrics collection) and kube and kind (enabling local kube
clusters) were installed using bash scripts. A script-based approach,
while simple, requires tedious and error-prone copying and committing
to other repos (e.g. subnet-evm and hypersdk) that need the same
functionality.

Possible to rewrite the scripts to golang which allows usage via `go
run` or `go install`. Simple enough if the versions never change, but
still requires retrieving binaries, verifying their hashes for
security, and potentially dealing with tar archives. Still more
complicated if it becomes necessary to ensure the desired version is
the one in the path.

Switching to [nix](https://nixos.org/), on the other hand, is an
established way of solving the problem that doesn't involve
maintaining code. Installing nix is a one-time operation not too
different from homebrew, except that the result has more guarantees of
reproducibility across linux and macos.
@@ -51,6 +51,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-go-for-project
- uses: cachix/install-nix-action@v30
with:
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this github token is needed while it was not needed in the previous version of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous version of this file was not installing tools with nix. Provision of a github token is common in github actions where things will be downloaded, and avoids the possibility of being rate-limited that is common to anonymous usage of a given installation action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess this is what I should have led with: https://github.com/cachix/install-nix-action?tab=readme-ov-file#inputs-specify-using-with

tl;dr specifying a github token allows the cachix action to download from github without fear of being rate-limited.

@maru-ava maru-ava added this pull request to the merge queue Feb 17, 2025
Merged via the queue into master with commit af372a6 Feb 17, 2025
22 checks passed
@maru-ava maru-ava deleted the nix branch February 17, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci This focuses on changes to the CI process testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants