Skip to content

Commit a11b683

Browse files
committed
Merge branch 'master' into massi/drone
2 parents 3003827 + 5cca8e2 commit a11b683

34 files changed

+147
-56
lines changed

Diff for: .golangci.yml

-40
This file was deleted.

Diff for: .travis.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,21 @@ env:
99
# Anything in before_script that returns a nonzero exit code will flunk the
1010
# build and immediately stop. It's sorta like having set -e enabled in bash.
1111
# Make sure golangci-lint is vendored.
12-
before_install:
13-
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.16.0
12+
install:
1413
- curl -sL https://taskfile.dev/install.sh | sh
15-
16-
install: true
14+
- go get github.com/golangci/govet
15+
- go get golang.org/x/lint/golint
1716

1817
script:
19-
# Check if the code is formatted
20-
- $(exit $(go fmt ./... | wc -l))
21-
# Run linter
22-
- golangci-lint run
18+
# Check if the code is formatted and run linter
19+
- ./bin/task check
2320
# Build and test
2421
- ./bin/task build
2522
- ./bin/task test
2623
- ./bin/task test-legacy
2724

2825
after_success:
29-
- bash <(curl -s https://codecov.io/bash) -cF unittests,integration
26+
- bash <(curl -s https://codecov.io/bash) -cF unit -f '*_unit.txt'
27+
- bash <(curl -s https://codecov.io/bash) -cF integ -f '*_integ.txt'
3028

3129

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,13 @@ Currently Unit and Integration test are available for launch in 2 ways:
344344

345345
```
346346
* build: Build the project
347-
* test: Run the full testsuite
347+
* check: Check fmt and lint, `legacy` will be skipped
348+
* check-legacy: Check fmt and lint for the `legacy` package
349+
* test: Run the full testsuite, `legacy` will be skipped
348350
* test-integration: Run integration tests only
351+
* test-legacy: Run tests for the `legacy` package
349352
* test-unit: Run unit tests only
353+
* test-unit-race: Run unit tests only with race condition detection
350354
```
351355

352356
For Example to launch unit tests only run: `task test-unit`

Diff for: Taskfile.yml

+26-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,28 @@ tasks:
2727
cmds:
2828
- go test {{ default "-v" .GOFLAGS }} ./legacy/...
2929

30+
test-unit-race:
31+
desc: Run unit tests only with race condition detection
32+
cmds:
33+
- go test -short -race {{ default "-v" .GOFLAGS }} -coverprofile=coverage_race_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }}
34+
35+
check:
36+
desc: Check fmt and lint, `legacy` will be skipped
37+
cmds:
38+
- test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }})
39+
- go vet {{ default .DEFAULT_TARGETS .TARGETS }}
40+
- golint {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}
41+
42+
check-legacy:
43+
desc: Check fmt and lint for the `legacy` package
44+
cmds:
45+
- test -z $(go fmt ./legacy/...)
46+
- go vet ./legacy/...
47+
3048
vars:
31-
DEFAULT_TARGETS: "./arduino/... ./auth/... ./cli/... ./commands/... ./executils/... ./version/..."
49+
# all modules of this project except for "legacy/..." module
50+
DEFAULT_TARGETS:
51+
sh: echo `go list ./... | grep -v legacy | tr '\n' ' '`
3252

3353
# build vars
3454
VERSIONSTRING: "0.3.6-alpha.preview"
@@ -39,9 +59,12 @@ vars:
3959
-X github.com/arduino/arduino-cli/version.commit={{.COMMIT}}'
4060
4161
# test vars
42-
GOFLAGS: "-timeout 5m -v -coverpkg=./... -covermode=atomic"
62+
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
4363
TEST_VERSIONSTRING: "0.0.0-test.preview"
4464
TEST_COMMIT: "deadbeef"
4565
TEST_LDFLAGS: >
4666
-ldflags '-X github.com/arduino/arduino-cli/version.versionString={{.TEST_VERSIONSTRING}}
47-
-X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}'
67+
-X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}'
68+
69+
# check-lint vars
70+
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/arduino/arduino-cli/configs"
2828
"github.com/arduino/go-paths-helper"
2929
properties "github.com/arduino/go-properties-orderedmap"
30-
"go.bug.st/relaxed-semver"
30+
semver "go.bug.st/relaxed-semver"
3131
)
3232

3333
// LoadHardware read all plaforms from the configured paths
@@ -361,6 +361,7 @@ func (pm *PackageManager) loadToolReleasesFromTool(tool *cores.Tool, toolPath *p
361361
return nil
362362
}
363363

364+
// LoadToolsFromBundleDirectories FIXMEDOC
364365
func (pm *PackageManager) LoadToolsFromBundleDirectories(dirs paths.PathList) error {
365366
for _, dir := range dirs {
366367
if err := pm.LoadToolsFromBundleDirectory(dir); err != nil {
@@ -370,6 +371,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectories(dirs paths.PathList) er
370371
return nil
371372
}
372373

374+
// LoadToolsFromBundleDirectory FIXMEDOC
373375
func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) error {
374376
pm.Log.Infof("Loading tools from bundle dir: %s", toolsPath)
375377

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

+10
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ func NewPackageManager(indexDir, packagesDir, downloadDir, tempDir *paths.Path)
5959
}
6060
}
6161

62+
// Clear FIXMEDOC
6263
func (pm *PackageManager) Clear() {
6364
pm.packages = cores.NewPackages()
6465
}
6566

67+
// GetPackages FIXMEDOC
6668
func (pm *PackageManager) GetPackages() *cores.Packages {
6769
return pm.packages
6870
}
6971

72+
// FindPlatformReleaseProvidingBoardsWithVidPid FIXMEDOC
7073
func (pm *PackageManager) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid string) []*cores.PlatformRelease {
7174
res := []*cores.PlatformRelease{}
7275
for _, targetPackage := range pm.packages.Packages {
@@ -86,6 +89,7 @@ func (pm *PackageManager) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid
8689
return res
8790
}
8891

92+
// FindBoardsWithVidPid FIXMEDOC
8993
func (pm *PackageManager) FindBoardsWithVidPid(vid, pid string) []*cores.Board {
9094
res := []*cores.Board{}
9195
for _, targetPackage := range pm.packages.Packages {
@@ -102,6 +106,7 @@ func (pm *PackageManager) FindBoardsWithVidPid(vid, pid string) []*cores.Board {
102106
return res
103107
}
104108

109+
// FindBoardsWithID FIXMEDOC
105110
func (pm *PackageManager) FindBoardsWithID(id string) []*cores.Board {
106111
res := []*cores.Board{}
107112
for _, targetPackage := range pm.packages.Packages {
@@ -290,6 +295,7 @@ func (ta *ToolActions) IsInstalled() (bool, error) {
290295
return false, nil
291296
}
292297

298+
// Release FIXMEDOC
293299
func (ta *ToolActions) Release(version *semver.RelaxedVersion) *ToolReleaseActions {
294300
if ta.forwardError != nil {
295301
return &ToolReleaseActions{forwardError: ta.forwardError}
@@ -310,6 +316,7 @@ type ToolReleaseActions struct {
310316
forwardError error
311317
}
312318

319+
// Get FIXMEDOC
313320
func (tr *ToolReleaseActions) Get() (*cores.ToolRelease, error) {
314321
if tr.forwardError != nil {
315322
return nil, tr.forwardError
@@ -340,6 +347,7 @@ func (pm *PackageManager) GetInstalledPlatformRelease(platform *cores.Platform)
340347
return best
341348
}
342349

350+
// GetAllInstalledToolsReleases FIXMEDOC
343351
func (pm *PackageManager) GetAllInstalledToolsReleases() []*cores.ToolRelease {
344352
tools := []*cores.ToolRelease{}
345353
for _, targetPackage := range pm.packages.Packages {
@@ -384,6 +392,7 @@ func (pm *PackageManager) InstalledBoards() []*cores.Board {
384392
return boards
385393
}
386394

395+
// FindToolsRequiredForBoard FIXMEDOC
387396
func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*cores.ToolRelease, error) {
388397
pm.Log.Infof("Searching tools required for board %s", board)
389398

@@ -421,6 +430,7 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core
421430
return requiredTools, nil
422431
}
423432

433+
// FindToolDependency FIXMEDOC
424434
func (pm *PackageManager) FindToolDependency(dep *cores.ToolDependency) *cores.ToolRelease {
425435
toolRelease, err := pm.Package(dep.ToolPackager).Tool(dep.ToolName).Release(dep.ToolVersion).Get()
426436
if err != nil {

Diff for: arduino/libraries/libraries.go

+5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ import (
2626
semver "go.bug.st/relaxed-semver"
2727
)
2828

29+
// MandatoryProperties FIXMEDOC
2930
var MandatoryProperties = []string{"name", "version", "author", "maintainer"}
31+
32+
// OptionalProperties FIXMEDOC
3033
var OptionalProperties = []string{"sentence", "paragraph", "url"}
34+
35+
// ValidCategories FIXMEDOC
3136
var ValidCategories = map[string]bool{
3237
"Display": true,
3338
"Communication": true,

Diff for: cli/cli.go

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var appName = filepath.Base(os.Args[0])
5858
// VersionInfo contains all info injected during build
5959
var VersionInfo = version.NewInfo(appName)
6060

61+
// HTTPClientHeader is the object that will be propagated to configure the clients inside the downloaders
6162
var HTTPClientHeader = getHTTPClientHeader()
6263

6364
// ErrLogrus represents the logrus instance, which has the role to
@@ -70,6 +71,7 @@ var GlobalFlags struct {
7071
OutputJSON bool // true output in JSON, false output as Text
7172
}
7273

74+
// Config FIXMEDOC
7375
var Config *configs.Configuration
7476

7577
func packageManagerInitReq() *rpc.InitReq {
@@ -96,6 +98,7 @@ func getHTTPClientHeader() http.Header {
9698
return downloaderHeaders
9799
}
98100

101+
// InitInstance FIXMEDOC
99102
func InitInstance() *rpc.InitResp {
100103
logrus.Info("Initializing package manager")
101104
req := packageManagerInitReq()

Diff for: commands/board/attach.go

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
paths "github.com/arduino/go-paths-helper"
3535
)
3636

37+
// Attach FIXMEDOC
3738
func Attach(ctx context.Context, req *rpc.BoardAttachReq, taskCB commands.TaskProgressCB) (*rpc.BoardAttachResp, error) {
3839

3940
pm := commands.GetPackageManager(req)

Diff for: commands/board/details.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/arduino/arduino-cli/rpc"
2828
)
2929

30+
// Details FIXMEDOC
3031
func Details(ctx context.Context, req *rpc.BoardDetailsReq) (*rpc.BoardDetailsResp, error) {
3132
pm := commands.GetPackageManager(req)
3233
if pm == nil {

Diff for: commands/board/list.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/arduino/arduino-cli/rpc"
2727
)
2828

29+
// List FIXMEDOC
2930
func List(ctx context.Context, req *rpc.BoardListReq) (*rpc.BoardListResp, error) {
3031
pm := commands.GetPackageManager(req)
3132
if pm == nil {

Diff for: commands/board/listall.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/arduino/arduino-cli/rpc"
2727
)
2828

29+
// ListAll FIXMEDOC
2930
func ListAll(ctx context.Context, req *rpc.BoardListAllReq) (*rpc.BoardListAllResp, error) {
3031
pm := commands.GetPackageManager(req)
3132
if pm == nil {

Diff for: commands/compile/compile.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/sirupsen/logrus"
4141
)
4242

43+
// Compile FIXMEDOC
4344
func Compile(ctx context.Context, req *rpc.CompileReq, outStream io.Writer, errStream io.Writer) (*rpc.CompileResp, error) {
4445
pm := commands.GetPackageManager(req)
4546
if pm == nil {

Diff for: commands/core/download.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/arduino/arduino-cli/rpc"
3030
)
3131

32+
// PlatformDownload FIXMEDOC
3233
func PlatformDownload(ctx context.Context, req *rpc.PlatformDownloadReq, downloadCB commands.DownloadProgressCB,
3334
downloaderHeaders http.Header) (*rpc.PlatformDownloadResp, error) {
3435
pm := commands.GetPackageManager(req)

Diff for: commands/core/install.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/arduino/arduino-cli/rpc"
3030
)
3131

32+
// PlatformInstall FIXMEDOC
3233
func PlatformInstall(ctx context.Context, req *rpc.PlatformInstallReq,
3334
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) (*rpc.PlatformInstallResp, error) {
3435

Diff for: commands/core/list.go

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/arduino/arduino-cli/rpc"
2626
)
2727

28+
// PlatformList FIXMEDOC
2829
func PlatformList(ctx context.Context, req *rpc.PlatformListReq) (*rpc.PlatformListResp, error) {
2930
pm := commands.GetPackageManager(req)
3031
if pm == nil {

Diff for: commands/core/search.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/arduino/arduino-cli/rpc"
2929
)
3030

31+
// PlatformSearch FIXMEDOC
3132
func PlatformSearch(ctx context.Context, req *rpc.PlatformSearchReq) (*rpc.PlatformSearchResp, error) {
3233
pm := commands.GetPackageManager(req)
3334
if pm == nil {

Diff for: commands/core/uninstall.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/arduino/arduino-cli/rpc"
2929
)
3030

31+
// PlatformUninstall FIXMEDOC
3132
func PlatformUninstall(ctx context.Context, req *rpc.PlatformUninstallReq, taskCB commands.TaskProgressCB) (*rpc.PlatformUninstallResp, error) {
3233
pm := commands.GetPackageManager(req)
3334
if pm == nil {

Diff for: commands/core/upgrade.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/arduino/arduino-cli/rpc"
2929
)
3030

31+
// PlatformUpgrade FIXMEDOC
3132
func PlatformUpgrade(ctx context.Context, req *rpc.PlatformUpgradeReq,
3233
downloadCB commands.DownloadProgressCB, taskCB commands.TaskProgressCB, downloaderHeaders http.Header) (*rpc.PlatformUpgradeResp, error) {
3334

0 commit comments

Comments
 (0)