Skip to content

Commit be9eff0

Browse files
committed
Use go.mod as source of Go version number for workflows
Go is used in the development and maintenance of the project. A standardized version of Go is used for all operations. This version is defined in the `go` directive of the go.mod metadata file. Go is installed in the GitHub Actions runner environments using the "actions/setup-go" action, which also must be configured to install the correct version of Go. Previously the version number for use by the "actions/setup-go" action was defined in each workflow. This meant that we had multiple copies of the Go version information, all of which had to be kept in sync. Fortunately, support for using `go.mod` as the source of version information for the "actions/setup-go" action was recently added. This means it is now possible for all workflows to get the Go version from a single source.
1 parent 51dfd70 commit be9eff0

9 files changed

+24
-46
lines changed

Diff for: .github/workflows/check-code-generation-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Check Code Generation
22

3-
env:
4-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
5-
GO_VERSION: "1.17"
6-
73
on:
84
create:
95
push:
@@ -61,7 +57,7 @@ jobs:
6157
- name: Install Go
6258
uses: actions/setup-go@v5
6359
with:
64-
go-version: ${{ env.GO_VERSION }}
60+
go-version-file: go.mod
6561

6662
- name: Install Task
6763
uses: arduino/setup-task@v2

Diff for: .github/workflows/check-go-dependencies-task.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md
22
name: Check Go Dependencies
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -87,7 +83,7 @@ jobs:
8783
- name: Install Go
8884
uses: actions/setup-go@v5
8985
with:
90-
go-version: ${{ env.GO_VERSION }}
86+
go-version-file: go.mod
9187

9288
- name: Install Task
9389
uses: arduino/setup-task@v2
@@ -146,7 +142,7 @@ jobs:
146142
- name: Install Go
147143
uses: actions/setup-go@v5
148144
with:
149-
go-version: ${{ env.GO_VERSION }}
145+
go-version-file: go.mod
150146

151147
- name: Install Task
152148
uses: arduino/setup-task@v2

Diff for: .github/workflows/check-go-task.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md
22
name: Check Go
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -77,7 +73,7 @@ jobs:
7773
- name: Install Go
7874
uses: actions/setup-go@v5
7975
with:
80-
go-version: ${{ env.GO_VERSION }}
76+
go-version-file: go.mod
8177

8278
- name: Install Task
8379
uses: arduino/setup-task@v2
@@ -114,7 +110,7 @@ jobs:
114110
- name: Install Go
115111
uses: actions/setup-go@v5
116112
with:
117-
go-version: ${{ env.GO_VERSION }}
113+
go-version-file: go.mod
118114

119115
- name: Install Task
120116
uses: arduino/setup-task@v2
@@ -154,7 +150,7 @@ jobs:
154150
- name: Install Go
155151
uses: actions/setup-go@v5
156152
with:
157-
go-version: ${{ env.GO_VERSION }}
153+
go-version-file: go.mod
158154

159155
- name: Install Task
160156
uses: arduino/setup-task@v2
@@ -194,7 +190,7 @@ jobs:
194190
- name: Install Go
195191
uses: actions/setup-go@v5
196192
with:
197-
go-version: ${{ env.GO_VERSION }}
193+
go-version-file: go.mod
198194

199195
- name: Install Task
200196
uses: arduino/setup-task@v2
@@ -234,7 +230,7 @@ jobs:
234230
- name: Install Go
235231
uses: actions/setup-go@v5
236232
with:
237-
go-version: ${{ env.GO_VERSION }}
233+
go-version-file: go.mod
238234

239235
- name: Install Task
240236
uses: arduino/setup-task@v2

Diff for: .github/workflows/check-markdown-task.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
22
name: Check Markdown
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -17,6 +13,8 @@ on:
1713
- "package-lock.json"
1814
- "Taskfile.ya?ml"
1915
- "**/.markdownlint*"
16+
- "**/go.mod"
17+
- "**/go.sum"
2018
- "**.mdx?"
2119
- "**.mkdn"
2220
- "**.mdown"
@@ -30,6 +28,8 @@ on:
3028
- "package-lock.json"
3129
- "Taskfile.ya?ml"
3230
- "**/.markdownlint*"
31+
- "**/go.mod"
32+
- "**/go.sum"
3333
- "**.mdx?"
3434
- "**.mkdn"
3535
- "**.mdown"
@@ -107,7 +107,7 @@ jobs:
107107
- name: Install Go
108108
uses: actions/setup-go@v5
109109
with:
110-
go-version: ${{ env.GO_VERSION }}
110+
go-version-file: go.mod
111111

112112
- name: Setup Node.js
113113
uses: actions/setup-node@v4

Diff for: .github/workflows/check-mkdocs-task.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-mkdocs-task.md
22
name: Check Website
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
117
push:
128
paths:
139
- ".github/workflows/check-mkdocs-task.ya?ml"
1410
- "**/.npmrc"
11+
- "**/go.mod"
12+
- "**/go.sum"
1513
- "Taskfile.ya?ml"
1614
- "mkdocs.ya?ml"
1715
- "package.json"
@@ -26,6 +24,8 @@ on:
2624
paths:
2725
- ".github/workflows/check-mkdocs-task.ya?ml"
2826
- "**/.npmrc"
27+
- "**/go.mod"
28+
- "**/go.sum"
2929
- "Taskfile.ya?ml"
3030
- "mkdocs.ya?ml"
3131
- "package.json"
@@ -81,7 +81,7 @@ jobs:
8181
- name: Install Go
8282
uses: actions/setup-go@v5
8383
with:
84-
go-version: ${{ env.GO_VERSION }}
84+
go-version-file: go.mod
8585

8686
- name: Install Python
8787
uses: actions/setup-python@v5

Diff for: .github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md
22
name: Deploy Website
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
on:
95
push:
106
branches:
@@ -69,7 +65,7 @@ jobs:
6965
- name: Install Go
7066
uses: actions/setup-go@v5
7167
with:
72-
go-version: ${{ env.GO_VERSION }}
68+
go-version-file: go.mod
7369

7470
- name: Install Python
7571
uses: actions/setup-python@v5

Diff for: .github/workflows/test-go-integration-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-integration-task.md
22
name: Test Integration
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -81,7 +77,7 @@ jobs:
8177
- name: Install Go
8278
uses: actions/setup-go@v5
8379
with:
84-
go-version: ${{ env.GO_VERSION }}
80+
go-version-file: go.mod
8581

8682
- name: Install Python
8783
uses: actions/setup-python@v5

Diff for: .github/workflows/test-go-task.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-task.md
22
name: Test Go
33

4-
env:
5-
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6-
GO_VERSION: "1.17"
7-
84
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -91,7 +87,7 @@ jobs:
9187
- name: Install Go
9288
uses: actions/setup-go@v5
9389
with:
94-
go-version: ${{ env.GO_VERSION }}
90+
go-version-file: go.mod
9591

9692
- name: Install Task
9793
uses: arduino/setup-task@v2

Diff for: docs/CONTRIBUTING.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ submitting a PR:
7676

7777
To build Arduino Lint from sources you need the following tools to be available in your local environment:
7878

79-
- [Go](https://golang.org/doc/install) version 1.17 or later
79+
- [Go](https://golang.org/doc/install
80+
- The **Go** version in use is defined in the `go` directive of
81+
[`go.mod`](https://github.com/arduino/arduino-lint/blob/main/go.mod).
8082
- [Taskfile](https://taskfile.dev/#/installation) to help you run the most common tasks from the command line
8183

8284
If you want to run integration tests or work on documentation, you will also need:

0 commit comments

Comments
 (0)