Skip to content

Commit ac5c2db

Browse files
authored
Merge pull request #227 from per1234/test
Sync test assets workflow with templates
2 parents 96a6178 + 3bc729c commit ac5c2db

File tree

39 files changed

+252
-117
lines changed

39 files changed

+252
-117
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Check Code Generation
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/check-code-generation-task.ya?ml"
7+
- "Taskfile.yml"
8+
- "go.mod"
9+
- "go.sum"
10+
- "**/*.go"
11+
- "etc/schemas/**/*.json"
12+
pull_request:
13+
paths:
14+
- ".github/workflows/check-code-generation-task.ya?ml"
15+
- "Taskfile.yml"
16+
- "go.mod"
17+
- "go.sum"
18+
- "**/*.go"
19+
- "etc/schemas/**/*.json"
20+
21+
env:
22+
BUILDS_ARTIFACT: build-artifacts
23+
24+
jobs:
25+
test-go:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout local repository
30+
uses: actions/checkout@v2
31+
32+
- name: Install Go
33+
uses: actions/setup-go@v2
34+
with:
35+
go-version: "1.16"
36+
37+
- name: Install Taskfile
38+
uses: arduino/setup-task@v1
39+
with:
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}
41+
version: 3.x
42+
43+
- name: Generate code
44+
run: task go:generate
45+
46+
- name: Check for forgotten code generation
47+
run: git diff --color --exit-code

.github/workflows/test.yml renamed to .github/workflows/publish-go-tester-task.yml

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,37 @@
1-
name: Run tests
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
2+
name: Publish Tester Build
23

4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
35
on:
46
push:
57
paths:
6-
- ".github/workflows/test.yml"
7-
- "Taskfile.yml"
8+
- ".github/workflows/publish-go-tester-task.ya?ml"
89
- "go.mod"
910
- "go.sum"
10-
- "**/*.go"
11-
- "**/testdata/**"
12-
- "etc/schemas/**/*.json"
13-
- "pyproject.toml"
14-
- "test/**"
15-
- "Taskfile.yml"
11+
- "Taskfile.ya?ml"
12+
- "**.go"
1613
pull_request:
1714
paths:
18-
- ".github/workflows/test.yml"
19-
- "Taskfile.yml"
15+
- ".github/workflows/publish-go-tester-task.ya?ml"
2016
- "go.mod"
2117
- "go.sum"
22-
- "**/*.go"
23-
- "**/testdata/**"
24-
- "etc/schemas/**/*.json"
25-
- "pyproject.toml"
26-
- "test/**"
27-
- "Taskfile.yml"
18+
- "Taskfile.ya?ml"
19+
- "**.go"
20+
workflow_dispatch:
21+
repository_dispatch:
2822

2923
env:
24+
# As defined by the Taskfile's DIST_DIR variable
25+
DIST_DIR: dist
3026
BUILDS_ARTIFACT: build-artifacts
3127

3228
jobs:
33-
test-go:
34-
strategy:
35-
matrix:
36-
operating-system:
37-
- ubuntu-latest
38-
- windows-latest
39-
- macOS-latest
40-
41-
runs-on: ${{ matrix.operating-system }}
42-
43-
steps:
44-
- name: Checkout local repository
45-
uses: actions/checkout@v2
46-
47-
- name: Install Go
48-
uses: actions/setup-go@v2
49-
with:
50-
go-version: "1.16"
51-
52-
- name: Install Taskfile
53-
uses: arduino/setup-task@v1
54-
with:
55-
repo-token: ${{ secrets.GITHUB_TOKEN }}
56-
version: 3.x
57-
58-
- name: Generate code
59-
run: task go:generate
60-
61-
- name: Check for forgotten code generation
62-
run: git diff --color --exit-code
63-
64-
- name: Run unit tests
65-
run: task go:test-unit
66-
67-
- name: Send unit tests coverage to Codecov
68-
if: matrix.operating-system == 'ubuntu-latest'
69-
uses: codecov/codecov-action@v1
70-
with:
71-
file: ./coverage_unit.txt
72-
flags: unit
73-
fail_ci_if_error: true
74-
75-
- name: Install Python
76-
uses: actions/setup-python@v2
77-
with:
78-
python-version: "3.9"
79-
80-
- name: Install Poetry
81-
run: pip install poetry
82-
83-
- name: Run integration tests
84-
run: task test-integration
85-
8629
build:
8730
runs-on: ubuntu-latest
8831

8932
steps:
9033
- name: Checkout repository
91-
uses: actions/checkout@v1
34+
uses: actions/checkout@v2
9235
with:
9336
fetch-depth: 0
9437

@@ -112,7 +55,7 @@ jobs:
11255
- name: Upload combined builds artifact
11356
uses: actions/upload-artifact@v2
11457
with:
115-
path: dist/
58+
path: ${{ env.DIST_DIR }}
11659
name: ${{ env.BUILDS_ARTIFACT }}
11760

11861
artifacts:
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test Integration
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/test-go-integration-task.ya?ml"
7+
- "Taskfile.ya?ml"
8+
- "**.go"
9+
- "go.mod"
10+
- "go.sum"
11+
- "poetry.lock"
12+
- "pyproject.toml"
13+
- "tests/**"
14+
pull_request:
15+
paths:
16+
- ".github/workflows/test-go-integration-task.ya?ml"
17+
- "Taskfile.ya?ml"
18+
- "**.go"
19+
- "go.mod"
20+
- "go.sum"
21+
- "poetry.lock"
22+
- "pyproject.toml"
23+
- "tests/**"
24+
25+
jobs:
26+
test-go:
27+
strategy:
28+
matrix:
29+
operating-system:
30+
- ubuntu-latest
31+
- windows-latest
32+
- macOS-latest
33+
34+
runs-on: ${{ matrix.operating-system }}
35+
36+
steps:
37+
- name: Checkout local repository
38+
uses: actions/checkout@v2
39+
40+
- name: Install Go
41+
uses: actions/setup-go@v2
42+
with:
43+
go-version: "1.16"
44+
45+
- name: Install Taskfile
46+
uses: arduino/setup-task@v1
47+
with:
48+
repo-token: ${{ secrets.GITHUB_TOKEN }}
49+
version: 3.x
50+
51+
- name: Install Python
52+
uses: actions/setup-python@v2
53+
with:
54+
python-version: "3.9"
55+
56+
- name: Install Poetry
57+
run: pip install poetry
58+
59+
- name: Run integration tests
60+
run: task go:test-integration

.github/workflows/test-go-task.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/test-go-task.ya?ml"
7+
- "Taskfile.yml"
8+
- "go.mod"
9+
- "go.sum"
10+
- "**/*.go"
11+
- "**/testdata/**"
12+
pull_request:
13+
paths:
14+
- ".github/workflows/test-go-task.ya?ml"
15+
- "Taskfile.yml"
16+
- "go.mod"
17+
- "go.sum"
18+
- "**/*.go"
19+
- "**/testdata/**"
20+
21+
env:
22+
BUILDS_ARTIFACT: build-artifacts
23+
24+
jobs:
25+
test-go:
26+
strategy:
27+
matrix:
28+
operating-system:
29+
- ubuntu-latest
30+
- windows-latest
31+
- macOS-latest
32+
33+
runs-on: ${{ matrix.operating-system }}
34+
35+
steps:
36+
- name: Checkout local repository
37+
uses: actions/checkout@v2
38+
39+
- name: Install Go
40+
uses: actions/setup-go@v2
41+
with:
42+
go-version: "1.16"
43+
44+
- name: Install Taskfile
45+
uses: arduino/setup-task@v1
46+
with:
47+
repo-token: ${{ secrets.GITHUB_TOKEN }}
48+
version: 3.x
49+
50+
- name: Run unit tests
51+
run: task go:test
52+
53+
- name: Send unit tests coverage to Codecov
54+
if: matrix.operating-system == 'ubuntu-latest'
55+
uses: codecov/codecov-action@v1
56+
with:
57+
file: ./coverage_unit.txt
58+
flags: unit
59+
fail_ci_if_error: true

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Arduino Lint
22

3-
[![Tests Status](https://github.com/arduino/arduino-lint/workflows/Run%20tests/badge.svg)](https://github.com/arduino/arduino-lint/actions?workflow=Run+tests)
3+
[![Test Go status](https://github.com/arduino/arduino-lint/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/test-go-task.yml)
4+
[![Test Integration status](https://github.com/arduino/arduino-lint/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/test-go-integration-task.yml)
45
[![Check Go status](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-go-task.yml)
6+
[![Check Code Generation status](https://github.com/arduino/arduino-lint/actions/workflows/check-code-generation-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-code-generation-task.yml)
7+
[![Publish Tester Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-tester-task.yml)
58
[![Publish Nightly Build status](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/publish-go-nightly-task.yml)
69
[![Check Python status](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-python-task.yml)
710
[![Check Markdown status](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-markdown-task.yml)

Taskfile.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ vars:
99
PROJECT_NAME: "arduino-lint"
1010
DIST_DIR: "dist"
1111
DEFAULT_GO_PACKAGES:
12-
sh: echo `go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' '`
12+
sh: echo $(go list ./... | grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | tr '\n' ' ')
1313
# build vars
1414
COMMIT:
1515
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
@@ -28,7 +28,6 @@ vars:
2828
-X {{.CONFIGURATION_PACKAGE}}.Commit={{.COMMIT}}
2929
-X {{.CONFIGURATION_PACKAGE}}.Timestamp={{.TIMESTAMP}}
3030
'
31-
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
3231
DOCS_VERSION: dev
3332
DOCS_ALIAS: ""
3433
DOCS_REMOTE: "origin"
@@ -41,14 +40,20 @@ vars:
4140
tasks:
4241
build:
4342
desc: Build the project
44-
cmds:
45-
- go build -v {{.LDFLAGS}}
43+
deps:
44+
- task: go:build
4645

4746
test:
4847
desc: Run tests
4948
cmds:
50-
- task: go:test-unit
51-
- task: test-integration
49+
- task: go:test
50+
- task: go:test-integration
51+
52+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
53+
go:build:
54+
desc: Build the Go code
55+
cmds:
56+
- go build -v {{.LDFLAGS}}
5257

5358
go:generate:
5459
desc: Generate Go code
@@ -60,17 +65,27 @@ tasks:
6065
- go generate ./...
6166
- task: go:format
6267

63-
go:test-unit:
68+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
69+
go:test:
6470
desc: Run unit tests
6571
cmds:
66-
- go test -short -run '{{default ".*" .TEST_REGEX}}' {{default "-v" .GOFLAGS}} -coverprofile=coverage_unit.txt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
72+
- |
73+
go test \
74+
-v \
75+
-short \
76+
-run '{{default ".*" .GO_TEST_REGEX}}' \
77+
{{default "-timeout 10m -coverpkg=./... -covermode=atomic" .GO_TEST_FLAGS}} \
78+
-coverprofile=coverage_unit.txt \
79+
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
6780
68-
test-integration:
81+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-integration-task/Taskfile.yml
82+
go:test-integration:
6983
desc: Run integration tests
84+
deps:
85+
- task: go:build
86+
- task: poetry:install-deps
7087
cmds:
71-
- task: build
72-
- poetry install --no-root
73-
- poetry run pytest test
88+
- poetry run pytest tests
7489

7590
check:
7691
desc: Lint and check formatting of all files

0 commit comments

Comments
 (0)