-
Notifications
You must be signed in to change notification settings - Fork 129
[BE-1876] Integrate nixpkgs plugin #1156
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
Open
marcell-vida
wants to merge
29
commits into
master
Choose a base branch
from
BE-1876-integrate-nixpkgs-plugin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
081f066
[BE-1876] Integrate nixpkgs plugin
marcell-vida eb05dd2
Check for version in index, remove plugin version pinning, fixes
marcell-vida 1dfba3d
*
marcell-vida 3738f29
Fix test version
marcell-vida ebe94d2
Rename tool
marcell-vida fce56eb
Remove index checking, use listing
marcell-vida d4c3efd
*
marcell-vida c177efe
Timeout on test
marcell-vida 9aaccad
Simplify things
ofalvai 95548fe
Get rid of MiseExecutor, make ExecEnv mockable instead
ofalvai adc95ec
Change plugin ID to final value
ofalvai 24fd4b5
Unit tests
ofalvai aca4ce3
Add force flag for integration testing
ofalvai a2d8363
Integration tests
ofalvai 972e50b
Add check before executing nix commands
ofalvai 59c8133
Make feature flag value true instead of 1
ofalvai 7e4bff6
AI reviewer fixes
marcell-vida 945d3a3
Merge branch 'master' into BE-1876-integrate-nixpkgs-plugin
marcell-vida 7d750f5
chore: trigger CI checks
marcell-vida d6e6b20
Raise timeout, install backend even with force install
marcell-vida 67f994c
Lint
marcell-vida 6f8f212
Fix tests, update plugin
marcell-vida 488b138
Decrease validate timeout
marcell-vida 45d52d4
Fix tests
marcell-vida dec4eb0
*
marcell-vida 28bb814
Tests working on stable stacks too, consistent commenting
marcell-vida 68e3e49
Remove nix availability check
marcell-vida e9574f3
Fake nix checking in tests instead of env var override
ofalvai ba0feab
Merge branch 'master' into BE-1876-integrate-nixpkgs-plugin
marcell-vida File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
integrationtests/toolprovider/mise/install_nixpkgs_ruby_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //go:build linux_and_mac | ||
| // +build linux_and_mac | ||
|
|
||
| package mise | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/bitrise-io/bitrise/v2/toolprovider/mise" | ||
| "github.com/bitrise-io/bitrise/v2/toolprovider/provider" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestMiseInstallNixpkgsRuby(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| tool string | ||
| version string | ||
| resolutionStrategy provider.ResolutionStrategy | ||
| want string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "Install specific version", | ||
| tool: "ruby", | ||
| version: "3.3.9", | ||
| resolutionStrategy: provider.ResolutionStrategyStrict, | ||
| want: "3.3.9", | ||
| }, | ||
| { | ||
| name: "Install fuzzy version and released strategy", | ||
| tool: "ruby", | ||
| version: "3.1", // EOL version, won't receive new patch versions suddenly | ||
| resolutionStrategy: provider.ResolutionStrategyLatestReleased, | ||
| want: "3.1.7", | ||
| }, | ||
| { | ||
| name: "Install fuzzy version and installed strategy", | ||
| tool: "ruby", | ||
| version: "3.1", // EOL version, won't receive new patch versions | ||
| resolutionStrategy: provider.ResolutionStrategyLatestInstalled, | ||
| want: "3.1.7", | ||
| }, | ||
| { | ||
| name: "Nonexistent version in nixpkgs index", | ||
| tool: "ruby", | ||
| version: "0.1.999", | ||
| resolutionStrategy: provider.ResolutionStrategyStrict, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "Install some other tool with forced nixpkgs backend", | ||
| tool: "node", | ||
| version: "22.22.1", | ||
| resolutionStrategy: provider.ResolutionStrategyStrict, | ||
| wantErr: true, | ||
| }, | ||
| } | ||
|
|
||
| t.Setenv("BITRISE_TOOLSETUP_FAST_INSTALL", "true") | ||
| t.Setenv("BITRISE_TOOLSETUP_FAST_INSTALL_FORCE", "true") | ||
|
|
||
| for _, tt := range tests { | ||
| miseInstallDir := t.TempDir() | ||
| miseDataDir := t.TempDir() | ||
| miseProvider, err := mise.NewToolProvider(miseInstallDir, miseDataDir) | ||
| require.NoError(t, err) | ||
|
|
||
| err = miseProvider.Bootstrap() | ||
| require.NoError(t, err) | ||
|
|
||
| t.Run(tt.name, func(t *testing.T) { | ||
| request := provider.ToolRequest{ | ||
| ToolName: provider.ToolID(tt.tool), | ||
| UnparsedVersion: tt.version, | ||
| ResolutionStrategy: tt.resolutionStrategy, | ||
| } | ||
| result, installErr := miseProvider.InstallTool(request) | ||
|
|
||
| if tt.wantErr { | ||
| require.Error(t, installErr) | ||
| return | ||
| } | ||
| require.NoError(t, installErr) | ||
| if tt.tool == "ruby" { | ||
| // We purposely return ruby with the nixpkgs: prefix for environment activation later | ||
| require.Equal(t, provider.ToolID("nixpkgs:ruby"), result.ToolName) | ||
| } else { | ||
| require.Equal(t, provider.ToolID(tt.tool), result.ToolName) | ||
| } | ||
| require.Equal(t, tt.want, result.ConcreteVersion) | ||
| require.False(t, result.IsAlreadyInstalled) | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package mise | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "time" | ||
| ) | ||
|
|
||
| type fakeExecEnv struct { | ||
| // responses maps command strings to their outputs. | ||
| responses map[string]string | ||
| // errors maps command strings to errors. | ||
| errors map[string]error | ||
| } | ||
|
|
||
| func newFakeExecEnv() *fakeExecEnv { | ||
| return &fakeExecEnv{ | ||
| responses: make(map[string]string), | ||
| errors: make(map[string]error), | ||
| } | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) setResponse(cmdKey string, output string) { | ||
| m.responses[cmdKey] = output | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) setError(cmdKey string, err error) { | ||
| m.errors[cmdKey] = err | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) InstallDir() string { | ||
| return "/fake/mise/install/dir" | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) RunMise(args ...string) (string, error) { | ||
| return m.runCommand(args...) | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) RunMisePlugin(args ...string) (string, error) { | ||
| return m.runCommand(append([]string{"plugin"}, args...)...) | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) RunMiseWithTimeout(timeout time.Duration, args ...string) (string, error) { | ||
| return m.runCommand(args...) | ||
| } | ||
|
|
||
| func (m *fakeExecEnv) runCommand(args ...string) (string, error) { | ||
| cmdKey := strings.Join(args, " ") | ||
|
|
||
| if err, ok := m.errors[cmdKey]; ok { | ||
| return "", err | ||
| } | ||
|
|
||
| if output, ok := m.responses[cmdKey]; ok { | ||
| return output, nil | ||
| } | ||
|
|
||
| return "", fmt.Errorf("no mock response configured for command: %s", cmdKey) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.