Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use project Go version for generating website content #353

Merged
merged 1 commit into from
May 16, 2023
Merged

Use project Go version for generating website content #353

merged 1 commit into from
May 16, 2023

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 16, 2023

The "Deploy Website" (Cobra, versioned, MkDocs, Poetry) template is used to generate and publish a documentation website for projects based on the Cobra command line application framework.

Command line reference pages are generated from the project's Go codebase.

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 (actions/runner-images#7276) caused the generation process to fail during the workflow runs in some projects that use older Go versions:

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/[email protected]/zipexe.go:128 +0x8b
github.com/daaku/go%2ezipexe.NewReader({0xa38040, 0xc0000140f0}, 0x0?)
	/home/runner/go/pkg/mod/github.com/daaku/[email protected]/zipexe.go:48 +0x98
github.com/daaku/go%2ezipexe.OpenCloser({0xc0000822a0?, 0xc0000e5720?})
	/home/runner/go/pkg/mod/github.com/daaku/[email protected]/zipexe.go:30 +0x57
github.com/cmaglie/go%2erice.init.0()
	/home/runner/go/pkg/mod/github.com/cmaglie/[email protected]/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.


This fix has already been applied to the installations of the template in several projects:


NOTE: I did not apply the equivalent patch to the "Check Markdown (task)" template as was done in arduino/arduino-lint#542 and arduino/arduino-fwuploader#167 because that template is intended to be applicable to any project, while the patch is only necessary in projects that use Go to generate Markdown-based documentation content. So the work needed on that template is not so straightforward as it is for the "Deploy Website" (Cobra, versioned, MkDocs, Poetry) template, which will always use Go in any project it is applied to.

I hope to find time to also follow up on improving the "Check Markdown (task)" template in this respect, but thought it best to at least immediately pull the straightforward fix up from the downstream projects.

The "Deploy Website" (Cobra, versioned, MkDocs, Poetry) template is used to generate and publish a documentation website
for projects based on the Cobra command line application framework.

Command line reference pages are generated from the project's Go codebase.

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 during the
workflow runs in some projects that use older Go versions:

```
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/[email protected]/zipexe.go:128 +0x8b
github.com/daaku/go%2ezipexe.NewReader({0xa38040, 0xc0000140f0}, 0x0?)
	/home/runner/go/pkg/mod/github.com/daaku/[email protected]/zipexe.go:48 +0x98
github.com/daaku/go%2ezipexe.OpenCloser({0xc0000822a0?, 0xc0000e5720?})
	/home/runner/go/pkg/mod/github.com/daaku/[email protected]/zipexe.go:30 +0x57
github.com/cmaglie/go%2erice.init.0()
	/home/runner/go/pkg/mod/github.com/cmaglie/[email protected]/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.
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels May 16, 2023
@per1234 per1234 self-assigned this May 16, 2023
@per1234 per1234 requested a review from MatteoPologruto May 16, 2023 06:41
Copy link
Contributor

@MatteoPologruto MatteoPologruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Per!

@per1234 per1234 merged commit 6de0a54 into arduino:main May 16, 2023
@per1234 per1234 deleted the set-go-version branch May 16, 2023 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants