From 9f2667727077d655c905d87ac85a1a20cdf29567 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Wed, 1 May 2024 10:33:10 -0700 Subject: [PATCH] fixup: Add repo-local action for golang setup --- .../setup-go-for-project-v3/action.yml | 25 ++++++++++++++++++ .../actions/setup-go-for-project/action.yml | 26 +++++++++++++++++++ .github/workflows/ci.yml | 12 ++------- 3 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 .github/actions/setup-go-for-project-v3/action.yml create mode 100644 .github/actions/setup-go-for-project/action.yml diff --git a/.github/actions/setup-go-for-project-v3/action.yml b/.github/actions/setup-go-for-project-v3/action.yml new file mode 100644 index 000000000000..eb3c20442a65 --- /dev/null +++ b/.github/actions/setup-go-for-project-v3/action.yml @@ -0,0 +1,25 @@ +# This action targets setup-go@v3 to support workers with old NodeJS +# incompabible with newer versions of setup-go. +# +# Since github actions do not support dynamically configuring the +# versions in a uses statement (e.g. `actions/setup-go@${{ var }}`) it +# is necessary to define an action per version rather than one action +# that can be parameterized. +# +# Must be run after actions/checkout to ensure go.mod is available to +# source the desired go version from. + +name: 'Install Go toolchain with project defaults' +description: 'Install a go toolchain with project defaults' + +runs: + using: composite + steps: + - name: Set the project Go version in the environment + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + shell: bash + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '${{ env.GO_VERSION }}' + check-latest: true diff --git a/.github/actions/setup-go-for-project/action.yml b/.github/actions/setup-go-for-project/action.yml new file mode 100644 index 000000000000..b6acb085a72c --- /dev/null +++ b/.github/actions/setup-go-for-project/action.yml @@ -0,0 +1,26 @@ +# This action targets the project default version of setup-go. For +# workers with old NodeJS incompabible with newer versions of +# setup-go, try setup-go-for-project-v3. +# +# Since github actions do not support dynamically configuring the +# versions in a uses statement (e.g. `actions/setup-go@${{ var }}`) it +# is necessary to define an action per version rather than one action +# that can be parameterized. +# +# Must be run after actions/checkout to ensure go.mod is available to +# source the desired go version from. + +name: 'Install Go toolchain with project defaults' +description: 'Install a go toolchain with project defaults' + +runs: + using: composite + steps: + - name: Set the project Go version in the environment + run: .github/workflows/go_version_env.sh >> $GITHUB_ENV + shell: bash + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '${{ env.GO_VERSION }}' + check-latest: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 426b60f9c546..b3ec0656300a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,11 +31,7 @@ jobs: os: [macos-12, ubuntu-20.04, ubuntu-22.04, windows-2022, [self-hosted, linux, ARM64, focal], [self-hosted, linux, ARM64, jammy]] steps: - uses: actions/checkout@v4 - - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - - uses: actions/setup-go@v3 - with: - go-version: '${{ env.GO_VERSION }}' - check-latest: true + - uses: ./.github/actions/setup-go-for-project-v3 - name: Set timeout on Windows # Windows UT run slower and need a longer timeout shell: bash if: matrix.os == 'windows-2022' @@ -61,11 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: .github/workflows/go_version_env.sh >> $GITHUB_ENV - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: true + - uses: ./.github/actions/setup-go-for-project - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r