Skip to content

Commit a5c0d06

Browse files
mxpvakhilerm
authored andcommitted
Extract a composite action to install Go
Signed-off-by: Maksym Pavlenko <[email protected]> (cherry picked from commit 488b563) Signed-off-by: Akhil Mohan <[email protected]>
1 parent 33b3e13 commit a5c0d06

2 files changed

Lines changed: 28 additions & 39 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Setup Go"
2+
description: "Reusable action to install Go, so there is one place to bump Go versions"
3+
inputs:
4+
go-version:
5+
required: true
6+
default: "1.21.6"
7+
description: "Go version to install"
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: "Setup Go"
13+
uses: actions/setup-go@v5
14+
with:
15+
go-version: ${{ inputs.go-version }}
16+
cache: false # see actions/setup-go#368

.github/workflows/ci.yml

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ on:
99
- main
1010
- "release/**"
1111

12-
env:
13-
# Go version we currently use to build containerd across all CI.
14-
# Note: don't forget to update `Binaries` step, as it contains the matrix of all supported Go versions.
15-
GO_VERSION: "1.20.13"
16-
1712
permissions: # added using https://github.com/step-security/secure-workflows
1813
contents: read
1914

@@ -34,11 +29,8 @@ jobs:
3429
os: [ubuntu-20.04, actuated-arm64-4cpu-16gb, macos-12, windows-2019]
3530

3631
steps:
37-
- uses: actions/setup-go@v5
38-
with:
39-
go-version: ${{ env.GO_VERSION }}
40-
4132
- uses: actions/checkout@v4
33+
- uses: ./.github/actions/install-go
4234
- uses: golangci/golangci-lint-action@v4
4335
with:
4436
version: v1.56.1
@@ -55,15 +47,13 @@ jobs:
5547
timeout-minutes: 5
5648

5749
steps:
58-
- uses: actions/setup-go@v5
59-
with:
60-
go-version: ${{ env.GO_VERSION }}
61-
6250
- uses: actions/checkout@v4
6351
with:
6452
path: src/github.com/containerd/containerd
6553
fetch-depth: 100
6654

55+
- uses: ./src/github.com/containerd/containerd/.github/actions/install-go
56+
6757
- uses: containerd/[email protected]
6858
with:
6959
working-directory: src/github.com/containerd/containerd
@@ -88,14 +78,12 @@ jobs:
8878
working-directory: src/github.com/containerd/containerd
8979

9080
steps:
91-
- uses: actions/setup-go@v5
92-
with:
93-
go-version: ${{ env.GO_VERSION }}
94-
9581
- uses: actions/checkout@v4
9682
with:
9783
path: src/github.com/containerd/containerd
9884

85+
- uses: ./src/github.com/containerd/containerd/.github/actions/install-go
86+
9987
- name: Set env
10088
shell: bash
10189
run: |
@@ -120,10 +108,8 @@ jobs:
120108
timeout-minutes: 5
121109

122110
steps:
123-
- uses: actions/setup-go@v5
124-
with:
125-
go-version: ${{ env.GO_VERSION }}
126111
- uses: actions/checkout@v4
112+
- uses: ./.github/actions/install-go
127113
- run: go install github.com/cpuguy83/go-md2man/[email protected]
128114
- run: make man
129115

@@ -153,10 +139,8 @@ jobs:
153139
goarm: "7"
154140

155141
steps:
156-
- uses: actions/setup-go@v5
157-
with:
158-
go-version: ${{ env.GO_VERSION }}
159142
- uses: actions/checkout@v4
143+
- uses: ./.github/actions/install-go
160144
- run: |
161145
set -e -x
162146
@@ -209,12 +193,8 @@ jobs:
209193
os: [ubuntu-20.04, actuated-arm64-4cpu-16gb, macos-12, windows-2019, windows-2022]
210194
go-version: ["1.20.13", "1.21.6"]
211195
steps:
212-
- uses: actions/setup-go@v5
213-
with:
214-
go-version: ${{ matrix.go-version }}
215-
216196
- uses: actions/checkout@v4
217-
197+
- uses: ./.github/actions/install-go
218198
- name: Make
219199
run: |
220200
make build
@@ -243,14 +223,12 @@ jobs:
243223
working-directory: src/github.com/containerd/containerd
244224

245225
steps:
246-
- uses: actions/setup-go@v5
247-
with:
248-
go-version: ${{ env.GO_VERSION }}
249-
250226
- uses: actions/checkout@v4
251227
with:
252228
path: src/github.com/containerd/containerd
253229

230+
- uses: ./.github/actions/install-go
231+
254232
- uses: actions/checkout@v4
255233
with:
256234
repository: kubernetes-sigs/cri-tools
@@ -413,11 +391,8 @@ jobs:
413391
env:
414392
GOTEST: gotestsum --
415393
steps:
416-
- uses: actions/setup-go@v5
417-
with:
418-
go-version: ${{ env.GO_VERSION }}
419-
420394
- uses: actions/checkout@v4
395+
- uses: ./.github/actions/install-go
421396

422397
- name: Install containerd dependencies
423398
env:
@@ -548,10 +523,8 @@ jobs:
548523
GOTEST: gotestsum --
549524

550525
steps:
551-
- uses: actions/setup-go@v5
552-
with:
553-
go-version: ${{ env.GO_VERSION }}
554526
- uses: actions/checkout@v4
527+
- uses: ./.github/actions/install-go
555528
- run: script/setup/install-gotestsum
556529
- run: script/setup/install-teststat
557530
- name: Tests

0 commit comments

Comments
 (0)