Skip to content

Commit cada486

Browse files
authored
[skip changelog] Migrate tests to GH actions (arduino#352)
* port drone to gh actions
1 parent f9ebd6b commit cada486

File tree

11 files changed

+118
-101
lines changed

11 files changed

+118
-101
lines changed

.codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ coverage:
77
status:
88
project:
99
default:
10-
target: 40%
10+
target: 35%
1111
threshold: null
1212
patch: off
1313
changes: off

.drone.yml

-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,3 @@
1-
---
2-
kind: pipeline
3-
name: test
4-
5-
steps:
6-
- name: lint
7-
image: arduino/arduino-cli:drone-1.1.0
8-
commands:
9-
# Check if the Go code is properly formatted and run the linter
10-
- task check
11-
# Ensure protobufs compile without errors
12-
- task protoc
13-
14-
- name: build
15-
image: arduino/arduino-cli:drone-1.1.0
16-
commands:
17-
- task build
18-
19-
- name: test
20-
image: arduino/arduino-cli:drone-1.1.0
21-
commands:
22-
- task test-unit
23-
- task test-legacy
24-
25-
- name: integration
26-
image: arduino/arduino-cli:drone-1.1.0
27-
commands:
28-
- pip install -r test/requirements.txt
29-
- task test-integration
30-
31-
- name: coverage
32-
# Contrary to other CI platforms, uploading reports to Codecov requires Drone to provide a token.
33-
# To avoid exposing the Codecov token to external PRs, we only upload coverage when we merge on
34-
# `master`.
35-
image: arduino/arduino-cli:drone-1.1.0
36-
environment:
37-
CODECOV_TOKEN:
38-
from_secret: codecov_token
39-
commands:
40-
- codecov -cF unit -f coverage_unit.txt -t $CODECOV_TOKEN
41-
- codecov -cF integ -f coverage_integ.txt -t $CODECOV_TOKEN
42-
when:
43-
branch:
44-
- master
45-
event:
46-
- push
47-
481
---
492
kind: pipeline
503
name: release

.github/workflows/test.yaml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: test
2+
3+
on: [push]
4+
5+
jobs:
6+
test-matrix:
7+
8+
strategy:
9+
matrix:
10+
operating-system: [ubuntu-18.04, windows-2019]
11+
12+
runs-on: ${{ matrix.operating-system }}
13+
14+
steps:
15+
- name: Disable EOL conversions
16+
run: git config --global core.autocrlf false
17+
18+
- name: Checkout
19+
uses: actions/checkout@master
20+
21+
- name: Install Go
22+
uses: actions/setup-go@v1
23+
with:
24+
go-version: '1.12.x'
25+
26+
- name: Install Go deps
27+
run: |
28+
go get github.com/golangci/govet
29+
go get golang.org/x/lint/golint
30+
go get github.com/golang/protobuf/protoc-gen-go
31+
32+
- name: Install Taskfile
33+
uses: Arduino/actions/setup-taskfile@master
34+
35+
- name: Check the code is good
36+
run: task check
37+
38+
- name: Install protoc compiler
39+
uses: Arduino/actions/setup-protoc@master
40+
41+
- name: Check protocol buffers compile correctly
42+
run: task protoc
43+
44+
- name: Build the CLI
45+
run: task build
46+
47+
- name: Run unit tests
48+
run: task test-unit
49+
50+
- name: Run unit tests on the legacy package
51+
if: matrix.operating-system != 'windows-2019'
52+
run: task test-legacy
53+
54+
- name: Install Python
55+
uses: actions/setup-python@v1
56+
with:
57+
python-version: '3.x'
58+
architecture: 'x64'
59+
60+
- name: Run integration tests
61+
run: |
62+
pip install -r test/requirements.txt
63+
task test-integration
64+
65+
- name: Send unit tests coverage to Codecov
66+
if: matrix.operating-system != 'windows-2019'
67+
uses: codecov/[email protected]
68+
with:
69+
token: ${{secrets.CODECOV_TOKEN}}
70+
file: ./coverage_unit.txt
71+
flags: unit
72+
73+
- name: Send integration tests coverage to Codecov
74+
if: matrix.operating-system != 'windows-2019'
75+
uses: codecov/[email protected]
76+
with:
77+
token: ${{secrets.CODECOV_TOKEN}}
78+
file: ./coverage_integ.txt
79+
flags: integ

Taskfile.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tasks:
4444
cmds:
4545
- test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }})
4646
- go vet {{ default .DEFAULT_TARGETS .TARGETS }}
47-
- golint {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}
47+
- "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}"
4848

4949
check-legacy:
5050
desc: Check fmt and lint for the `legacy` package
@@ -79,4 +79,6 @@ vars:
7979
-X github.com/arduino/arduino-cli/version.commit={{.TEST_COMMIT}}'
8080
8181
# check-lint vars
82+
GOLINTBIN:
83+
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
8284
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"

appveyor.yml

-49
This file was deleted.

arduino/builder/sketch_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"io/ioutil"
2121
"os"
2222
"path/filepath"
23+
"runtime"
2324
"strings"
2425
"testing"
2526

@@ -89,7 +90,7 @@ func TestLoadSketchFolderWrongMain(t *testing.T) {
8990

9091
_, err = builder.SketchLoad("does/not/exist", "")
9192
require.Error(t, err)
92-
require.Contains(t, err.Error(), "no such file or directory")
93+
require.Contains(t, err.Error(), "does/not/exist")
9394
}
9495

9596
func TestMergeSketchSources(t *testing.T) {
@@ -99,7 +100,11 @@ func TestMergeSketchSources(t *testing.T) {
99100
require.NotNil(t, s)
100101

101102
// load expected result
102-
mergedPath := filepath.Join("testdata", t.Name()+".txt")
103+
suffix := ".txt"
104+
if runtime.GOOS == "windows" {
105+
suffix = "_win.txt"
106+
}
107+
mergedPath := filepath.Join("testdata", t.Name()+suffix)
103108
mergedBytes, err := ioutil.ReadFile(mergedPath)
104109
if err != nil {
105110
t.Fatalf("unable to read golden file %s: %v", mergedPath, err)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <Arduino.h>
2+
#line 1 "testdata\\TestLoadSketchFolder\\TestLoadSketchFolder.ino"
3+
void setup() {
4+
5+
}
6+
7+
void loop() {
8+
9+
}
10+
#line 1 "testdata\\TestLoadSketchFolder\\old.pde"
11+
12+
#line 1 "testdata\\TestLoadSketchFolder\\other.ino"
13+
String hello() {
14+
return "world";
15+
}

cli/cli_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"io/ioutil"
2525
"os"
2626
"path/filepath"
27+
"runtime"
2728
"testing"
2829

2930
"bou.ke/monkey"
@@ -217,6 +218,10 @@ func detectLatestAVRCore(t *testing.T) string {
217218
// END -- Utility functions
218219

219220
func TestUploadIntegration(t *testing.T) {
221+
if runtime.GOOS == "windows" {
222+
t.Skip("This test runs only on Linux")
223+
}
224+
220225
exitCode, _ := executeWithArgs("core", "update-index")
221226
require.Zero(t, exitCode)
222227

configs/navigate_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package configs_test
2020
import (
2121
"io/ioutil"
2222
"path/filepath"
23+
"runtime"
2324
"strings"
2425
"testing"
2526

@@ -30,6 +31,10 @@ import (
3031
)
3132

3233
func TestNavigate(t *testing.T) {
34+
if runtime.GOOS != "linux" {
35+
t.Skip("Test only runs on Linux")
36+
}
37+
3338
tests := []string{
3439
"noconfig",
3540
"local",

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC
6767
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
6868
github.com/miekg/dns v1.0.5 h1:MQBGf2JEJDu0rg9WOpQZzeO+zW8UKwgkvP3R1dUU1Yw=
6969
github.com/miekg/dns v1.0.5/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
70+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
7071
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
7172
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
7273
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
8283
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
8384
github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiyyjYS17cCYRqP13/SHk=
8485
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
86+
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
8587
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
8688
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
8789
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=

test/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def running_on_ci():
1919
"""
2020
Returns whether the program is running on a CI environment
2121
"""
22-
val = os.getenv("APPVEYOR") or os.getenv("DRONE")
22+
val = os.getenv("APPVEYOR") or os.getenv("DRONE") or os.getenv("GITHUB_WORKFLOW")
2323
return val is not None

0 commit comments

Comments
 (0)