diff --git a/.codecov.yml b/.codecov.yml index 755e0297c66..279a3159537 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -7,7 +7,7 @@ coverage: status: project: default: - target: 40% + target: 35% threshold: null patch: off changes: off diff --git a/.drone.yml b/.drone.yml index 84e9808d43d..d579e82d367 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,50 +1,3 @@ ---- -kind: pipeline -name: test - -steps: -- name: lint - image: arduino/arduino-cli:drone-1.1.0 - commands: - # Check if the Go code is properly formatted and run the linter - - task check - # Ensure protobufs compile without errors - - task protoc - -- name: build - image: arduino/arduino-cli:drone-1.1.0 - commands: - - task build - -- name: test - image: arduino/arduino-cli:drone-1.1.0 - commands: - - task test-unit - - task test-legacy - -- name: integration - image: arduino/arduino-cli:drone-1.1.0 - commands: - - pip install -r test/requirements.txt - - task test-integration - -- name: coverage - # Contrary to other CI platforms, uploading reports to Codecov requires Drone to provide a token. - # To avoid exposing the Codecov token to external PRs, we only upload coverage when we merge on - # `master`. - image: arduino/arduino-cli:drone-1.1.0 - environment: - CODECOV_TOKEN: - from_secret: codecov_token - commands: - - codecov -cF unit -f coverage_unit.txt -t $CODECOV_TOKEN - - codecov -cF integ -f coverage_integ.txt -t $CODECOV_TOKEN - when: - branch: - - master - event: - - push - --- kind: pipeline name: release diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000000..ac9cd3be953 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,79 @@ +name: test + +on: [push] + +jobs: + test-matrix: + + strategy: + matrix: + operating-system: [ubuntu-18.04, windows-2019] + + runs-on: ${{ matrix.operating-system }} + + steps: + - name: Disable EOL conversions + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@master + + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: '1.12.x' + + - name: Install Go deps + run: | + go get github.com/golangci/govet + go get golang.org/x/lint/golint + go get github.com/golang/protobuf/protoc-gen-go + + - name: Install Taskfile + uses: Arduino/actions/setup-taskfile@master + + - name: Check the code is good + run: task check + + - name: Install protoc compiler + uses: Arduino/actions/setup-protoc@master + + - name: Check protocol buffers compile correctly + run: task protoc + + - name: Build the CLI + run: task build + + - name: Run unit tests + run: task test-unit + + - name: Run unit tests on the legacy package + if: matrix.operating-system != 'windows-2019' + run: task test-legacy + + - name: Install Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + architecture: 'x64' + + - name: Run integration tests + run: | + pip install -r test/requirements.txt + task test-integration + + - name: Send unit tests coverage to Codecov + if: matrix.operating-system != 'windows-2019' + uses: codecov/codecov-action@v1.0.2 + with: + token: ${{secrets.CODECOV_TOKEN}} + file: ./coverage_unit.txt + flags: unit + + - name: Send integration tests coverage to Codecov + if: matrix.operating-system != 'windows-2019' + uses: codecov/codecov-action@v1.0.2 + with: + token: ${{secrets.CODECOV_TOKEN}} + file: ./coverage_integ.txt + flags: integ diff --git a/Taskfile.yml b/Taskfile.yml index 24ce844f7c6..b013962768d 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -44,7 +44,7 @@ tasks: cmds: - test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }}) - go vet {{ default .DEFAULT_TARGETS .TARGETS }} - - golint {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }} + - "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}" check-legacy: desc: Check fmt and lint for the `legacy` package @@ -79,4 +79,6 @@ vars: -X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}' # check-lint vars + GOLINTBIN: + sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status" diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 580f449cf04..00000000000 --- a/appveyor.yml +++ /dev/null @@ -1,49 +0,0 @@ -build: off -deploy: off - -clone_folder: C:\arduino-cli -shallow_clone: true - -skip_tags: true -skip_branch_with_pr: true - -environment: - GOPATH: c:\gopath - PROTOC_PATH: c:\protoc - PROTOC_BINARY: protoc.exe - # add protoc, gopath and override default Python 2.7 - PATH: $(PROTOC_PATH);$(PROTOC_PATH)\bin;$(GOPATH)\bin;C:\Python37;C:\Python37\Scripts;$(PATH) - -stack: go 1.12 - -install: - # install the task executor - - curl -o task.zip -LO https://github.com/go-task/task/releases/download/v2.6.0/task_windows_amd64.zip - - 7z x task.zip -o%GOPATH%\bin - # golang dependencies needed at test time - - go get github.com/golangci/govet - - go get golang.org/x/lint/golint - # Python dependencies needed at test time - - python -V - - pip install -r test\requirements.txt - # protobuf tooling needed at test time. We use a very old version of the compiler - # because of this: https://github.com/protocolbuffers/protobuf/issues/3957 - - go get github.com/golang/protobuf/protoc-gen-go - - curl -o protoc.zip -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-win32.zip - - 7z x protoc.zip -o%PROTOC_PATH% - -test_script: - # Check if the Go code is properly formatted and run the linter - - task.exe check - # Ensure protobufs compile - - task.exe protoc - # re-enable after fixing go tests - # - task.exe test-integration - # build the binary - - task.exe build - # run e2e tests - - pytest test - -# uncomment to debug builds -# on_finish: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file diff --git a/arduino/builder/sketch_test.go b/arduino/builder/sketch_test.go index 404dc8ba10b..e6526f6fbc8 100644 --- a/arduino/builder/sketch_test.go +++ b/arduino/builder/sketch_test.go @@ -20,6 +20,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" "testing" @@ -89,7 +90,7 @@ func TestLoadSketchFolderWrongMain(t *testing.T) { _, err = builder.SketchLoad("does/not/exist", "") require.Error(t, err) - require.Contains(t, err.Error(), "no such file or directory") + require.Contains(t, err.Error(), "does/not/exist") } func TestMergeSketchSources(t *testing.T) { @@ -99,7 +100,11 @@ func TestMergeSketchSources(t *testing.T) { require.NotNil(t, s) // load expected result - mergedPath := filepath.Join("testdata", t.Name()+".txt") + suffix := ".txt" + if runtime.GOOS == "windows" { + suffix = "_win.txt" + } + mergedPath := filepath.Join("testdata", t.Name()+suffix) mergedBytes, err := ioutil.ReadFile(mergedPath) if err != nil { t.Fatalf("unable to read golden file %s: %v", mergedPath, err) diff --git a/arduino/builder/testdata/TestMergeSketchSources_win.txt b/arduino/builder/testdata/TestMergeSketchSources_win.txt new file mode 100644 index 00000000000..933987f7b60 --- /dev/null +++ b/arduino/builder/testdata/TestMergeSketchSources_win.txt @@ -0,0 +1,15 @@ +#include +#line 1 "testdata\\TestLoadSketchFolder\\TestLoadSketchFolder.ino" +void setup() { + +} + +void loop() { + +} +#line 1 "testdata\\TestLoadSketchFolder\\old.pde" + +#line 1 "testdata\\TestLoadSketchFolder\\other.ino" +String hello() { + return "world"; +} diff --git a/cli/cli_test.go b/cli/cli_test.go index abf31969151..79b79f56a01 100644 --- a/cli/cli_test.go +++ b/cli/cli_test.go @@ -24,6 +24,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "testing" "bou.ke/monkey" @@ -217,6 +218,10 @@ func detectLatestAVRCore(t *testing.T) string { // END -- Utility functions func TestUploadIntegration(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("This test runs only on Linux") + } + exitCode, _ := executeWithArgs("core", "update-index") require.Zero(t, exitCode) diff --git a/configs/navigate_test.go b/configs/navigate_test.go index 6c188933de9..817885e7566 100644 --- a/configs/navigate_test.go +++ b/configs/navigate_test.go @@ -20,6 +20,7 @@ package configs_test import ( "io/ioutil" "path/filepath" + "runtime" "strings" "testing" @@ -30,6 +31,10 @@ import ( ) func TestNavigate(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("Test only runs on Linux") + } + tests := []string{ "noconfig", "local", diff --git a/go.sum b/go.sum index 1a95b11c651..7e58fcf4410 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,7 @@ github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/miekg/dns v1.0.5 h1:MQBGf2JEJDu0rg9WOpQZzeO+zW8UKwgkvP3R1dUU1Yw= github.com/miekg/dns v1.0.5/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/oleksandr/bonjour v0.0.0-20160508152359-5dcf00d8b228 h1:Cvfd2dOlXIPTeEkOT/h8PyK4phBngOM4at9/jlgy7d4= @@ -82,6 +83,7 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiyyjYS17cCYRqP13/SHk= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/test/common.py b/test/common.py index eeb82456c9d..81699e60239 100644 --- a/test/common.py +++ b/test/common.py @@ -19,5 +19,5 @@ def running_on_ci(): """ Returns whether the program is running on a CI environment """ - val = os.getenv("APPVEYOR") or os.getenv("DRONE") + val = os.getenv("APPVEYOR") or os.getenv("DRONE") or os.getenv("GITHUB_WORKFLOW") return val is not None