Skip to content

Commit 13143d1

Browse files
expose Incompatible properity in the API
1 parent 7bd4cd9 commit 13143d1

File tree

8 files changed

+78
-28
lines changed

8 files changed

+78
-28
lines changed

commands/board/listall.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func ListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListA
6868
ManuallyInstalled: platform.ManuallyInstalled,
6969
Indexed: platform.Indexed,
7070
MissingMetadata: !installedPlatformRelease.HasMetadata(),
71+
Incompatible: installedPlatformRelease.IsIncompatible(),
7172
}
7273

7374
toTest := []string{

commands/board/search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func Search(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchR
6666
if installedPlatformRelease != nil {
6767
rpcPlatform.Installed = installedPlatformRelease.Version.String()
6868
rpcPlatform.MissingMetadata = !installedPlatformRelease.HasMetadata()
69+
rpcPlatform.Incompatible = installedPlatformRelease.IsIncompatible()
6970
}
7071

7172
// Platforms that are not installed don't have a list of boards

commands/core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func PlatformReleaseToRPC(platformRelease *cores.PlatformRelease) *rpc.Platform
6464
Type: []string{platformRelease.Platform.Category},
6565
Indexed: platformRelease.Platform.Indexed,
6666
MissingMetadata: !platformRelease.HasMetadata(),
67+
Incompatible: platformRelease.IsIncompatible(),
6768
}
6869

6970
return result

commands/core/search.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
7575

7676
if allVersions {
7777
res = append(res, platform.GetAllReleases()...)
78+
continue
79+
}
80+
81+
// in case there isn't a compatible version fallback on the latest uncompatibile.
82+
if latestCompatibleRelease := platform.GetLatestCompatibleRelease(); latestCompatibleRelease != nil {
83+
res = append(res, latestCompatibleRelease)
7884
} else {
7985
res = append(res, latestRelease)
8086
}

commands/core/search_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
)
2727

2828
func TestPlatformSearch(t *testing.T) {
29-
3029
dataDir := paths.TempDir().Join("test", "data_dir")
3130
downloadDir := paths.TempDir().Join("test", "staging")
3231
t.Setenv("ARDUINO_DATA_DIR", dataDir.String())
@@ -64,6 +63,7 @@ func TestPlatformSearch(t *testing.T) {
6463
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
6564
Indexed: true,
6665
MissingMetadata: true,
66+
Incompatible: true,
6767
})
6868
require.Contains(t, res.SearchOutput, &rpc.Platform{
6969
Id: "Retrokits-RK002:arm",
@@ -78,6 +78,7 @@ func TestPlatformSearch(t *testing.T) {
7878
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
7979
Indexed: true,
8080
MissingMetadata: true,
81+
Incompatible: true,
8182
})
8283

8384
res, stat = PlatformSearch(&rpc.PlatformSearchRequest{
@@ -101,6 +102,7 @@ func TestPlatformSearch(t *testing.T) {
101102
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
102103
Indexed: true,
103104
MissingMetadata: true,
105+
Incompatible: true,
104106
})
105107

106108
// Search the Package Maintainer
@@ -125,6 +127,7 @@ func TestPlatformSearch(t *testing.T) {
125127
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
126128
Indexed: true,
127129
MissingMetadata: true,
130+
Incompatible: true,
128131
})
129132
require.Contains(t, res.SearchOutput, &rpc.Platform{
130133
Id: "Retrokits-RK002:arm",
@@ -139,6 +142,7 @@ func TestPlatformSearch(t *testing.T) {
139142
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
140143
Indexed: true,
141144
MissingMetadata: true,
145+
Incompatible: true,
142146
})
143147

144148
// Search using the Package name
@@ -163,6 +167,7 @@ func TestPlatformSearch(t *testing.T) {
163167
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
164168
Indexed: true,
165169
MissingMetadata: true,
170+
Incompatible: true,
166171
})
167172
require.Contains(t, res.SearchOutput, &rpc.Platform{
168173
Id: "Retrokits-RK002:arm",
@@ -177,6 +182,7 @@ func TestPlatformSearch(t *testing.T) {
177182
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
178183
Indexed: true,
179184
MissingMetadata: true,
185+
Incompatible: true,
180186
})
181187

182188
// Search using the Platform name
@@ -201,6 +207,7 @@ func TestPlatformSearch(t *testing.T) {
201207
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
202208
Indexed: true,
203209
MissingMetadata: true,
210+
Incompatible: true,
204211
})
205212
require.Contains(t, res.SearchOutput, &rpc.Platform{
206213
Id: "Retrokits-RK002:arm",
@@ -215,6 +222,7 @@ func TestPlatformSearch(t *testing.T) {
215222
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
216223
Indexed: true,
217224
MissingMetadata: true,
225+
Incompatible: true,
218226
})
219227

220228
// Search using a board name
@@ -266,6 +274,7 @@ func TestPlatformSearch(t *testing.T) {
266274
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
267275
Indexed: true,
268276
MissingMetadata: true,
277+
Incompatible: true,
269278
})
270279

271280
res, stat = PlatformSearch(&rpc.PlatformSearchRequest{
@@ -316,6 +325,7 @@ func TestPlatformSearch(t *testing.T) {
316325
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
317326
Indexed: true,
318327
MissingMetadata: true,
328+
Incompatible: true,
319329
})
320330
}
321331

internal/integrationtest/core/core_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ func TestCoreSearchNoArgs(t *testing.T) {
181181
for _, v := range strings.Split(strings.TrimSpace(string(stdout)), "\n") {
182182
lines = append(lines, strings.Fields(strings.TrimSpace(v)))
183183
}
184-
// Check the presence of test:[email protected]
185-
require.Contains(t, lines, []string{"test:x86", "3.0.0", "test_core"})
184+
// Check the absence of test:[email protected] because it contains incompatible deps
185+
require.NotContains(t, lines, []string{"test:x86", "3.0.0", "test_core"})
186186
numPlatforms = len(lines) - 1
187187

188188
// same thing in JSON format, also check the number of platforms found is the same
@@ -1143,4 +1143,22 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
11431143
_, stderr, err = cli.Run("core", "install", "incompatible_vendor:avr", additionalURLs)
11441144
require.Error(t, err)
11451145
require.Contains(t, string(stderr), "has no available releases for your OS")
1146+
1147+
// Core search --all shows incompatible field when a version is incompatible
1148+
stdout, _, err = cli.Run("core", "search", "--all", "--format", "json", additionalURLs)
1149+
require.NoError(t, err)
1150+
requirejson.Query(t, stdout,
1151+
`[.[] | select(.id == "foo_vendor:avr") | {latest: .latest, incompatible: .incompatible}] | sort_by(.latest)`,
1152+
`[
1153+
{"incompatible":null,"latest":"1.0.0"},
1154+
{"incompatible":null,"latest":"1.0.1"},
1155+
{"incompatible":true,"latest":"1.0.2"}
1156+
]`,
1157+
)
1158+
1159+
// Core search shows latest compatible version
1160+
stdout, _, err = cli.Run("core", "search", "--format", "json", additionalURLs)
1161+
require.NoError(t, err)
1162+
requirejson.Query(t, stdout, `.[] | select(.id == "foo_vendor:avr") | .latest`, `"1.0.1"`)
1163+
requirejson.Query(t, stdout, `.[] | select(.id == "incompatible_vendor:avr") | .incompatible`, `true`)
11461164
}

rpc/cc/arduino/cli/commands/v1/common.pb.go

Lines changed: 36 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/cc/arduino/cli/commands/v1/common.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ message Platform {
111111
// Newest available version of the platform containing all compatible
112112
// dependencies.
113113
string latest_compatible = 15;
114+
// True if the platform contains an incompatible dependency.
115+
bool incompatible = 16;
114116
}
115117

116118
message InstalledPlatformReference {

0 commit comments

Comments
 (0)