Skip to content

Commit 21dd63d

Browse files
author
Maurizio Branca
authored
CI: add test workflow (#559)
* Add test workflow * Update go fmt * Fix go 1.14+ compatibility issue * Fix linter complaint * Add install linux packages * Try to fix dependencies install * Try to fix dependencies install (2) * Try to fix dependencies install (3) * Try to fix dependencies install (4) * Inspect error * Add more debug info 😔 * Add more debug info 😔 * Uncomment 'Disable EOL conversions' * Make test portable between go versions * Add missing urls and checksums for windowsamd64 * Make download_test cross platform Fix an issue with the '/tmp' path on non-unix OSs * Switch to a fake username instead of the real one We can't use user home dir path as a subpath on Windows * Cleanup test workflow * Run test workflow on pull requests * Cleanup
1 parent e8f4baa commit 21dd63d

12 files changed

+5179
-5031
lines changed

Diff for: .github/workflows/test.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test-matrix:
8+
strategy:
9+
matrix:
10+
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
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@v2
20+
21+
- name: Install Go
22+
uses: actions/setup-go@v2
23+
with:
24+
go-version: "1.14"
25+
26+
- name: Install Dependencies (Linux)
27+
# run: sudo apt-get install ninja-build
28+
run: sudo apt update && sudo apt install -y --no-install-recommends build-essential libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev
29+
if: matrix.operating-system == 'ubuntu-latest'
30+
31+
- name: Install Go deps
32+
# Since 10/23/2019 pwsh is the default shell
33+
# on Windows, but pwsh fails to install protoc-gen-go so
34+
# we force bash as default shell for all OSes in this task
35+
run: |
36+
go get github.com/golangci/govet
37+
go get golang.org/x/lint/golint
38+
shell: bash
39+
40+
- name: Install Taskfile
41+
uses: Arduino/actions/setup-taskfile@master
42+
with:
43+
repo-token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Check the code is good
46+
run: task check
47+
48+
- name: Build the Agent
49+
run: task build
50+
51+
- name: Run unit tests
52+
run: task test-unit
53+
54+
# - name: Send unit tests coverage to Codecov
55+
# if: >
56+
# matrix.operating-system == 'ubuntu-latest' &&
57+
# github.event_name == 'push'
58+
# uses: codecov/codecov-action@v1
59+
# with:
60+
# file: ./coverage_unit.txt
61+
# flags: unit
62+
63+
# - name: Send legacy tests coverage to Codecov
64+
# if: >
65+
# matrix.operating-system == 'ubuntu-latest' &&
66+
# github.event_name == 'push'
67+
# uses: codecov/codecov-action@v1
68+
# with:
69+
# file: ./coverage_legacy.txt
70+
# flags: unit
71+
72+
# - name: Send integration tests coverage to Codecov
73+
# if: >
74+
# matrix.operating-system == 'ubuntu-latest' &&
75+
# github.event_name == 'push'
76+
# uses: codecov/codecov-action@v1
77+
# with:
78+
# file: ./coverage_integ.txt
79+
# flags: integ

Diff for: Taskfile.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
version: "2"
2+
3+
tasks:
4+
5+
build:
6+
desc: Build the project
7+
cmds:
8+
- go build -v -i {{.LDFLAGS}}
9+
10+
test:
11+
desc: Run the full testsuite, `legacy` will be skipped
12+
cmds:
13+
- task: test-unit
14+
15+
test-unit:
16+
desc: Run unit tests only
17+
cmds:
18+
- go test -short -run '{{ default ".*" .TEST_REGEX }}' {{ default "-v" .GOFLAGS }} -coverprofile=coverage_unit.txt {{ default .DEFAULT_TARGETS .TARGETS }} {{.TEST_LDFLAGS}}
19+
20+
check:
21+
desc: Check fmt and lint
22+
cmds:
23+
- go version
24+
- go fmt {{ default .DEFAULT_TARGETS .TARGETS }}
25+
- test -z $(go fmt {{ default .DEFAULT_TARGETS .TARGETS }})
26+
- echo 'test ok'
27+
- go vet {{ default .DEFAULT_TARGETS .TARGETS }}
28+
- echo 'vet ok'
29+
# FIXME: too many suggestions are failing the check, I'll fix these one in
30+
# another PR.
31+
# - "'{{.GOLINTBIN}}' {{.GOLINTFLAGS}} {{ default .DEFAULT_TARGETS .TARGETS }}"
32+
# - task: i18n:check
33+
# - task: python:check
34+
# - task: docs:check
35+
# - task: config:check
36+
37+
vars:
38+
# all modules of this project except for "gen/..." module
39+
DEFAULT_TARGETS:
40+
sh: echo `go list ./... | grep -v 'arduino-create-agent/gen/' | tr '\n' ' '`
41+
# build vars
42+
COMMIT:
43+
sh: echo ${TRAVIS_COMMIT:-`git log -n 1 --format=%h`}
44+
LDFLAGS: >
45+
-ldflags '-X github.com/arduino/arduino-create-agent/version.commit={{.COMMIT}}'
46+
# test vars
47+
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
48+
TEST_VERSIONSTRING: "0.0.0-test.preview"
49+
TEST_COMMIT: "deadbeef"
50+
TEST_LDFLAGS: >
51+
-ldflags '-X github.com/arduino/arduino-create-agent/version.versionString={{.TEST_VERSIONSTRING}}
52+
-X github.com/arduino/arduino-create-agent/version.commit={{.TEST_COMMIT}}'
53+
# check-lint vars
54+
GOLINTBIN:
55+
sh: go list -f {{"{{"}}".Target{{"}}"}}" golang.org/x/lint/golint
56+
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"
57+
# # docs versioning
58+
# DOCS_VERSION: dev
59+
# DOCS_ALIAS: ""
60+
# DOCS_REMOTE: "origin"
61+

0 commit comments

Comments
 (0)