From 4f2f4f500a28268046f2daee1f75b568b8bbd412 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 16 Oct 2024 08:40:00 -0700 Subject: [PATCH 1/2] 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. --- .github/workflows/check-code-generation-task.yml | 6 +----- .github/workflows/check-go-dependencies-task.yml | 8 ++------ .github/workflows/check-go-task.yml | 14 +++++--------- .github/workflows/check-markdown-task.yml | 10 +++++----- .github/workflows/check-mkdocs-task.yml | 10 +++++----- .../deploy-cobra-mkdocs-versioned-poetry.yml | 6 +----- .github/workflows/test-go-integration-task.yml | 6 +----- .github/workflows/test-go-task.yml | 6 +----- 8 files changed, 21 insertions(+), 45 deletions(-) diff --git a/.github/workflows/check-code-generation-task.yml b/.github/workflows/check-code-generation-task.yml index bb953bde..15a08fe2 100644 --- a/.github/workflows/check-code-generation-task.yml +++ b/.github/workflows/check-code-generation-task.yml @@ -1,9 +1,5 @@ name: Check Code Generation -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - on: create: push: @@ -61,7 +57,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-go-dependencies-task.yml b/.github/workflows/check-go-dependencies-task.yml index 2bf7945e..87928ffe 100644 --- a/.github/workflows/check-go-dependencies-task.yml +++ b/.github/workflows/check-go-dependencies-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md name: Check Go Dependencies -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -87,7 +83,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -146,7 +142,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-go-task.yml b/.github/workflows/check-go-task.yml index 86583f2e..17dc7371 100644 --- a/.github/workflows/check-go-task.yml +++ b/.github/workflows/check-go-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md name: Check Go -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -77,7 +73,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -114,7 +110,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -154,7 +150,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -194,7 +190,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 @@ -234,7 +230,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 diff --git a/.github/workflows/check-markdown-task.yml b/.github/workflows/check-markdown-task.yml index b08de436..df7c5af3 100644 --- a/.github/workflows/check-markdown-task.yml +++ b/.github/workflows/check-markdown-task.yml @@ -1,10 +1,6 @@ # 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.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -17,6 +13,8 @@ on: - "package-lock.json" - "Taskfile.ya?ml" - "**/.markdownlint*" + - "**/go.mod" + - "**/go.sum" - "**.mdx?" - "**.mkdn" - "**.mdown" @@ -30,6 +28,8 @@ on: - "package-lock.json" - "Taskfile.ya?ml" - "**/.markdownlint*" + - "**/go.mod" + - "**/go.sum" - "**.mdx?" - "**.mkdn" - "**.mdown" @@ -107,7 +107,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Setup Node.js uses: actions/setup-node@v4 diff --git a/.github/workflows/check-mkdocs-task.yml b/.github/workflows/check-mkdocs-task.yml index d03d836f..a07848cc 100644 --- a/.github/workflows/check-mkdocs-task.yml +++ b/.github/workflows/check-mkdocs-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-mkdocs-task.md name: Check Website -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -12,6 +8,8 @@ on: paths: - ".github/workflows/check-mkdocs-task.ya?ml" - "**/.npmrc" + - "**/go.mod" + - "**/go.sum" - "Taskfile.ya?ml" - "mkdocs.ya?ml" - "package.json" @@ -26,6 +24,8 @@ on: paths: - ".github/workflows/check-mkdocs-task.ya?ml" - "**/.npmrc" + - "**/go.mod" + - "**/go.sum" - "Taskfile.ya?ml" - "mkdocs.ya?ml" - "package.json" @@ -81,7 +81,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Python uses: actions/setup-python@v5 diff --git a/.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml b/.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml index 3c5a1463..842beda9 100644 --- a/.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml +++ b/.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md name: Deploy Website -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - on: push: branches: @@ -69,7 +65,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Python uses: actions/setup-python@v5 diff --git a/.github/workflows/test-go-integration-task.yml b/.github/workflows/test-go-integration-task.yml index 5f78fa9a..c7ca4609 100644 --- a/.github/workflows/test-go-integration-task.yml +++ b/.github/workflows/test-go-integration-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-integration-task.md name: Test Integration -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -81,7 +77,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Python uses: actions/setup-python@v5 diff --git a/.github/workflows/test-go-task.yml b/.github/workflows/test-go-task.yml index f0d2270f..a4a12611 100644 --- a/.github/workflows/test-go-task.yml +++ b/.github/workflows/test-go-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-go-task.md name: Test Go -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.22" - # See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows on: create: @@ -91,7 +87,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Install Task uses: arduino/setup-task@v2 From 79de0f236b6df4f23c105ec53dadec6a6fb624b2 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 21 Nov 2024 22:44:20 -0800 Subject: [PATCH 2/2] Update project Go toolchain version to 1.22.9 Support for specifying the Go toolchain version compatibility of a module to patch version granularity via the `go` directive of the go.mod module metadata file was introduced in Go 1.21.0. The `go` directives of the project's modules were changed to specify the patch version when the project's Go version was bumped to 1.22.3. However, support for this version format was not added to the `go fix` command until Go 1.22.7. This caused the `go fix` command (which is invoked by the "check-outdated" job of the project's "Check Go" workflow) to fail when a version of Go between 1.21.0 and 1.22.6 was used: ``` invalid -go=go1.22.3 exit status 2 task: Failed to run task "go:fix": exit status 1 ``` Previously, this did not affect the CI system because the workflows only specified the Go version to be installed by the "actions/setup-go" action to the minor version (1.22), and the action happened to use a version of Go >1.22.6. However, the "actions/setup-go" action now installs the exact version of Go specified the `go` directive, which means the runs of the "Check Go" workflow would fail with the above error if the value of the `go` directive is >=1.21.0 and <1.22.7. The chosen solution is to bump the value of the `go` directive to a version with the `go fix` command bug fixed. Although this could be achieved by a bump to 1.22.7, it makes sense to bump Go all the way to the latest version in the 1.22.x series (because apparently the production release build system is not compatible with Go 1.23.x). --- DistTasks.yml | 7 ++++--- docsgen/go.mod | 2 +- go.mod | 2 +- ruledocsgen/go.mod | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DistTasks.yml b/DistTasks.yml index 1b754502..eb967164 100644 --- a/DistTasks.yml +++ b/DistTasks.yml @@ -19,7 +19,7 @@ version: "3" vars: CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild" - GO_VERSION: "1.22.5" + GO_VERSION: "1.22.9" tasks: Windows_32bit: @@ -131,11 +131,12 @@ tasks: desc: Builds Linux ARMv6 binaries dir: "{{.DIST_DIR}}" cmds: + # "git config safe.directory" is required until this is fixed https://github.com/elastic/golang-crossbuild/issues/232 - | docker run -v `pwd`/..:/home/build -w /home/build \ -e CGO_ENABLED=0 \ {{.CONTAINER}}:{{.CONTAINER_TAG}} \ - --build-cmd "{{.BUILD_COMMAND}}" \ + --build-cmd "git config --global --add safe.directory /home/build && {{.BUILD_COMMAND}}" \ -p "{{.BUILD_PLATFORM}}" tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}} @@ -172,7 +173,7 @@ tasks: # # Until there is a fix released we must use a recent gcc for Linux_ARMv6 build, so for this # build we select the debian10 based container. - CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian9" + CONTAINER_TAG: "{{.GO_VERSION}}-armel-debian12" PACKAGE_PLATFORM: "Linux_ARMv6" PACKAGE_NAME: "{{.PROJECT_NAME}}_{{.VERSION}}_{{.PACKAGE_PLATFORM}}.tar.gz" diff --git a/docsgen/go.mod b/docsgen/go.mod index c2e61e84..ac8e20f7 100644 --- a/docsgen/go.mod +++ b/docsgen/go.mod @@ -1,7 +1,7 @@ // Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/cobra/docsgen/go.mod module github.com/arduino/arduino-lint/docsgen -go 1.22.3 +go 1.22.9 replace github.com/arduino/arduino-lint => ../ diff --git a/go.mod b/go.mod index 6856689e..7df211d0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/arduino/arduino-lint -go 1.22.3 +go 1.22.9 replace github.com/jandelgado/gcov2lcov => github.com/jandelgado/gcov2lcov v1.0.5 // v1.0.4 causes Dependabot updates to fail due to checksum mismatch (likely a moved tag). This is an unused transitive dependency, so version is irrelevant. diff --git a/ruledocsgen/go.mod b/ruledocsgen/go.mod index e6101ffc..d6764020 100644 --- a/ruledocsgen/go.mod +++ b/ruledocsgen/go.mod @@ -1,6 +1,6 @@ module github.com/arduino/arduino-lint/ruledocsgen -go 1.22.3 +go 1.22.9 replace github.com/arduino/arduino-lint => ../