From d209316093149705da73507d540be056549d41f6 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 7 Feb 2024 12:28:17 -0800 Subject: [PATCH] Extract a composite action to install Go Signed-off-by: Maksym Pavlenko --- .github/actions/install-go/action.yml | 16 ++++++++ .github/workflows/build-test-images.yml | 6 +-- .github/workflows/ci.yml | 51 ++++++------------------- .github/workflows/codeql.yml | 4 +- .github/workflows/fuzz.yml | 4 +- .github/workflows/images.yml | 6 +-- .github/workflows/nightly.yml | 15 ++------ .github/workflows/release.yml | 3 -- 8 files changed, 39 insertions(+), 66 deletions(-) create mode 100644 .github/actions/install-go/action.yml diff --git a/.github/actions/install-go/action.yml b/.github/actions/install-go/action.yml new file mode 100644 index 000000000000..1b664838465f --- /dev/null +++ b/.github/actions/install-go/action.yml @@ -0,0 +1,16 @@ +name: "Setup Go" +description: "Reusable action to install Go, so there is one place to bump Go versions" +inputs: + go-version: + required: true + default: "1.20.13" + description: "Go version to install" + +runs: + using: composite + steps: + - name: "Setup Go" + uses: actions/setup-go@v5 + with: + go-version: ${{ inputs.go-version }} + cache: false # see actions/setup-go#368 diff --git a/.github/workflows/build-test-images.yml b/.github/workflows/build-test-images.yml index d20ab3f56b48..93528b418be0 100644 --- a/.github/workflows/build-test-images.yml +++ b/.github/workflows/build-test-images.yml @@ -41,14 +41,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: "1.20.13" - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - name: Set env shell: bash run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac3f4826840b..eda20ba019fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,11 +9,6 @@ on: - main - "release/**" -env: - # Go version we currently use to build containerd across all CI. - # Note: don't forget to update `Binaries` step, as it contains the matrix of all supported Go versions. - GO_VERSION: "1.20.13" - permissions: # added using https://github.com/step-security/secure-workflows contents: read @@ -34,11 +29,8 @@ jobs: os: [ubuntu-20.04, actuated-arm64-4cpu-16gb, macos-12, windows-2019] steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - uses: golangci/golangci-lint-action@v4 with: version: v1.51.1 @@ -55,15 +47,13 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd fetch-depth: 100 + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - uses: containerd/project-checks@v1.1.0 with: working-directory: src/github.com/containerd/containerd @@ -88,14 +78,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - name: Set env shell: bash run: | @@ -120,10 +108,8 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: go install github.com/cpuguy83/go-md2man/v2@v2.0.2 - run: make man @@ -153,10 +139,8 @@ jobs: goarm: "7" steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: | set -e -x @@ -209,12 +193,8 @@ jobs: os: [ubuntu-20.04, actuated-arm64-4cpu-16gb, macos-12, windows-2019, windows-2022] go-version: ["1.20.13", "1.21.6"] steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v4 - + - uses: ./.github/actions/install-go - name: Make run: | make build @@ -243,14 +223,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - uses: actions/checkout@v4 with: repository: kubernetes-sigs/cri-tools @@ -413,11 +391,8 @@ jobs: env: GOTEST: gotestsum -- steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - name: Install containerd dependencies env: @@ -548,10 +523,8 @@ jobs: GOTEST: gotestsum -- steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: script/setup/install-gotestsum - run: script/setup/install-teststat - name: Tests diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index efaba5dd9685..9777e87c5e75 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -32,9 +32,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: 1.20.13 + - uses: ./.github/actions/install-go # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 45718a25ac57..60ee230787dd 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -40,10 +40,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/setup-go@v5 + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go with: # FIXME: go-fuzz fails with Go 1.20: `cgo_unix_cgo_res.cgo2.c:(.text+0x32): undefined reference to `__res_search'` # https://github.com/containerd/containerd/pull/8103#issuecomment-1429256152 go-version: 1.18 - - uses: actions/checkout@v4 - run: script/go-test-fuzz.sh diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 280aef62ba68..b39174a7ac82 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -26,14 +26,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: "1.20.13" - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - name: Set env shell: bash run: | diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0076ea07e665..288b5df21f11 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,9 +6,6 @@ on: paths: - ".github/workflows/nightly.yml" -env: - GO_VERSION: "1.20.13" - permissions: # added using https://github.com/step-security/secure-workflows contents: read @@ -23,14 +20,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - name: Set env shell: bash run: | @@ -143,14 +138,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./src/github.com/containerd/containerd/.github/actions/install-go + - name: Set env shell: bash run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4db9827d8044..e6c1f4b3fd79 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,6 @@ on: name: Release -env: - GO_VERSION: "1.20.13" - permissions: # added using https://github.com/step-security/secure-workflows contents: read