From 379ddb594440be0f28b1d4a84a495322b099cc85 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 26 Feb 2025 13:18:50 -0800 Subject: [PATCH] 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 appropriate 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-go-dependencies-task.yml | 8 ++------ .github/workflows/check-go-task.yml | 14 +++++--------- .github/workflows/publish-go-tester-task.yml | 6 +----- .github/workflows/release.yml | 6 +----- .github/workflows/test-go-integration-task.yml | 4 +--- .github/workflows/test-go-task.yml | 6 +----- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/.github/workflows/check-go-dependencies-task.yml b/.github/workflows/check-go-dependencies-task.yml index 054aa8d9..705e9d02 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.23" - # See: https://docs.github.com/actions/using-workflows/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 0c29a653..0dc8e838 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.23" - # See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows on: create: @@ -75,7 +71,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 @@ -110,7 +106,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 @@ -148,7 +144,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 @@ -186,7 +182,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 @@ -224,7 +220,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/publish-go-tester-task.yml b/.github/workflows/publish-go-tester-task.yml index ae2c9aec..6f0f191b 100644 --- a/.github/workflows/publish-go-tester-task.yml +++ b/.github/workflows/publish-go-tester-task.yml @@ -1,10 +1,6 @@ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md name: Publish Tester Build -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.23" - # See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows on: create: @@ -72,7 +68,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/release.yml b/.github/workflows/release.yml index 5ac6060b..79a2c7fb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,5 @@ name: Create Release -env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.23" - on: push: tags: @@ -44,7 +40,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod - name: Build project run: task build diff --git a/.github/workflows/test-go-integration-task.yml b/.github/workflows/test-go-integration-task.yml index 4519834e..4881895c 100644 --- a/.github/workflows/test-go-integration-task.yml +++ b/.github/workflows/test-go-integration-task.yml @@ -2,8 +2,6 @@ name: Test Integration env: - # See: https://github.com/actions/setup-go/tree/main#supported-version-syntax - GO_VERSION: "1.23" # See: https://github.com/actions/setup-python/tree/main#available-versions-of-python PYTHON_VERSION: "3.9" @@ -88,7 +86,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 725b9613..73bde281 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.23" - # See: https://docs.github.com/actions/using-workflows/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 Arduino Lint run: |