Skip to content

Commit dab52f1

Browse files
authored
Merge pull request #65 from per1234/check-go
Sync "Check Go" CI workflow with template
2 parents 8c95f28 + af93ca7 commit dab52f1

File tree

5 files changed

+228
-106
lines changed

5 files changed

+228
-106
lines changed

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

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md
2+
name: Check Go
3+
4+
env:
5+
# See: https://github.com/actions/setup-go/tree/v2#readme
6+
GO_VERSION: "1.16"
7+
8+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/check-go-task.ya?ml"
13+
- "Taskfile.ya?ml"
14+
- "**/go.mod"
15+
- "**/go.sum"
16+
- "**.go"
17+
pull_request:
18+
paths:
19+
- ".github/workflows/check-go-task.ya?ml"
20+
- "Taskfile.ya?ml"
21+
- "**/go.mod"
22+
- "**/go.sum"
23+
- "**.go"
24+
schedule:
25+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
26+
- cron: "0 8 * * TUE"
27+
workflow_dispatch:
28+
repository_dispatch:
29+
30+
jobs:
31+
check-errors:
32+
name: check-errors (${{ matrix.module.path }})
33+
runs-on: ubuntu-latest
34+
35+
strategy:
36+
fail-fast: false
37+
38+
matrix:
39+
module:
40+
- path: ./
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v2
45+
46+
- name: Install Go
47+
uses: actions/setup-go@v2
48+
with:
49+
go-version: ${{ env.GO_VERSION }}
50+
51+
- name: Install Task
52+
uses: arduino/setup-task@v1
53+
with:
54+
repo-token: ${{ secrets.GITHUB_TOKEN }}
55+
version: 3.x
56+
57+
- name: Check for errors
58+
env:
59+
GO_MODULE_PATH: ${{ matrix.module.path }}
60+
run: task go:vet
61+
62+
check-outdated:
63+
name: check-outdated (${{ matrix.module.path }})
64+
runs-on: ubuntu-latest
65+
66+
strategy:
67+
fail-fast: false
68+
69+
matrix:
70+
module:
71+
- path: ./
72+
73+
steps:
74+
- name: Checkout repository
75+
uses: actions/checkout@v2
76+
77+
- name: Install Go
78+
uses: actions/setup-go@v2
79+
with:
80+
go-version: ${{ env.GO_VERSION }}
81+
82+
- name: Install Task
83+
uses: arduino/setup-task@v1
84+
with:
85+
repo-token: ${{ secrets.GITHUB_TOKEN }}
86+
version: 3.x
87+
88+
- name: Modernize usages of outdated APIs
89+
env:
90+
GO_MODULE_PATH: ${{ matrix.module.path }}
91+
run: task go:fix
92+
93+
- name: Check if any fixes were needed
94+
run: git diff --color --exit-code
95+
96+
check-style:
97+
name: check-style (${{ matrix.module.path }})
98+
runs-on: ubuntu-latest
99+
100+
strategy:
101+
fail-fast: false
102+
103+
matrix:
104+
module:
105+
- path: ./
106+
107+
steps:
108+
- name: Checkout repository
109+
uses: actions/checkout@v2
110+
111+
- name: Install Go
112+
uses: actions/setup-go@v2
113+
with:
114+
go-version: ${{ env.GO_VERSION }}
115+
116+
- name: Install Task
117+
uses: arduino/setup-task@v1
118+
with:
119+
repo-token: ${{ secrets.GITHUB_TOKEN }}
120+
version: 3.x
121+
122+
- name: Install golint
123+
run: go install golang.org/x/lint/golint@latest
124+
125+
- name: Check style
126+
env:
127+
GO_MODULE_PATH: ${{ matrix.module.path }}
128+
run: task --silent go:lint
129+
130+
check-formatting:
131+
name: check-formatting (${{ matrix.module.path }})
132+
runs-on: ubuntu-latest
133+
134+
strategy:
135+
fail-fast: false
136+
137+
matrix:
138+
module:
139+
- path: ./
140+
141+
steps:
142+
- name: Checkout repository
143+
uses: actions/checkout@v2
144+
145+
- name: Install Go
146+
uses: actions/setup-go@v2
147+
with:
148+
go-version: ${{ env.GO_VERSION }}
149+
150+
- name: Install Task
151+
uses: arduino/setup-task@v1
152+
with:
153+
repo-token: ${{ secrets.GITHUB_TOKEN }}
154+
version: 3.x
155+
156+
- name: Format code
157+
env:
158+
GO_MODULE_PATH: ${{ matrix.module.path }}
159+
run: task go:format
160+
161+
- name: Check formatting
162+
run: git diff --color --exit-code
163+
164+
check-config:
165+
name: check-config (${{ matrix.module.path }})
166+
runs-on: ubuntu-latest
167+
168+
strategy:
169+
fail-fast: false
170+
171+
matrix:
172+
module:
173+
- path: ./
174+
175+
steps:
176+
- name: Checkout repository
177+
uses: actions/checkout@v2
178+
179+
- name: Install Go
180+
uses: actions/setup-go@v2
181+
with:
182+
go-version: ${{ env.GO_VERSION }}
183+
184+
- name: Run go mod tidy
185+
working-directory: ${{ matrix.module.path }}
186+
run: go mod tidy
187+
188+
- name: Check whether any tidying was needed
189+
run: git diff --color --exit-code

.github/workflows/check-go.yml

-97
This file was deleted.

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

+21-7
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ on:
1111
paths:
1212
- ".github/workflows/test-go-task.ya?ml"
1313
- "codecov.ya?ml"
14-
- "go.mod"
15-
- "go.sum"
14+
- "**/go.mod"
15+
- "**/go.sum"
1616
- "Taskfile.ya?ml"
1717
- "**.go"
1818
- "**/testdata/**"
1919
pull_request:
2020
paths:
2121
- ".github/workflows/test-go-task.ya?ml"
2222
- "codecov.ya?ml"
23-
- "go.mod"
24-
- "go.sum"
23+
- "**/go.mod"
24+
- "**/go.sum"
2525
- "Taskfile.ya?ml"
2626
- "**.go"
2727
- "**/testdata/**"
@@ -30,7 +30,19 @@ on:
3030

3131
jobs:
3232
test:
33-
runs-on: ubuntu-latest
33+
name: test (${{ matrix.module.path }} - ${{ matrix.operating-system }})
34+
35+
strategy:
36+
fail-fast: false
37+
38+
matrix:
39+
operating-system:
40+
- ubuntu-latest
41+
module:
42+
- path: ./
43+
codecov-flags: unit
44+
45+
runs-on: ${{ matrix.operating-system }}
3446

3547
steps:
3648
- name: Checkout repository
@@ -48,12 +60,14 @@ jobs:
4860
version: 3.x
4961

5062
- name: Run tests
63+
env:
64+
GO_MODULE_PATH: ${{ matrix.module.path }}
5165
run: task go:test
5266

5367
- name: Send unit tests coverage to Codecov
5468
if: matrix.operating-system == 'ubuntu-latest'
5569
uses: codecov/codecov-action@v2
5670
with:
57-
file: ./coverage_unit.txt
58-
flags: unit
71+
file: ${{ matrix.module.path }}coverage_unit.txt
72+
flags: ${{ matrix.module.codecov-flags }}
5973
fail_ci_if_error: true

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Test Go status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/test-go-task.yml)
44
[![Codecov](https://codecov.io/gh/arduino/library-registry-submission-parser/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/library-registry-submission-parser)
55
[![Test Integration status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/test-go-integration-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/test-go-integration-task.yml)
6-
[![Check Go status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-go.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-go.yml)
6+
[![Check Go status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-go-task.yml)
77
[![Check Python status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-python-task.yml)
88
[![Check Prettier Formatting status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/check-prettier-formatting-task.yml)
99
[![Spell Check status](https://github.com/arduino/library-registry-submission-parser/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/library-registry-submission-parser/actions/workflows/spell-check-task.yml)

0 commit comments

Comments
 (0)