Unverified Commit cada486f authored by Massimiliano Pippi's avatar Massimiliano Pippi Committed by GitHub

[skip changelog] Migrate tests to GH actions (#352)

* port drone to gh actions
parent f9ebd6bd
......@@ -7,7 +7,7 @@ coverage:
status:
project:
default:
target: 40%
target: 35%
threshold: null
patch: off
changes: off
---
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
......
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
......@@ -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"
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
......@@ -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)
......
#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";
}
......@@ -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)
......
......@@ -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",
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment