Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork436
Added library dependency support#351
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
12 commits Select commitHold shift + click to select a range
2a110df Added globals.ParseLibraryReferenceArgs method
cmaglie94c2adf Added check for missing library version/name in args
cmaglieafb5092 Added check for missing core/arch/version in core arg parsing
cmaglie3c2e364 Added infrastructure to handle 'dependency' field in library index
cmaglieb66178c 100% test coverage for librariesindexer module
cmaglie3d210c4 Added grpc call LibraryResolveDependencies (WIP)
cmaglie33c2bf4 Use semver.Dependency interface to represent a library dependency
cmaglie2edf3d1 Added library-dep resolution function in core modules
cmagliefa85cd0 Added implementation for LibraryResolveDependency grpc call
cmaglie196727e Implementation of deps install in 'lib install' command
cmaglie92db6f7 Added no-deps flag in lib install command
cmagliede882e4 Added lib deps command
cmaglieFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletionsarduino/libraries/librariesindex/index.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
113 changes: 113 additions & 0 deletionsarduino/libraries/librariesindex/index_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,113 @@ | ||
| /* | ||
| * This file is part of arduino-cli. | ||
| * | ||
| * Copyright 2018 ARDUINO SA (http://www.arduino.cc/) | ||
| * | ||
| * This software is released under the GNU General Public License version 3, | ||
| * which covers the main part of arduino-cli. | ||
| * The terms of this license can be found at: | ||
| * https://www.gnu.org/licenses/gpl-3.0.en.html | ||
| * | ||
| * You can be released from the requirements of the above licenses by purchasing | ||
| * a commercial license. Buying such a license is mandatory if you want to modify or | ||
| * otherwise use the software for commercial activities involving the Arduino | ||
| * software without disclosing the source code of your own applications. To purchase | ||
| * a commercial license, send an email to license@arduino.cc. | ||
| */ | ||
| package librariesindex | ||
| import ( | ||
| "fmt" | ||
| "testing" | ||
| "github.com/arduino/arduino-cli/arduino/libraries" | ||
| "github.com/arduino/go-paths-helper" | ||
| "github.com/stretchr/testify/require" | ||
| semver "go.bug.st/relaxed-semver" | ||
| ) | ||
| func TestIndexer(t *testing.T) { | ||
| fail1, err := LoadIndex(paths.New("testdata/inexistent")) | ||
| require.Error(t, err) | ||
| require.Nil(t, fail1) | ||
| fail2, err := LoadIndex(paths.New("testdata/invalid.json")) | ||
| require.Error(t, err) | ||
| require.Nil(t, fail2) | ||
| index, err := LoadIndex(paths.New("testdata/library_index.json")) | ||
| require.NoError(t, err) | ||
| require.Equal(t, 2380, len(index.Libraries), "parsed libraries count") | ||
| alp := index.Libraries["Arduino Low Power"] | ||
| require.NotNil(t, alp) | ||
| require.Equal(t, 4, len(alp.Releases)) | ||
| require.Equal(t, "Arduino Low Power@1.2.1", alp.Latest.String()) | ||
| require.Len(t, alp.Latest.Dependencies, 1) | ||
| require.Equal(t, "RTCZero", alp.Latest.Dependencies[0].GetName()) | ||
| require.Equal(t, "", alp.Latest.Dependencies[0].GetConstraint().String()) | ||
| require.Equal(t, "[1.0.0 1.1.0 1.2.0 1.2.1]", fmt.Sprintf("%v", alp.Versions())) | ||
| rtc100ref := &Reference{Name: "RTCZero", Version: semver.MustParse("1.0.0")} | ||
| require.Equal(t, "RTCZero@1.0.0", rtc100ref.String()) | ||
| rtc100 := index.FindRelease(rtc100ref) | ||
| require.NotNil(t, rtc100) | ||
| require.Equal(t, "RTCZero@1.0.0", rtc100.String()) | ||
| rtcLatestRef := &Reference{Name: "RTCZero"} | ||
| require.Equal(t, "RTCZero", rtcLatestRef.String()) | ||
| rtcLatest := index.FindRelease(rtcLatestRef) | ||
| require.NotNil(t, rtcLatest) | ||
| require.Equal(t, "RTCZero@1.6.0", rtcLatest.String()) | ||
| rtcInexistent := index.FindRelease(&Reference{ | ||
| Name: "RTCZero", | ||
| Version: semver.MustParse("0.0.0-blah"), | ||
| }) | ||
| require.Nil(t, rtcInexistent) | ||
| rtcInexistent = index.FindRelease(&Reference{ | ||
| Name: "RTCZero-blah", | ||
| }) | ||
| require.Nil(t, rtcInexistent) | ||
| rtc := index.FindIndexedLibrary(&libraries.Library{Name: "RTCZero"}) | ||
| require.NotNil(t, rtc) | ||
| require.Equal(t, "RTCZero", rtc.Name) | ||
| rtcUpdate := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero", Version: semver.MustParse("1.0.0")}) | ||
| require.NotNil(t, rtcUpdate) | ||
| require.Equal(t, "RTCZero@1.6.0", rtcUpdate.String()) | ||
| rtcNoUpdate := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero", Version: semver.MustParse("3.0.0")}) | ||
| require.Nil(t, rtcNoUpdate) | ||
| rtcInexistent2 := index.FindLibraryUpdate(&libraries.Library{Name: "RTCZero-blah", Version: semver.MustParse("1.0.0")}) | ||
| require.Nil(t, rtcInexistent2) | ||
| resolve1 := index.ResolveDependencies(alp.Releases["1.2.1"]) | ||
| require.Len(t, resolve1, 2) | ||
| require.Contains(t, resolve1, alp.Releases["1.2.1"]) | ||
| require.Contains(t, resolve1, rtc.Releases["1.6.0"]) | ||
| oauth010 := index.FindRelease(&Reference{Name: "Arduino_OAuth", Version: semver.MustParse("0.1.0")}) | ||
| require.NotNil(t, oauth010) | ||
| require.Equal(t, "Arduino_OAuth@0.1.0", oauth010.String()) | ||
| eccx133 := index.FindRelease(&Reference{Name: "ArduinoECCX08", Version: semver.MustParse("1.3.3")}) | ||
| require.NotNil(t, eccx133) | ||
| require.Equal(t, "ArduinoECCX08@1.3.3", eccx133.String()) | ||
| bear130 := index.FindRelease(&Reference{Name: "ArduinoBearSSL", Version: semver.MustParse("1.3.0")}) | ||
| require.NotNil(t, bear130) | ||
| require.Equal(t, "ArduinoBearSSL@1.3.0", bear130.String()) | ||
| http040 := index.FindRelease(&Reference{Name: "ArduinoHttpClient", Version: semver.MustParse("0.4.0")}) | ||
| require.NotNil(t, http040) | ||
| require.Equal(t, "ArduinoHttpClient@0.4.0", http040.String()) | ||
| resolve2 := index.ResolveDependencies(oauth010) | ||
| require.Len(t, resolve2, 4) | ||
| require.Contains(t, resolve2, oauth010) | ||
| require.Contains(t, resolve2, eccx133) | ||
| require.Contains(t, resolve2, bear130) | ||
| require.Contains(t, resolve2, http040) | ||
| } |
64 changes: 47 additions & 17 deletionsarduino/libraries/librariesindex/json.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
1 change: 1 addition & 0 deletionsarduino/libraries/librariesindex/testdata/invalid.json
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 @@ | ||
| { "invalid", |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.