Skip to content

Commit a84b0d7

Browse files
authored
Merge pull request containerd#4159 from apostasie/ci-2025-04-ci-cleanup-b1
[CI]: cleanup, breakout 1: `./hack`
2 parents 1673252 + b21a1c4 commit a84b0d7

File tree

15 files changed

+258
-68
lines changed

15 files changed

+258
-68
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
run: |
4646
# If canary is specified, get the latest available golang pre-release instead of the major version
4747
if [ "${{ matrix.canary }}" != "" ]; then
48-
. ./hack/build-integration-canary.sh
49-
canary::golang::latest
48+
. ./hack/provisioning/version/fetch.sh
49+
printf "GO_VERSION=%s\n" "$(go::canary::for::go-setup)" >> "$GITHUB_ENV"
5050
fi
5151
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
5252
with:

.github/workflows/test-canary.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ jobs:
6868
ctd_v="$("${args[@]}" https://api.github.com/repos/containerd/containerd/tags | jq -rc .[0].name)"
6969
echo "CONTAINERD_VERSION=${ctd_v:1}" >> "$GITHUB_ENV"
7070
71-
. ./hack/build-integration-canary.sh
72-
canary::golang::latest
71+
. ./hack/provisioning/version/fetch.sh
72+
printf "GO_VERSION=%s\n" "$(go::canary::for::go-setup)" >> "$GITHUB_ENV"
7373
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
7474
with:
7575
go-version: ${{ env.GO_VERSION }}
@@ -82,7 +82,7 @@ jobs:
8282
- name: "Set up containerd"
8383
env:
8484
ctrdVersion: ${{ env.CONTAINERD_VERSION }}
85-
run: powershell hack/configure-windows-ci.ps1
85+
run: powershell hack/provisioning/windows/containerd.ps1
8686
- name: "Run integration tests"
8787
run: ./hack/test-integration.sh -test.only-flaky=false
8888
- name: "Run integration tests (flaky)"

.github/workflows/test-kube.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ jobs:
2323
- name: "Run Kubernetes integration tests"
2424
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
2525
run: |
26-
./hack/build-integration-kubernetes.sh
26+
./hack/provisioning/kube/kind.sh
2727
sudo ./_output/nerdctl exec nerdctl-test-control-plane bash -c -- 'export TMPDIR="$HOME"/tmp; mkdir -p "$TMPDIR"; cd /nerdctl-source; /usr/local/go/bin/go test -p 1 ./cmd/nerdctl/... -test.only-kubernetes'

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ jobs:
369369
- name: "Set up containerd"
370370
env:
371371
ctrdVersion: 1.7.27
372-
run: powershell hack/configure-windows-ci.ps1
372+
run: powershell hack/provisioning/windows/containerd.ps1
373373
- name: "Run integration tests"
374374
run: ./hack/test-integration.sh -test.only-flaky=false
375375
- name: "Run integration tests (flaky)"

.github/workflows/tigron.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ jobs:
3737
fetch-depth: 100
3838
- name: "Set GO env"
3939
run: |
40-
# If canary is specified, get the latest available golang pre-release instead of the major version
4140
if [ "${{ matrix.canary }}" != "" ]; then
42-
. ./hack/build-integration-canary.sh
43-
canary::golang::latest
41+
. ./hack/provisioning/version/fetch.sh
42+
printf "GO_VERSION=%s\n" "$(go::canary::for::go-setup)" >> "$GITHUB_ENV"
4443
fi
4544
- name: "Install go"
4645
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0

hack/build-integration-canary.sh

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -323,27 +323,3 @@ canary::golang::hublatest(){
323323

324324
printf "%s" "$available_version"
325325
}
326-
327-
canary::golang::latest(){
328-
# Enable extended globbing features to use advanced pattern matching
329-
shopt -s extglob
330-
331-
# Get latest golang version and split it in components
332-
norm=()
333-
while read -r line; do
334-
line_trimmed="${line//+([[:space:]])/}"
335-
norm+=("$line_trimmed")
336-
done < \
337-
<(sed -E 's/^go([0-9]+)[.]([0-9]+)([.]([0-9]+))?(([a-z]+)([0-9]+))?/\1.\2\n\4\n\6\n\7/i' \
338-
<(curl -fsSL "https://go.dev/dl/?mode=json&include=all" | jq -rc .[0].version) \
339-
)
340-
341-
# Serialize version, making sure we have a patch version, and separate possible rcX into .rc-X
342-
[ "${norm[1]}" != "" ] || norm[1]="0"
343-
norm[1]=".${norm[1]}"
344-
[ "${norm[2]}" == "" ] || norm[2]="-${norm[2]}"
345-
[ "${norm[3]}" == "" ] || norm[3]=".${norm[3]}"
346-
# Save it
347-
IFS=
348-
echo "GO_VERSION=${norm[*]}" >> "$GITHUB_ENV"
349-
}

hack/provisioning/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Dependencies provisioning for integration testing
2+
3+
This folder provides a set of scripts useful (for the CI) to configure hosts for
4+
the purpose of testing.
5+
6+
While this is agnostic and would (probably) work outside the context of GitHub Actions,
7+
this is not the right way for people to install a functioning stack.
8+
Use provided installation scripts instead (see user documentation).
9+
10+
## Contents
11+
12+
- `/version` allows retrieving latest (or experimental) versions of certain products (golang, containerd, etc)
13+
- `/linux` allows updating in-place containerd, cni (future: buildkit)
14+
- `/windows` allows install WinCNI, containerd
15+
- `/kube` allows spinning-up a Kind cluster

hack/build-integration-kubernetes.sh renamed to hack/provisioning/kube/kind.sh

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# shellcheck disable=SC2034,SC2015
1817
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
1918
root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)"
2019
readonly root
2120
# shellcheck source=/dev/null
22-
. "$root/scripts/lib.sh"
21+
. "$root/../../scripts/lib.sh"
2322

2423
GO_VERSION=1.24
2524
KIND_VERSION=v0.27.0
26-
CNI_PLUGINS_VERSION=v1.6.2
25+
CNI_PLUGINS_VERSION=v1.7.1
26+
# shellcheck disable=SC2034
27+
CNI_PLUGINS_SHA_AMD64=1a28a0506bfe5bcdc981caf1a49eeab7e72da8321f1119b7be85f22621013098
28+
# shellcheck disable=SC2034
29+
CNI_PLUGINS_SHA_ARM64=119fcb508d1ac2149e49a550752f9cd64d023a1d70e189b59c476e4d2bf7c497
2730

2831
[ "$(uname -m)" == "aarch64" ] && GOARCH=arm64 || GOARCH=amd64
2932

@@ -55,19 +58,6 @@ install::kubectl(){
5558
host::install "$temp"/kubectl
5659
}
5760

58-
install::cni(){
59-
local version="$1"
60-
local temp
61-
temp="$(fs::mktemp "install")"
62-
63-
http::get "$temp"/cni.tgz "https://github.com/containernetworking/plugins/releases/download/$version/cni-plugins-${GOOS:-linux}-${GOARCH:-amd64}-$version.tgz"
64-
sudo mkdir -p /opt/cni/bin
65-
sudo tar xzf "$temp"/cni.tgz -C /opt/cni/bin
66-
mkdir -p ~/opt/cni/bin
67-
tar xzf "$temp"/cni.tgz -C ~/opt/cni/bin
68-
rm "$temp"/cni.tgz
69-
}
70-
7161
exec::kind(){
7262
local args=()
7363
[ ! "$_rootful" ] || args=(sudo env PATH="$PATH" KIND_EXPERIMENTAL_PROVIDER="$KIND_EXPERIMENTAL_PROVIDER")
@@ -92,16 +82,20 @@ main(){
9282
configure::rootful "${ROOTFUL:-}"
9383

9484
log::info "Installing host dependencies if necessary"
85+
host::require make go
9586
host::require kind 2>/dev/null || install::kind "$KIND_VERSION"
9687
host::require kubectl 2>/dev/null || install::kubectl
9788

9889
# Build nerdctl to use for kind
99-
make binaries
90+
make -f "$root/../../../Makefile" binaries
10091
PATH=$(pwd)/_output:"$PATH"
10192
export PATH
10293

10394
# Add CNI plugins
104-
install::cni "$CNI_PLUGINS_VERSION"
95+
local sha
96+
sha="CNI_PLUGINS_SHA_$(tr "[:lower:]" "[:upper:]" <<<"$GOARCH")"
97+
# shellcheck source=/dev/null
98+
"$root"/../linux/cni.sh "$CNI_PLUGINS_VERSION" "$GOARCH" "${!sha}"
10599

106100
# Hack to get go into kind control plane
107101
exec::nerdctl rm -f go-kind 2>/dev/null || true
@@ -113,7 +107,7 @@ main(){
113107
log::info "Creating new cluster"
114108
export KIND_EXPERIMENTAL_PROVIDER=nerdctl
115109
exec::kind delete cluster --name nerdctl-test 2>/dev/null || true
116-
exec::kind create cluster --name nerdctl-test --config=./hack/kind.yaml
110+
exec::kind create cluster --name nerdctl-test --config="$root"/kind.yaml
117111
}
118112

119113
main "$@"
File renamed without changes.

hack/provisioning/linux/cni.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
18+
root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)"
19+
readonly root
20+
# shellcheck source=/dev/null
21+
. "$root/../../scripts/lib.sh"
22+
23+
provision::cni::uninstall(){
24+
[ "$(id -u)" == 0 ] || {
25+
log::error "You need to be root"
26+
return 1
27+
}
28+
29+
rm -Rf /opt/cni/bin
30+
}
31+
32+
# provision::containerd::cni will retrieve a specific version of cni plugins and extract it in place on the host
33+
provision::cni(){
34+
local version="$1"
35+
local arch="$2"
36+
local bin_sha="$3"
37+
38+
cd "$(fs::mktemp "cni-install")"
39+
40+
http::get::secure \
41+
cni.tgz \
42+
https://github.com/containernetworking/plugins/releases/download/"$version"/cni-plugins-linux-"$arch"-"$version".tgz \
43+
"$bin_sha"
44+
45+
sudo mkdir -p /opt/cni/bin
46+
sudo tar -C /opt/cni/bin -xzf cni.tgz
47+
48+
cd - >/dev/null
49+
}
50+
51+
provision::cni "$1" "$2" "$3"

0 commit comments

Comments
 (0)