From bbc28d7f1f01d54f374493a953feec602f095ea9 Mon Sep 17 00:00:00 2001 From: apostasie Date: Fri, 13 Dec 2024 09:28:05 -0800 Subject: [PATCH] Adding a custom go-setup command Signed-off-by: apostasie --- .github/actions/install-go/action.yml | 73 +++++++++++++++++++++++++++ .github/workflows/ci_debugging.yml | 35 +++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 .github/actions/install-go/action.yml create mode 100644 .github/workflows/ci_debugging.yml diff --git a/.github/actions/install-go/action.yml b/.github/actions/install-go/action.yml new file mode 100644 index 00000000000..956ced36bae --- /dev/null +++ b/.github/actions/install-go/action.yml @@ -0,0 +1,73 @@ +name: "Setup Go" +description: "Nerdctl go installation, with canary support. Will by default install go for the supported patch-version." +inputs: + stable: + required: false + default: "false" + description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod" + old-stable: + required: false + default: "false" + description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod" + canary: + required: false + default: "false" + description: "Set this to true if you want the bleeding edge golang version (RC, etc)" + _current: + required: false + default: "1.23.1" # 1.23.4 + description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod" + _stable: + required: false + default: "1.23.x" + description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod" + _old_stable: + required: false + default: "1.22.x" + description: "Set this to true if you want the latest patch version of the main supported version specified in go.mod" + +runs: + using: composite + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 1 + - name: Set GO env + shell: bash + run: | + golang::canary(){ + # Enable extended globbing features to use advanced pattern matching + shopt -s extglob + # Get latest golang version and split it in components + norm=() + while read -r line; do + line_trimmed="${line//+([[:space:]])/}" + norm+=("$line_trimmed") + done < \ + <(sed -E 's/^go([0-9]+)[.]([0-9]+)([.]([0-9]+))?(([a-z]+)([0-9]+))?/\1.\2\n\4\n\6\n\7/i' \ + <(curl -fsSL "https://go.dev/dl/?mode=json&include=all" | jq -rc .[0].version) \ + ) + # Serialize version, making sure we have a patch version, and separate possible rcX into .rc-X + [ "${norm[1]}" != "" ] || norm[1]="0" + norm[1]=".${norm[1]}" + [ "${norm[2]}" == "" ] || norm[2]="-${norm[2]}" + [ "${norm[3]}" == "" ] || norm[3]=".${norm[3]}" + # Save it + IFS= + echo "GO_VERSION=${norm[*]}" >> "$GITHUB_ENV" + } + + if [ "${{ inputs.canary }}" == "true" ]; then + golang::canary + elif [ "${{ inputs.stable }}" == "true" ]; then + echo "GO_VERSION=$INPUT__STABLE" >> "$GITHUB_ENV" + elif [ "${{ inputs.old-stable }}" == "true" ]; then + echo "GO_VERSION=$INPUT__OLD_STABLE" >> "$GITHUB_ENV" + else + echo "GO_VERSION=$INPUT__CURRENT" >> "$GITHUB_ENV" + fi + - name: "Setup Go" + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: ${{ env.GO_VERSION }} + cache: true diff --git a/.github/workflows/ci_debugging.yml b/.github/workflows/ci_debugging.yml new file mode 100644 index 00000000000..523de6feda2 --- /dev/null +++ b/.github/workflows/ci_debugging.yml @@ -0,0 +1,35 @@ +name: ci_debugging + +on: + push: + branches: + - main + - 'release/**' + pull_request: + paths-ignore: + - '**.md' + +jobs: + # This job builds the dependency target of the test docker image for all supported architectures and cache it in GHA + go_stable: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: ./.github/actions/install-go + - run: | + go version + - uses: ./.github/actions/install-go + with: + stable: true + - run: | + go version + - uses: ./.github/actions/install-go + with: + old-stable: true + - run: | + go version + - uses: ./.github/actions/install-go + with: + canary: true + - run: | + go version