Skip to content

Commit

Permalink
Use project Go version for generating website content (#167)
Browse files Browse the repository at this point in the history
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:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x83c1a6]

goroutine 1 [running]:
debug/elf.(*Section).ReadAt(0xc0001be000?, {0xc0001ce000?, 0x24?, 0x23?}, 0x23?)
	<autogenerated>:1 +0x26
archive/zip.readDirectoryEnd({0xa37480, 0xc0000af580}, 0x210)
	/opt/hostedtoolcache/go/1.20.3/x64/src/archive/zip/reader.go:581 +0xf5
archive/zip.(*Reader).init(0xc000137500, {0xa37480?, 0xc0000af580}, 0x210)
	/opt/hostedtoolcache/go/1.20.3/x64/src/archive/zip/reader.go:124 +0x5c
archive/zip.NewReader({0xa37480, 0xc0000af580}, 0x210)
	/opt/hostedtoolcache/go/1.20.3/x64/src/archive/zip/reader.go:103 +0x5e
github.com/daaku/go%2ezipexe.zipExeReaderElf({0xa38040?, 0xc0000140f0}, 0xdc51bf)
	/home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.0/zipexe.go:128 +0x8b
github.com/daaku/go%2ezipexe.NewReader({0xa38040, 0xc0000140f0}, 0x0?)
	/home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.0/zipexe.go:48 +0x98
github.com/daaku/go%2ezipexe.OpenCloser({0xc0000822a0?, 0xc0000e5720?})
	/home/runner/go/pkg/mod/github.com/daaku/go.zipexe@v1.0.0/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
task: Failed to run task "go:cli-docs": exit status 2
```

This error, and the general fragility that comes from not controlling 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.
  • Loading branch information
per1234 authored May 15, 2023
1 parent b961277 commit eacf4f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/check-markdown-task.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
name: Check Markdown

env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.18"

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
Expand Down Expand Up @@ -56,6 +60,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Task
uses: arduino/setup-task@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: Deploy Website

env:
# See: https://github.com/actions/setup-go/tree/main#supported-version-syntax
GO_VERSION: "1.18"
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
PYTHON_VERSION: "3.9"

Expand Down Expand Up @@ -59,6 +61,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Python
uses: actions/setup-python@v4
with:
Expand Down

0 comments on commit eacf4f9

Please sign in to comment.