Skip to content

Commit 1a28b61

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

23 files changed

+1257
-755
lines changed

.github/workflows/environment.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Shared environment
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
GO_OLD:
7+
description: "oldest tested golang version"
8+
value: "1.23"
9+
GO_STABLE:
10+
description: "main supported golang version"
11+
value: "1.24"
12+
GO_CANARY:
13+
description: "canary golang version"
14+
value: canary
15+
RUNNER_WINDOWS_OLD:
16+
description: "windows old runner"
17+
value: windows-2019
18+
RUNNER_WINDOWS_STABLE:
19+
description: "windows stable runner"
20+
value: windows-2022
21+
RUNNER_WINDOWS_CANARY:
22+
description: "windows canary runner"
23+
value: windows-2025
24+
RUNNER_LINUX_OLD:
25+
description: "linux old runner"
26+
value: ubuntu-22.04
27+
RUNNER_LINUX_STABLE:
28+
description: "linux stable runner"
29+
value: ubuntu-24.04
30+
RUNNER_LINUX_AMD64_STABLE:
31+
description: "linux amd64 stable runner"
32+
value: ubuntu-24.04
33+
RUNNER_LINUX_ARM64_STABLE:
34+
description: "linux arm64 stable runner"
35+
value: ubuntu-24.04-arm
36+
RUNNER_LINUX_CANARY:
37+
description: "linux canary runner"
38+
value: ubuntu-24.04
39+
RUNNER_MACOS_OLD:
40+
description: "macos old runner"
41+
value: macos-13
42+
RUNNER_MACOS_STABLE:
43+
description: "macos stable runner"
44+
value: macos-14
45+
RUNNER_MACOS_CANARY:
46+
description: "macos canary runner"
47+
value: macos-15
48+
TIMEOUT_SHORT:
49+
description: "short timeout"
50+
value: "10"
51+
TIMEOUT_LONG:
52+
description: "long timeout"
53+
value: "40"
54+
GITHUB_TOKEN:
55+
description: "Github token"
56+
value: ""
57+
WINDOWS_CONTAINERD_VERSION:
58+
description: "containerd version for windows"
59+
value: "v2.0.4"
60+
WINDOWS_WINCNI_VERSION:
61+
description: "wincni version"
62+
value: "v0.3.1"
63+
WINDOWS_BUILDKIT_VERSION:
64+
description: "buildkit version"
65+
value: "v0.20.2"
66+
67+
jobs:
68+
blank:
69+
name: "environment"
70+
runs-on: ubuntu-24.04
71+
steps:
72+
- run: |
73+
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> "$GITHUB_ENV"
74+
echo "Environment setup complete"
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:
25+
name: ${{ 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

0 commit comments

Comments
 (0)