Skip to content

Commit cc1bbab

Browse files
expose Incompatible properity in the API
1 parent 2a9a291 commit cc1bbab

File tree

8 files changed

+78
-30
lines changed

8 files changed

+78
-30
lines changed

Diff for: commands/board/listall.go

+1
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{

Diff for: commands/board/search.go

+1
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

Diff for: commands/core.go

+1
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

Diff for: commands/core/search.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
7575

7676
if allVersions {
7777
res = append(res, platform.GetAllReleases()...)
78-
} else {
79-
res = append(res, latestRelease)
78+
continue
79+
}
80+
if latestCompatibleRelease := platform.GetLatestCompatibleRelease(); latestCompatibleRelease != nil {
81+
res = append(res, platform.GetLatestCompatibleRelease())
82+
continue
8083
}
84+
res = append(res, latestRelease)
8185
}
8286
}
8387
}

Diff for: commands/core/search_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
)
2828

2929
func TestPlatformSearch(t *testing.T) {
30-
3130
dataDir := paths.TempDir().Join("test", "data_dir")
3231
downloadDir := paths.TempDir().Join("test", "staging")
3332
os.Setenv("ARDUINO_DATA_DIR", dataDir.String())
@@ -65,6 +64,7 @@ func TestPlatformSearch(t *testing.T) {
6564
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
6665
Indexed: true,
6766
MissingMetadata: true,
67+
Incompatible: true,
6868
})
6969
require.Contains(t, res.SearchOutput, &rpc.Platform{
7070
Id: "Retrokits-RK002:arm",
@@ -79,6 +79,7 @@ func TestPlatformSearch(t *testing.T) {
7979
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
8080
Indexed: true,
8181
MissingMetadata: true,
82+
Incompatible: true,
8283
})
8384

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

107109
// Search the Package Maintainer
@@ -126,6 +128,7 @@ func TestPlatformSearch(t *testing.T) {
126128
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
127129
Indexed: true,
128130
MissingMetadata: true,
131+
Incompatible: true,
129132
})
130133
require.Contains(t, res.SearchOutput, &rpc.Platform{
131134
Id: "Retrokits-RK002:arm",
@@ -140,6 +143,7 @@ func TestPlatformSearch(t *testing.T) {
140143
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
141144
Indexed: true,
142145
MissingMetadata: true,
146+
Incompatible: true,
143147
})
144148

145149
// Search using the Package name
@@ -164,6 +168,7 @@ func TestPlatformSearch(t *testing.T) {
164168
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
165169
Indexed: true,
166170
MissingMetadata: true,
171+
Incompatible: true,
167172
})
168173
require.Contains(t, res.SearchOutput, &rpc.Platform{
169174
Id: "Retrokits-RK002:arm",
@@ -178,6 +183,7 @@ func TestPlatformSearch(t *testing.T) {
178183
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
179184
Indexed: true,
180185
MissingMetadata: true,
186+
Incompatible: true,
181187
})
182188

183189
// Search using the Platform name
@@ -202,6 +208,7 @@ func TestPlatformSearch(t *testing.T) {
202208
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
203209
Indexed: true,
204210
MissingMetadata: true,
211+
Incompatible: true,
205212
})
206213
require.Contains(t, res.SearchOutput, &rpc.Platform{
207214
Id: "Retrokits-RK002:arm",
@@ -216,6 +223,7 @@ func TestPlatformSearch(t *testing.T) {
216223
Help: &rpc.HelpResources{Online: "https://www.retrokits.com/rk002/arduino"},
217224
Indexed: true,
218225
MissingMetadata: true,
226+
Incompatible: true,
219227
})
220228

221229
// Search using a board name
@@ -267,6 +275,7 @@ func TestPlatformSearch(t *testing.T) {
267275
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
268276
Indexed: true,
269277
MissingMetadata: true,
278+
Incompatible: true,
270279
})
271280

272281
res, stat = PlatformSearch(&rpc.PlatformSearchRequest{
@@ -317,6 +326,7 @@ func TestPlatformSearch(t *testing.T) {
317326
Help: &rpc.HelpResources{Online: "http://www.arduino.cc/en/Reference/HomePage"},
318327
Indexed: true,
319328
MissingMetadata: true,
329+
Incompatible: true,
320330
})
321331
}
322332

Diff for: internal/integrationtest/core/core_test.go

+20-2
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
}

Diff for: rpc/cc/arduino/cli/commands/v1/common.pb.go

+36-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: rpc/cc/arduino/cli/commands/v1/common.proto

+2
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)