Skip to content

Commit dcf43bc

Browse files
committed
Restructure GHA workflows
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent 5c06c7d commit dcf43bc

22 files changed

+1175
-761
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This job pre-heats the cache for the test image by building all dependencies
2+
name: build-dependencies
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
timeout:
8+
required: true
9+
type: number
10+
runner-for-linux-amd:
11+
required: true
12+
type: string
13+
runner-for-linux-arm:
14+
required: true
15+
type: string
16+
containerd-version-stable:
17+
required: true
18+
type: string
19+
containerd-version-old:
20+
required: true
21+
type: string
22+
23+
env:
24+
GOTOOLCHAIN: local
25+
26+
jobs:
27+
# This job builds the dependency target of the test docker image for all supported architectures and cache it in GHA
28+
build-dependencies:
29+
name: "${{ matrix.containerd }} | ${{ matrix.runner == inputs.runner-for-linux-arm && 'arm64' || 'amd64' }}"
30+
timeout-minutes: ${{ inputs.timeout }}
31+
runs-on: "${{ matrix.runner }}"
32+
defaults:
33+
run:
34+
shell: bash
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
# Build for arm & amd, current containerd
40+
runner: ["${{ inputs.runner-for-linux-amd }}", "${{ inputs.runner-for-linux-arm }}"]
41+
containerd: ${{ inputs.containerd-version-stable }}
42+
# Additionally build for old containerd on amd
43+
include:
44+
- runner: ${{ inputs.runner-for-linux-amd }}
45+
containerd: ${{ inputs.containerd-version-old }}
46+
47+
steps:
48+
- name: "Init: checkout"
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50+
with:
51+
fetch-depth: 1
52+
53+
- name: "Init: expose GitHub Runtime variables for gha"
54+
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
55+
56+
- name: "Run: build dependencies for the integration test environment image"
57+
run: |
58+
arch=${{ matrix.runner == inputs.runner-for-linux-arm && 'arm64' || 'amd64' }}
59+
docker buildx create --name with-gha --use
60+
docker buildx build \
61+
--cache-to type=gha,compression=zstd,mode=max,scope=test-integration-dependencies-"$arch" \
62+
--cache-from type=gha,scope=test-integration-dependencies-"$arch" \
63+
--target build-dependencies --build-arg CONTAINERD_VERSION=${{ matrix.containerd }} .

.github/workflows/job-build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This job just builds nerdctl for the golang versions we support (as a smoke test)
2+
name: build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
timeout:
8+
required: true
9+
type: number
10+
go-version-stable:
11+
required: true
12+
type: string
13+
go-version-old:
14+
required: true
15+
type: string
16+
runner:
17+
required: true
18+
type: string
19+
20+
env:
21+
GOTOOLCHAIN: local
22+
23+
jobs:
24+
build-all-targets:
25+
name: "whyhwhwy" # ${{ format('go {0}', matrix.canary && 'canary' || matrix.go ) }}
26+
timeout-minutes: ${{ inputs.timeout }}
27+
runs-on: "${{ matrix.runner }}"
28+
defaults:
29+
run:
30+
shell: bash
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
# Build for both old and stable go
36+
go: ["${{ inputs.go-version-old }}", "${{ inputs.go-version-stable }}"]
37+
canary: [false]
38+
# Additionally build for canary
39+
includes:
40+
- go: ${{ inputs.go-version-stable }}
41+
canary: true
42+
43+
env:
44+
GO_VERSION: ${{ matrix.go }}
45+
46+
steps:
47+
- name: "Init: checkout"
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
49+
with:
50+
fetch-depth: 1
51+
52+
- if: ${{ matrix.canary }}
53+
name: "Init (canary): retrieve GO_VERSION"
54+
run: |
55+
latest_go="$(. ./hack/github/go-canary.sh; go::canary::for::go-setup)"
56+
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
57+
[ "$latest_go" != "" ] || \
58+
echo "::warning title=No canary go::There is currently no canary go version to test. Steps will not run."
59+
60+
- if: ${{ env.GO_VERSION != '' }}
61+
name: "Init: install go"
62+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
63+
with:
64+
go-version: ${{ env.GO_VERSION }}
65+
check-latest: true
66+
67+
- if: ${{ env.GO_VERSION != '' }}
68+
name: "Run: make binaries"
69+
run: |
70+
# We officially support these
71+
GOOS=linux make binaries
72+
GOOS=windows make binaries
73+
GOOS=freebsd make binaries
74+
GOOS=darwin make binaries
75+
GOARCH=arm GOARM=7 make binaries
76+
77+
# These architectures are not released, but we still verify that we can at least compile
78+
GOARCH=arm GOARM=6 make binaries
79+
GOARCH=ppc64le make binaries
80+
GOARCH=riscv64 make binaries
81+
GOARCH=s390x make binaries

.github/workflows/job-lint-go.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# This job runs golangci-lint
2+
# Note that technically, `make lint-go-all` would run the linter for all targets, and could be called once, on a single instance.
3+
# The point of running it on a matrix instead, each GOOS separately, is to verify that the tooling itself is working on the target OS.
4+
name: lint-go
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
timeout:
10+
required: true
11+
type: number
12+
go-version:
13+
required: true
14+
type: string
15+
runner-for-linux:
16+
required: true
17+
type: string
18+
runner-for-freebsd:
19+
required: true
20+
type: string
21+
runner-for-macos:
22+
required: true
23+
type: string
24+
runner-for-windows:
25+
required: true
26+
type: string
27+
28+
env:
29+
GOTOOLCHAIN: local
30+
31+
jobs:
32+
lint-go:
33+
name: ${{ format('{0}{1}', matrix.goos, matrix.canary && ' | canary' || '') }}
34+
timeout-minutes: ${{ inputs.timeout }}
35+
runs-on: "${{ matrix.runner }}"
36+
defaults:
37+
run:
38+
shell: bash
39+
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
include:
44+
- runner: ${{ inputs.runner-for-linux }}
45+
goos: linux
46+
canary: false
47+
- runner: ${{ inputs.runner-for-linux }}
48+
goos: linux
49+
canary: true
50+
- runner: ${{ inputs.runner-for-freebsd }}
51+
goos: freebsd
52+
canary: false
53+
- runner: ${{ inputs.runner-for-macos }}
54+
goos: darwin
55+
canary: false
56+
- runner: ${{ inputs.runner-for-windows }}
57+
goos: windows
58+
canary: false
59+
60+
env:
61+
GO_VERSION: ${{ inputs.go-version }}
62+
63+
steps:
64+
- name: "Init: checkout"
65+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
66+
with:
67+
fetch-depth: 1
68+
69+
- if: ${{ matrix.canary }}
70+
name: "Init (canary): retrieve GO_VERSION"
71+
run: |
72+
latest_go="$(. ./hack/github/go-canary.sh; go::canary::for::go-setup)"
73+
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
74+
[ "$latest_go" != "" ] || \
75+
echo "::warning title=No canary go::There is currently no canary go version to test. Steps will not run."
76+
77+
- if: ${{ env.GO_VERSION != '' }}
78+
name: "Init: install go"
79+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
80+
with:
81+
go-version: ${{ env.GO_VERSION }}
82+
check-latest: true
83+
84+
- if: ${{ env.GO_VERSION != '' }}
85+
name: "Init: install dev-tools"
86+
run: |
87+
echo "::group:: make install-dev-tools"
88+
make install-dev-tools
89+
echo "::endgroup::"
90+
91+
- if: ${{ env.GO_VERSION != '' }}
92+
name: "Run"
93+
run: |
94+
NO_COLOR=true GOOS="${{ matrix.goos }}" make lint-go
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This job runs any subsidiary linter not part of golangci (shell, yaml, etc)
2+
name: lint-other
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
timeout:
8+
required: true
9+
type: number
10+
go-version:
11+
required: true
12+
type: string
13+
runner:
14+
required: true
15+
type: string
16+
17+
env:
18+
GOTOOLCHAIN: local
19+
20+
jobs:
21+
lint-other:
22+
name: "yaml | shell"
23+
timeout-minutes: ${{ inputs.timeout }}
24+
runs-on: ${{ inputs.runner }}
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
steps:
30+
- name: "Init: checkout"
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
32+
with:
33+
fetch-depth: 1
34+
35+
- name: "Init: install go"
36+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
37+
with:
38+
go-version: ${{ inputs.go-version }}
39+
check-latest: true
40+
41+
- name: "Init: install dev-tools"
42+
run: |
43+
make install-dev-tools
44+
45+
- name: "Run: yaml"
46+
run: |
47+
make lint-yaml
48+
49+
- name: "Run: shell"
50+
run: |
51+
make lint-shell
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This job runs containerd shared project-checks, that verifies licenses, headers, and commits.
2+
# To run locally, you may just use `make lint` instead, that does the same thing
3+
# (albeit `make lint` uses more modern versions).
4+
name: project-checks
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
timeout:
10+
required: true
11+
type: number
12+
go-version:
13+
required: true
14+
type: string
15+
runner:
16+
required: true
17+
type: string
18+
19+
env:
20+
GOTOOLCHAIN: local
21+
22+
jobs:
23+
project:
24+
name: "commits, licenses..."
25+
timeout-minutes: ${{ inputs.timeout }}
26+
runs-on: ${{ inputs.runner }}
27+
defaults:
28+
run:
29+
shell: bash
30+
31+
steps:
32+
- name: "Init: checkout"
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
with:
35+
fetch-depth: 100
36+
path: src/github.com/containerd/nerdctl
37+
38+
- name: "Init: install go"
39+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
40+
with:
41+
go-version: ${{ inputs.go-version }}
42+
check-latest: true
43+
cache-dependency-path: src/github.com/containerd/nerdctl
44+
45+
- name: "Run"
46+
uses: containerd/project-checks@d7751f3c375b8fe4a84c02a068184ee4c1f59bc4 # v1.2.2
47+
with:
48+
working-directory: src/github.com/containerd/nerdctl
49+
repo-access-token: ${{ secrets.GITHUB_TOKEN }}
50+
# go-licenses-ignore is set because go-licenses cannot detect the license of the following package:
51+
# * go-base36: Apache-2.0 OR MIT (https://github.com/multiformats/go-base36/blob/master/LICENSE.md)
52+
#
53+
# The list of the CNCF-approved licenses can be found here:
54+
# https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md
55+
go-licenses-ignore: |
56+
github.com/multiformats/go-base36

0 commit comments

Comments
 (0)