Skip to content

Commit 6d7e0cc

Browse files
authored
Merge branch 'master' into massi/rpc-monitor
2 parents d2acae9 + 620a4c1 commit 6d7e0cc

38 files changed

+481
-266
lines changed

Diff for: .dependabot/config.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ update_configs:
55
update_schedule: "daily"
66
allowed_updates:
77
- match:
8-
update_type: "security"
8+
update_type: "security"
9+
default_labels:
10+
- "component/dependencies"

Diff for: .drone.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,36 @@ name: default
33

44
steps:
55
- name: lint
6-
image: arduino/arduino-cli:drone-0.2.1
6+
image: arduino/arduino-cli:drone-1.0
77
commands:
88
# Check if the Go code is properly formatted and run the linter
99
- task check
1010
# Ensure protobufs compile
1111
- task protoc
1212

1313
- name: build
14-
image: arduino/arduino-cli:drone-0.2.1
14+
image: arduino/arduino-cli:drone-1.0
1515
commands:
1616
- task build
1717

1818
- name: test
19-
image: arduino/arduino-cli:drone-0.2.1
19+
image: arduino/arduino-cli:drone-1.0
2020
commands:
21-
- task test
21+
- task test-unit
2222
- task test-legacy
2323

24+
- name: integration
25+
image: arduino/arduino-cli:drone-1.0
26+
failure: ignore # work in progress, we know some tests will fail at the moment
27+
commands:
28+
- pip install -r test/requirements.txt
29+
- task test-integration
30+
2431
# Contrary to other CI platforms, uploading reports to Codecov requires Drone to provide a token.
2532
# To avoid exposing the Codecov token to external PRs, we only upload coverage when we merge on
2633
# `master`.
2734
- name: coverage
28-
image: arduino/arduino-cli:drone-0.2.1
35+
image: arduino/arduino-cli:drone-1.0
2936
environment:
3037
CODECOV_TOKEN:
3138
from_secret: codecov_token

Diff for: .gitignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/debug
22
/arduino-cli
33
/main
4-
/.vscode/settings.json
4+
/.vscode/
55
/cmd/formatter/debug.test
66
/arduino-cli.yaml
77
/wiki
88
.idea
9-
coverage_*.txt
9+
coverage_*.txt
10+
__pycache__
11+
venv
12+
.pytest_cache

Diff for: Dockerfiles/CI/Dockerfile

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
FROM golang:1.12
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
4-
bzip2 \
5-
unzip \
4+
bzip2 \
5+
unzip \
66
&& rm -rf /var/lib/apt/lists/*
77

88
ENV PROTOBUF_VER 3.8.0
9+
ENV PATH="/miniconda/bin:${PATH}"
910

1011
# NOTE: most of the following assume WORDKIR is '/'
1112
RUN set -ex \
@@ -20,5 +21,11 @@ RUN set -ex \
2021
&& go get github.com/golang/protobuf/protoc-gen-go \
2122
&& mkdir protobuf && cd protobuf \
2223
&& curl -LO https://github.com/google/protobuf/releases/download/v$PROTOBUF_VER/protoc-$PROTOBUF_VER-linux-x86_64.zip \
23-
&& unzip protoc-$PROTOBUF_VER-linux-x86_64.zip && cp ./bin/* /bin/ \
24-
&& cd .. && rm -rf protobuf
24+
&& unzip protoc-$PROTOBUF_VER-linux-x86_64.zip \
25+
&& cp ./bin/* /bin/ \
26+
# protoc will search for default includes in the path of the binary
27+
&& cp -r ./include /bin/ \
28+
&& cd .. && rm -rf protobuf \
29+
# Install a recent version of Python
30+
&& curl -o $HOME/miniconda.sh -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
31+
&& chmod +x $HOME/miniconda.sh && bash ~/miniconda.sh -b -p /miniconda && rm -f $HOME/miniconda.sh

Diff for: Taskfile.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ tasks:
2121
test-unit:
2222
desc: Run unit tests only
2323
cmds:
24-
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }}
24+
- go test -short {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
2525

2626
test-integration:
2727
desc: Run integration tests only
2828
cmds:
2929
- go test -run Integration {{ default "-v" .GOFLAGS }} -coverprofile=coverage_integ.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
30+
- pytest test/
3031

3132
test-legacy:
3233
desc: Run tests for the `legacy` package
3334
cmds:
34-
- go test {{ default "-v" .GOFLAGS }} ./legacy/...
35+
- go test {{ default "-v -failfast" .GOFLAGS }} ./legacy/...
3536

3637
test-unit-race:
3738
desc: Run unit tests only with race condition detection

Diff for: arduino/cores/cores.go

+30-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package cores
1919

2020
import (
21+
"encoding/json"
2122
"strings"
2223

2324
paths "github.com/arduino/go-paths-helper"
@@ -41,14 +42,13 @@ type PlatformRelease struct {
4142
Resource *resources.DownloadResource
4243
Version *semver.Version
4344
BoardsManifest []*BoardManifest
44-
Dependencies ToolDependencies // The Dependency entries to load tools.
45-
Platform *Platform `json:"-"`
46-
47-
Properties *properties.Map `json:"-"`
48-
Boards map[string]*Board `json:"-"`
49-
Programmers map[string]*properties.Map `json:"-"`
50-
Menus *properties.Map `json:"-"`
51-
InstallDir *paths.Path `json:"-"`
45+
Dependencies ToolDependencies // The Dependency entries to load tools.
46+
Platform *Platform `json:"-"`
47+
Properties *properties.Map `json:"-"`
48+
Boards map[string]*Board `json:"-"`
49+
Programmers map[string]*properties.Map `json:"-"`
50+
Menus *properties.Map `json:"-"`
51+
InstallDir *paths.Path `json:"-"`
5252
}
5353

5454
// BoardManifest contains information about a board. These metadata are usually
@@ -226,3 +226,25 @@ func (release *PlatformRelease) String() string {
226226
}
227227
return release.Platform.String() + "@" + version
228228
}
229+
230+
// MarshalJSON provides a more user friendly serialization for
231+
// PlatformRelease objects.
232+
func (release *PlatformRelease) MarshalJSON() ([]byte, error) {
233+
latestStr := ""
234+
latest := release.Platform.GetLatestRelease()
235+
if latest != nil {
236+
latestStr = latest.Version.String()
237+
}
238+
239+
return json.Marshal(&struct {
240+
ID string `json:"ID,omitempty"`
241+
Installed string `json:"Installed,omitempty"`
242+
Latest string `json:"Latest,omitempty"`
243+
Name string `json:"Name,omitempty"`
244+
}{
245+
ID: release.Platform.String(),
246+
Installed: release.Version.String(),
247+
Latest: latestStr,
248+
Name: release.Platform.Name,
249+
})
250+
}

Diff for: arduino/cores/packageindex/index.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/arduino/arduino-cli/arduino/cores"
2525
"github.com/arduino/arduino-cli/arduino/resources"
2626
"github.com/arduino/go-paths-helper"
27-
"go.bug.st/relaxed-semver"
27+
semver "go.bug.st/relaxed-semver"
2828
)
2929

3030
// Index represents Cores and Tools struct as seen from package_index.json file.
@@ -97,13 +97,13 @@ type indexHelp struct {
9797

9898
// MergeIntoPackages converts the Index data into a cores.Packages and merge them
9999
// with the existing conents of the cores.Packages passed as parameter.
100-
func (index Index) MergeIntoPackages(outPackages *cores.Packages) {
100+
func (index Index) MergeIntoPackages(outPackages cores.Packages) {
101101
for _, inPackage := range index.Packages {
102102
inPackage.extractPackageIn(outPackages)
103103
}
104104
}
105105

106-
func (inPackage indexPackage) extractPackageIn(outPackages *cores.Packages) {
106+
func (inPackage indexPackage) extractPackageIn(outPackages cores.Packages) {
107107
outPackage := outPackages.GetOrCreatePackage(inPackage.Name)
108108
outPackage.Maintainer = inPackage.Maintainer
109109
outPackage.WebsiteURL = inPackage.WebsiteURL

Diff for: arduino/cores/packagemanager/download.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
"github.com/arduino/arduino-cli/arduino/cores"
2525
"go.bug.st/downloader"
26-
"go.bug.st/relaxed-semver"
26+
semver "go.bug.st/relaxed-semver"
2727
)
2828

2929
// PlatformReference represents a tuple to identify a Platform
@@ -44,7 +44,7 @@ func (platform *PlatformReference) String() string {
4444
// FindPlatform returns the Platform matching the PlatformReference or nil if not found.
4545
// The PlatformVersion field of the reference is ignored.
4646
func (pm *PackageManager) FindPlatform(ref *PlatformReference) *cores.Platform {
47-
targetPackage, ok := pm.GetPackages().Packages[ref.Package]
47+
targetPackage, ok := pm.Packages[ref.Package]
4848
if !ok {
4949
return nil
5050
}
@@ -71,7 +71,7 @@ func (pm *PackageManager) FindPlatformRelease(ref *PlatformReference) *cores.Pla
7171
// FindPlatformReleaseDependencies takes a PlatformReference and returns a set of items to download and
7272
// a set of outputs for non existing platforms.
7373
func (pm *PackageManager) FindPlatformReleaseDependencies(item *PlatformReference) (*cores.PlatformRelease, []*cores.ToolRelease, error) {
74-
targetPackage, exists := pm.packages.Packages[item.Package]
74+
targetPackage, exists := pm.Packages[item.Package]
7575
if !exists {
7676
return nil, nil, fmt.Errorf("package %s not found", item.Package)
7777
}
@@ -94,7 +94,7 @@ func (pm *PackageManager) FindPlatformReleaseDependencies(item *PlatformReferenc
9494
}
9595

9696
// replaces "latest" with latest version too
97-
toolDeps, err := pm.packages.GetDepsOfPlatformRelease(release)
97+
toolDeps, err := pm.Packages.GetDepsOfPlatformRelease(release)
9898
if err != nil {
9999
return nil, nil, fmt.Errorf("getting tool dependencies for platform %s: %s", release.String(), err)
100100
}

Diff for: arduino/cores/packagemanager/install_uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (pm *PackageManager) UninstallTool(toolRelease *cores.ToolRelease) error {
127127
// passed as parameter
128128
func (pm *PackageManager) IsToolRequired(toolRelease *cores.ToolRelease) bool {
129129
// Search in all installed platforms
130-
for _, targetPackage := range pm.packages.Packages {
130+
for _, targetPackage := range pm.Packages {
131131
for _, platform := range targetPackage.Platforms {
132132
if platformRelease := pm.GetInstalledPlatformRelease(platform); platformRelease != nil {
133133
if platformRelease.RequiresToolRelease(toolRelease) {

Diff for: arduino/cores/packagemanager/loader.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
112112
continue
113113
}
114114

115-
targetPackage := pm.packages.GetOrCreatePackage(packager)
115+
targetPackage := pm.Packages.GetOrCreatePackage(packager)
116116
if err := pm.loadPlatforms(targetPackage, architectureParentPath); err != nil {
117117
return fmt.Errorf("loading package %s: %s", packager, err)
118118
}
@@ -419,7 +419,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
419419
}
420420

421421
for packager, toolsData := range all.FirstLevelOf() {
422-
targetPackage := pm.packages.GetOrCreatePackage(packager)
422+
targetPackage := pm.Packages.GetOrCreatePackage(packager)
423423

424424
for toolName, toolVersion := range toolsData.AsMap() {
425425
tool := targetPackage.GetOrCreateTool(toolName)
@@ -431,7 +431,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
431431
}
432432
} else {
433433
// otherwise load the tools inside the unnamed package
434-
unnamedPackage := pm.packages.GetOrCreatePackage("")
434+
unnamedPackage := pm.Packages.GetOrCreatePackage("")
435435
pm.loadToolsFromPackage(unnamedPackage, toolsPath)
436436
}
437437
return nil

0 commit comments

Comments
 (0)