Skip to content

[skip changelog] Migrate tests to GH actions #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ coverage:
status:
project:
default:
target: 40%
target: 35%
threshold: null
patch: off
changes: off
47 changes: 0 additions & 47 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage_integ.txt
flags: integ
4 changes: 3 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
49 changes: 0 additions & 49 deletions appveyor.yml

This file was deleted.

9 changes: 7 additions & 2 deletions arduino/builder/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions arduino/builder/testdata/TestMergeSketchSources_win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <Arduino.h>
#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";
}
5 changes: 5 additions & 0 deletions cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"

"bou.ke/monkey"
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions configs/navigate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package configs_test
import (
"io/ioutil"
"path/filepath"
"runtime"
"strings"
"testing"

Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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