Skip to content

Commit bc76153

Browse files
committed
Use project Go version for generating website content
The project documentation is published on a companion website. A GitHub Actions workflow is used to automatically update the website whenever any relevant file is changed in the repository. This website includes content generated from the project's Go code. Previously, the default version of Go from the GitHub Actions runner machine was used for generating the documentation content. A recent update of this default Go version from 1.17 to 1.20 caused the generation process to fail: ``` task: [go:rule-docs] ./ruledocsgen ../docs/rules panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xa29866] goroutine 1 [running]: debug/elf.(*Section).ReadAt(0xc0003a4000?, {0xc000376000?, 0x24?, 0x23?}, 0x23?) <autogenerated>:1 +0x26 archive/zip.readDirectoryEnd({0xe9d780, 0xc000328b80}, 0x210) /opt/hostedtoolcache/go/1.20.4/x64/src/archive/zip/reader.go:581 +0xf5 archive/zip.(*Reader).init(0xc00030bc70, {0xe9d780?, 0xc000328b80}, 0x210) /opt/hostedtoolcache/go/1.20.4/x64/src/archive/zip/reader.go:124 +0x5c archive/zip.NewReader({0xe9d780, 0xc000328b80}, 0x210) /opt/hostedtoolcache/go/1.20.4/x64/src/archive/zip/reader.go:103 +0x5e github.com/daaku/go%2ezipexe.zipExeReaderElf({0xea05a0?, 0xc000120840}, 0x1846986) /home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.1/zipexe.go:128 +0x8b github.com/daaku/go%2ezipexe.NewReader({0xea05a0, 0xc000120840}, 0x0?) /home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.1/zipexe.go:48 +0x98 github.com/daaku/go%2ezipexe.OpenCloser({0xc0001543c0?, 0xc000147390?}) /home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.1/zipexe.go:30 +0x57 github.com/cmaglie/go%2erice.init.0() /home/runner/go/pkg/mod/github.com/cmaglie/go.rice@v1.0.3/appended.go:42 +0x65 ``` This error, and the general fragility that comes from the lack of control over the Go version, is avoided by configuring the workflow to use the specific version of Go that is used for development and validation of the project.
1 parent a7dcecc commit bc76153

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
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+
48
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
59
on:
610
push:
@@ -56,6 +60,11 @@ jobs:
5660
- name: Checkout repository
5761
uses: actions/checkout@v3
5862

63+
- name: Install Go
64+
uses: actions/setup-go@v4
65+
with:
66+
go-version: ${{ env.GO_VERSION }}
67+
5968
- name: Install Task
6069
uses: arduino/setup-task@v1
6170
with:

.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name: Deploy Website
33

44
env:
5+
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
6+
GO_VERSION: "1.17"
57
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
68
PYTHON_VERSION: "3.9"
79

@@ -54,6 +56,11 @@ jobs:
5456
- name: Checkout repository
5557
uses: actions/checkout@v3
5658

59+
- name: Install Go
60+
uses: actions/setup-go@v4
61+
with:
62+
go-version: ${{ env.GO_VERSION }}
63+
5764
- name: Install Python
5865
uses: actions/setup-python@v4
5966
with:

0 commit comments

Comments
 (0)