Skip to content

Commit 426fc6f

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

29 files changed

+1320
-800
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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-old:
17+
required: true
18+
type: string
19+
20+
env:
21+
GOTOOLCHAIN: local
22+
23+
jobs:
24+
# This job builds the dependency target of the test docker image for all supported architectures and cache it in GHA
25+
build-dependencies:
26+
name: "${{ matrix.runner == inputs.runner-for-linux-arm && 'arm64' || 'amd64' }}${{ matrix.old-containerd && format(' | {0}', inputs.containerd-version-old) || ''}}"
27+
timeout-minutes: ${{ inputs.timeout }}
28+
runs-on: "${{ matrix.runner }}"
29+
defaults:
30+
run:
31+
shell: bash
32+
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include:
37+
# Build for arm & amd, current containerd
38+
- runner: ${{ inputs.runner-for-linux-amd }}
39+
- runner: ${{ inputs.runner-for-linux-arm }}
40+
# Additionally build for old containerd on amd
41+
- runner: ${{ inputs.runner-for-linux-amd }}
42+
old-containerd: true
43+
steps:
44+
- name: "Init: checkout"
45+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+
with:
47+
fetch-depth: 1
48+
49+
- name: "Init: expose GitHub Runtime variables for gha"
50+
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
51+
52+
- name: "Run: build dependencies for the integration test environment image"
53+
run: |
54+
# Cache is sharded per-architecture
55+
arch=${{ matrix.runner == inputs.runner-for-linux-arm && 'arm64' || 'amd64' }}
56+
docker buildx create --name with-gha --use
57+
# Honor old containerd if requested
58+
args=()
59+
if [ "${{ matrix.old-containerd }}" == true ]; then
60+
args=(--build-arg CONTAINERD_VERSION=${{ inputs.containerd-version-old }})
61+
fi
62+
docker buildx build \
63+
--cache-to type=gha,compression=zstd,mode=max,scope=test-integration-dependencies-"$arch" \
64+
--cache-from type=gha,scope=test-integration-dependencies-"$arch" \
65+
--target build-dependencies "${args[@]}" .

.github/workflows/job-build.yml

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

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

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 && ' (go 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-freebsd }}
48+
goos: freebsd
49+
canary: false
50+
- runner: ${{ inputs.runner-for-macos }}
51+
goos: darwin
52+
canary: false
53+
- runner: ${{ inputs.runner-for-windows }}
54+
goos: windows
55+
canary: false
56+
# Additionally lint linux for canary
57+
- runner: ${{ inputs.runner-for-linux }}
58+
goos: linux
59+
canary: true
60+
61+
env:
62+
GO_VERSION: ${{ inputs.go-version }}
63+
64+
steps:
65+
- name: "Init: checkout"
66+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
with:
68+
fetch-depth: 1
69+
70+
- if: ${{ matrix.canary }}
71+
name: "Init (canary): retrieve GO_VERSION"
72+
run: |
73+
latest_go="$(. ./hack/provisioning/version/fetcher.sh; go::canary::for::go-setup)"
74+
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
75+
[ "$latest_go" != "" ] || \
76+
echo "::warning title=No canary go::There is currently no canary go version to test. Steps will not run."
77+
78+
- if: ${{ env.GO_VERSION != '' }}
79+
name: "Init: install go"
80+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
81+
with:
82+
go-version: ${{ env.GO_VERSION }}
83+
check-latest: true
84+
85+
- if: ${{ env.GO_VERSION != '' }}
86+
name: "Init: install dev-tools"
87+
run: |
88+
echo "::group:: make install-dev-tools"
89+
make install-dev-tools
90+
echo "::endgroup::"
91+
92+
- if: ${{ env.GO_VERSION != '' }}
93+
name: "Run"
94+
run: |
95+
# On canary, lint for all supported targets
96+
if [ "${{ matrix.canary }}" != "" ]; then
97+
NO_COLOR=true GOOS="${{ matrix.goos }}" make lint-go-all
98+
else
99+
NO_COLOR=true GOOS="${{ matrix.goos }}" make lint-go
100+
fi
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
echo "::group:: make install-dev-tools"
44+
make install-dev-tools
45+
echo "::endgroup::"
46+
47+
- name: "Run: yaml"
48+
run: |
49+
make lint-yaml
50+
51+
- name: "Run: shell"
52+
run: |
53+
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)