From 488b56361083967af1a4217f2c5063a7c194b8fb 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/ci.yml | 60 ++++++--------------------- 2 files changed, 28 insertions(+), 48 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 000000000..98b14a291 --- /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.21.6" + 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/ci.yml b/.github/workflows/ci.yml index 515b1428d..623aa170c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,11 +6,6 @@ on: pull_request: branches: ['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.21.6" - permissions: # added using https://github.com/step-security/secure-workflows contents: read @@ -31,12 +26,8 @@ jobs: os: [ubuntu-22.04, actuated-arm64-4cpu-16gb, macos-12, windows-2019] steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - uses: golangci/golangci-lint-action@v3 with: version: v1.55.2 @@ -53,16 +44,13 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - - 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 @@ -87,15 +75,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - - 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,11 +105,8 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: go install github.com/cpuguy83/go-md2man/v2@v2.0.2 - run: make man @@ -154,11 +136,8 @@ jobs: goarm: "7" steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: | set -e -x @@ -211,13 +190,8 @@ jobs: os: [ubuntu-22.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 }} - cache: false # see actions/setup-go#368 - - uses: actions/checkout@v4 - + - uses: ./.github/actions/install-go - name: Make run: | make build @@ -245,15 +219,12 @@ jobs: working-directory: src/github.com/containerd/containerd steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - - uses: actions/checkout@v4 with: path: src/github.com/containerd/containerd + - uses: ./.github/actions/install-go + - uses: actions/checkout@v4 with: repository: kubernetes-sigs/cri-tools @@ -409,12 +380,8 @@ jobs: env: GOTEST: gotestsum -- steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - name: Install containerd dependencies env: @@ -614,11 +581,8 @@ jobs: GOTEST: gotestsum -- steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - cache: false # see actions/setup-go#368 - uses: actions/checkout@v4 + - uses: ./.github/actions/install-go - run: script/setup/install-gotestsum - run: script/setup/install-teststat - name: Tests