Skip to content

Commit 98bc2e3

Browse files
committed
Merge branch 'master' of github.com:arduino/arduino-cli
2 parents 75ffd4f + f99361a commit 98bc2e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+491
-360
lines changed

.github/workflows/test.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: test
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
48

59
jobs:
610
test-matrix:
711

812
strategy:
913
matrix:
10-
operating-system: [ubuntu-18.04, windows-2019]
14+
operating-system: [ubuntu-18.04, windows-2019, macOS-10.14]
1115

1216
runs-on: ${{ matrix.operating-system }}
1317

@@ -36,7 +40,9 @@ jobs:
3640
run: task check
3741

3842
- name: Install protoc compiler
39-
uses: Arduino/actions/setup-protoc@master
43+
uses: arduino/[email protected]
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
4046

4147
- name: Check protocol buffers compile correctly
4248
run: task protoc
@@ -48,7 +54,8 @@ jobs:
4854
run: task test-unit
4955

5056
- name: Run unit tests on the legacy package
51-
if: matrix.operating-system != 'windows-2019'
57+
# Run legacy tests on one platform only
58+
if: matrix.operating-system == 'ubuntu-18.04'
5259
run: task test-legacy
5360

5461
- name: Install Python
@@ -58,11 +65,6 @@ jobs:
5865
architecture: 'x64'
5966

6067
- name: Run integration tests
61-
# Since we are investigating issues emerged
62-
# with python integration tests on windows
63-
# this step is disabled for windows-2019
64-
# platform ATM
65-
if: matrix.operating-system != 'windows-2019'
6668
run: |
6769
pip install -r test/requirements.txt
6870
task test-integration
@@ -73,7 +75,7 @@ jobs:
7375
# Codecov whitelists GitHub, lifting the need
7476
# for a token.
7577
if: >
76-
matrix.operating-system != 'windows-2019' &&
78+
matrix.operating-system == 'ubuntu-18.04' &&
7779
github.event_name == 'push'
7880
uses: codecov/[email protected]
7981
with:
@@ -87,7 +89,7 @@ jobs:
8789
# Codecov whitelists GitHub, lifting the need
8890
# for a token.
8991
if: >
90-
matrix.operating-system != 'windows-2019' &&
92+
matrix.operating-system == 'ubuntu-18.04' &&
9193
github.event_name == 'push'
9294
uses: codecov/[email protected]
9395
with:
@@ -101,7 +103,7 @@ jobs:
101103
# Codecov whitelists GitHub, lifting the need
102104
# for a token.
103105
if: >
104-
matrix.operating-system != 'windows-2019' &&
106+
matrix.operating-system == 'ubuntu-18.04' &&
105107
github.event_name == 'push'
106108
uses: codecov/[email protected]
107109
with:

.goreleaser.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ release:
1111
changelog:
1212
filters:
1313
exclude:
14-
- '^\[skip changelog\].*'
15-
- '^\[changelog skip\].*'
16-
- '^\[skip ci\].*'
17-
- '^\[ci skip\].*'
14+
# [skip changelog], [skip-changelog], [changelog skip], [changelog-skip]
15+
- '^(?i)\[(skip|changelog)[ ,-](skip|changelog)\].*'
16+
# [skip ci], [skip-ci], [ci skip], [ci-skip]
17+
- '^(?i)\[(skip|ci)[ ,-](skip|ci)\].*'
1818

1919
# We have multiple builds in order to fine tune
2020
# cross compilations.

README.md

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# arduino-cli
22

3-
![Workflow Status](https://github.com/Arduino/arduino-cli/workflows/test/badge.svg)
3+
[![Tests passing](https://github.com/Arduino/arduino-cli/workflows/test/badge.svg)](https://github.com/Arduino/arduino-cli/actions?workflow=test)
4+
[![Nightly build](https://github.com/Arduino/arduino-cli/workflows/nightly/badge.svg)](https://github.com/Arduino/arduino-cli/actions?workflow=nightly)
45
[![codecov](https://codecov.io/gh/arduino/arduino-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/arduino/arduino-cli)
56

67
`arduino-cli` is an all-in-one solution that provides builder, boards/library manager, uploader,
@@ -16,12 +17,28 @@ Contributions are welcome!
1617
Please read the document [How to contribute](CONTRIBUTING.md) which will guide you through how to
1718
build the source code, run the tests, and contribute your changes to the project.
1819

20+
:sparkles: Thanks to all our [contributors](https://github.com/arduino/arduino-cli/graphs/contributors)! :sparkles:
21+
1922
## How to install
2023

2124
### Get the latest package
2225

23-
The easiest way to get the latest version of `arduino-cli` on any supported platform is using the
24-
`install.sh` script:
26+
You have several options to install the latest version of the Arduino CLI
27+
on your system.
28+
29+
#### Install via Homebrew (macOS/Linux)
30+
31+
The Arduino CLI is available as a Homebrew formula since version `0.5.0`:
32+
33+
```console
34+
brew update
35+
brew install arduino-cli
36+
```
37+
38+
#### Use the install script
39+
40+
The easiest way to get the latest version of `arduino-cli` on any supported
41+
platform is using the `install.sh` script:
2542

2643
```console
2744
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
@@ -34,18 +51,36 @@ for example `~/local/bin`, set the `BINDIR` environment variable like this:
3451
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/local/bin sh
3552
```
3653

54+
#### Download the latest packages from Arduino CDN
55+
56+
In order to get the latest stable release for your platform you can use the
57+
following links:
58+
59+
- [Linux 64 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_64bit.tar.gz)
60+
- [Linux 32 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_32bit.tar.gz)
61+
- [Linux ARM 64 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARM64.tar.gz)
62+
- [Linux ARM 32 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Linux_ARMv7.tar.gz)
63+
- [Windows 64 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip)
64+
- [Windows 32 bit](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_32bit.zip)
65+
- [Mac OSX](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_macOS_64bit.tar.gz)
66+
67+
These links return a `302: Found` response, redirecting to latest generated builds by replacing `latest` with the latest
68+
available stable release. Once downloaded, place the executable `arduino-cli` into a directory which is in your `PATH`.
69+
3770
**Deprecation notice:** Links in the form `http://downloads.arduino.cc/arduino-cli/arduino-cli-latest-<platform>.tar.bz2`
3871
won't be further updated. That URL will provide arduino-cli 0.3.7-alpha.preview, regardless of further releases.
3972

40-
Alternatively you can download one of the pre-built binaries for the supported platforms from the
41-
[release page](https://github.com/arduino/arduino-cli/releases). Once downloaded, place the executable
42-
`arduino-cli` into a directory which is in your `PATH`.
73+
#### Download the latest package from the release page on GitHub
4374

44-
### Download a nightly build
75+
Alternatively you can download one of the pre-built binaries for the supported
76+
platforms from the
77+
[release page](https://github.com/arduino/arduino-cli/releases). Once downloaded,
78+
place the executable `arduino-cli` into a directory which is in your `PATH`.
4579

46-
These builds are generated once a day from `master` branch starting at 01:00 GMT
80+
### Get a nightly build
4781

48-
In order to get the latest nightly build for your platform use the following links:
82+
These builds are generated once a day from `master` branch starting at 01:00 GMT.
83+
In order to get the latest nightly build for your platform, use the following links:
4984

5085
- [Linux 64 bit](https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_64bit.tar.gz)
5186
- [Linux 32 bit](https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-latest_Linux_32bit.tar.gz)
@@ -58,16 +93,16 @@ In order to get the latest nightly build for your platform use the following lin
5893
These links return a `302: Found` response, redirecting to latest generated builds by replacing `latest` with the latest
5994
available build date, using the format YYYYMMDD (i.e for 2019/Aug/06 `latest` is replaced with `20190806` )
6095

61-
Checksums for the nightly builds are available at
96+
Checksums for the nightly builds are available at
6297
`https://downloads.arduino.cc/arduino-cli/nightly/nightly-<DATE>-checksums.txt`
6398

6499
Once downloaded, place the executable `arduino-cli` into a directory which is in your `PATH`.
65100

66-
### Build from source with Docker
101+
### Build from source using Docker
67102

68-
If you don't have a working Golang environment or if you want to build `arduino-cli` targeting
69-
different platforms, you can use Docker to get a binary directly from sources. From the project
70-
folder run:
103+
If you don't have a working Golang environment or if you want to build
104+
`arduino-cli` targeting different platforms, you can use Docker to get a binary
105+
directly from sources. From the project folder run:
71106

72107
```console
73108
docker run -v $PWD:/arduino-cli -w /arduino-cli -e PACKAGE_NAME_PREFIX='snapshot' arduino/arduino-cli:builder-1 goreleaser --rm-dist --snapshot --skip-publish
@@ -106,7 +141,7 @@ void loop() {
106141

107142
### Step 2. Modify your sketch
108143

109-
Use your favourite file editor or IDE to modify the .ino file, in this example
144+
Use your favourite file editor or IDE to modify the .ino file, in this example
110145
under: `$HOME/MyFirstSketch/MyFirstSketch.ino`
111146
and change the file to look like this one:
112147

arduino/builder/builder.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ import (
1919
"crypto/md5"
2020
"encoding/hex"
2121
"os"
22-
"path/filepath"
2322
"strings"
2423

24+
"github.com/arduino/go-paths-helper"
2525
"github.com/pkg/errors"
2626
)
2727

28-
// GenBuildPath generates a suitable name for the build folder
29-
func GenBuildPath(sketchPath string) string {
30-
md5SumBytes := md5.Sum([]byte(sketchPath))
28+
// GenBuildPath generates a suitable name for the build folder.
29+
// The sketchPath, if not nil, is also used to furhter differentiate build paths.
30+
func GenBuildPath(sketchPath *paths.Path) *paths.Path {
31+
path := ""
32+
if sketchPath != nil {
33+
path = sketchPath.String()
34+
}
35+
md5SumBytes := md5.Sum([]byte(path))
3136
md5Sum := strings.ToUpper(hex.EncodeToString(md5SumBytes[:]))
32-
33-
return filepath.Join(os.TempDir(), "arduino-sketch-"+md5Sum)
37+
return paths.TempDir().Join("arduino-sketch-" + md5Sum)
3438
}
3539

3640
// EnsureBuildPathExists creates the build path if doesn't already exists.

arduino/builder/builder_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"testing"
2424

2525
"github.com/arduino/arduino-cli/arduino/builder"
26+
"github.com/arduino/go-paths-helper"
2627
"github.com/stretchr/testify/assert"
2728
)
2829

@@ -36,7 +37,10 @@ func tmpDirOrDie() string {
3637

3738
func TestGenBuildPath(t *testing.T) {
3839
want := filepath.Join(os.TempDir(), "arduino-sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
39-
assert.Equal(t, want, builder.GenBuildPath("foo"))
40+
assert.Equal(t, want, builder.GenBuildPath(paths.New("foo")).String())
41+
42+
want = filepath.Join(os.TempDir(), "arduino-sketch-D41D8CD98F00B204E9800998ECF8427E")
43+
assert.Equal(t, want, builder.GenBuildPath(nil).String())
4044
}
4145

4246
func TestEnsureBuildPathExists(t *testing.T) {

cli/board/attach.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"github.com/arduino/arduino-cli/cli/output"
2828
"github.com/arduino/arduino-cli/commands/board"
2929
rpc "github.com/arduino/arduino-cli/rpc/commands"
30+
"github.com/arduino/go-paths-helper"
31+
"github.com/sirupsen/logrus"
3032
"github.com/spf13/cobra"
3133
)
3234

@@ -52,18 +54,37 @@ var attachFlags struct {
5254

5355
func runAttachCommand(cmd *cobra.Command, args []string) {
5456
instance := instance.CreateInstance()
55-
var path string
56-
if len(args) > 0 {
57-
path = args[1]
57+
58+
var path *paths.Path
59+
if len(args) > 1 {
60+
path = paths.New(args[1])
61+
} else {
62+
path = initSketchPath(path)
5863
}
64+
5965
_, err := board.Attach(context.Background(), &rpc.BoardAttachReq{
6066
Instance: instance,
6167
BoardUri: args[0],
62-
SketchPath: path,
68+
SketchPath: path.String(),
6369
SearchTimeout: attachFlags.searchTimeout,
6470
}, output.TaskProgress())
6571
if err != nil {
6672
feedback.Errorf("Attach board error: %v", err)
6773
os.Exit(errorcodes.ErrGeneric)
6874
}
6975
}
76+
77+
// initSketchPath returns the current working directory
78+
func initSketchPath(sketchPath *paths.Path) *paths.Path {
79+
if sketchPath != nil {
80+
return sketchPath
81+
}
82+
83+
wd, err := paths.Getwd()
84+
if err != nil {
85+
feedback.Errorf("Couldn't get current working directory: %v", err)
86+
os.Exit(errorcodes.ErrGeneric)
87+
}
88+
logrus.Infof("Reading sketch from dir: %s", wd)
89+
return wd
90+
}

cli/board/details.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func runDetailsCommand(cmd *cobra.Command, args []string) {
5454
feedback.PrintResult(detailsResult{details: res})
5555
}
5656

57-
// ouput from this command requires special formatting, let's create a dedicated
57+
// output from this command requires special formatting, let's create a dedicated
5858
// feedback.Result implementation
5959
type detailsResult struct {
6060
details *rpc.BoardDetailsResp

cli/board/list.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/arduino/arduino-cli/arduino/cores"
2727
"github.com/arduino/arduino-cli/cli/errorcodes"
2828
"github.com/arduino/arduino-cli/cli/feedback"
29-
"github.com/arduino/arduino-cli/cli/globals"
3029
"github.com/arduino/arduino-cli/cli/instance"
3130
"github.com/arduino/arduino-cli/commands/board"
3231
rpc "github.com/arduino/arduino-cli/rpc/commands"
@@ -68,27 +67,33 @@ func runListCommand(cmd *cobra.Command, args []string) {
6867
os.Exit(errorcodes.ErrNetwork)
6968
}
7069

71-
if globals.OutputFormat == "json" {
72-
feedback.PrintJSON(ports)
73-
} else {
74-
outputListResp(ports)
75-
}
70+
feedback.PrintResult(result{ports})
71+
}
72+
73+
// output from this command requires special formatting, let's create a dedicated
74+
// feedback.Result implementation
75+
type result struct {
76+
ports []*rpc.DetectedPort
7677
}
7778

78-
func outputListResp(ports []*rpc.DetectedPort) {
79-
if len(ports) == 0 {
80-
feedback.Print("No boards found.")
81-
return
79+
func (dr result) Data() interface{} {
80+
return dr.ports
81+
}
82+
83+
func (dr result) String() string {
84+
if len(dr.ports) == 0 {
85+
return "No boards found."
8286
}
83-
sort.Slice(ports, func(i, j int) bool {
84-
x, y := ports[i], ports[j]
87+
88+
sort.Slice(dr.ports, func(i, j int) bool {
89+
x, y := dr.ports[i], dr.ports[j]
8590
return x.GetProtocol() < y.GetProtocol() ||
8691
(x.GetProtocol() == y.GetProtocol() && x.GetAddress() < y.GetAddress())
8792
})
8893

8994
t := table.New()
9095
t.SetHeader("Port", "Type", "Board Name", "FQBN", "Core")
91-
for _, port := range ports {
96+
for _, port := range dr.ports {
9297
address := port.GetProtocol() + "://" + port.GetAddress()
9398
if port.GetProtocol() == "serial" {
9499
address = port.GetAddress()
@@ -123,5 +128,5 @@ func outputListResp(ports []*rpc.DetectedPort) {
123128
t.AddRow(address, protocol, board, fqbn, coreName)
124129
}
125130
}
126-
feedback.Print(t.Render())
131+
return t.Render()
127132
}

0 commit comments

Comments
 (0)