Skip to content

Commit 49f3afd

Browse files
committed
Cleanup canary
Signed-off-by: apostasie <[email protected]>
1 parent 3e20861 commit 49f3afd

File tree

4 files changed

+92
-94
lines changed

4 files changed

+92
-94
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
GO_VERSION: 1.24
1212
GOTOOLCHAIN: local
1313
GO_INSTALL_DESTINATION: /opt
14+
GOOS: linux
1415

1516
jobs:
1617
go_current:
@@ -30,12 +31,12 @@ jobs:
3031
id: cache-go
3132
with:
3233
path: /opt/go
33-
key: golang-${{ env.GO_VERSION }}
34+
key: golang-${{ env.GOOS }}-${{ env.GO_VERSION }}
3435
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
3536
id: cache-go-dev
3637
with:
3738
path: ~/go/bin
38-
key: golang-dev-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
39+
key: golang-dev-${{ env.GOOS }}-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
3940
- if: ${{ steps.cache-go.outputs.cache-hit != 'true' }}
4041
name: Install go
4142
continue-on-error: false
@@ -74,12 +75,12 @@ jobs:
7475
id: cache-go
7576
with:
7677
path: /opt/go
77-
key: golang-${{ env.GO_VERSION }}
78+
key: golang-${{ env.GOOS }}-${{ env.GO_VERSION }}
7879
- uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
7980
id: cache-go-dev
8081
with:
8182
path: ~/go/bin
82-
key: golang-dev-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
83+
key: golang-dev-${{ env.GOOS }}-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
8384
- if: ${{ steps.cache-go.outputs.cache-hit != 'true' }}
8485
name: Install go
8586
run: make install-go

.github/workflows/test-canary.yml

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ on:
1111
- '**.md'
1212

1313
env:
14-
UBUNTU_VERSION: "24.04"
14+
GO_VERSION: canary
15+
GOTOOLCHAIN: local
16+
GOOS: linux
1517
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1618

1719
jobs:
1820
linux:
19-
runs-on: "ubuntu-24.04"
21+
runs-on: ubuntu-24.04
2022
timeout-minutes: 40
2123
steps:
2224
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2325
with:
2426
fetch-depth: 1
25-
- name: "Prepare integration test environment"
27+
- name: "Setup environment"
2628
run: |
29+
# Get latest canary go version
30+
export GO_VERSION=$(make install-go-resolve-version)
31+
# Build integration image with updated dependencies
2732
. ./hack/build-integration-canary.sh
28-
canary::build::integration
33+
LOG_LEVEL=info canary::build::integration
2934
- name: "Remove snap loopback devices (conflicts with our loopback devices in TestRunDevice)"
3035
run: |
3136
sudo systemctl disable --now snapd.service snapd.socket
@@ -41,24 +46,29 @@ jobs:
4146
docker run --privileged --rm tonistiigi/binfmt --install linux/amd64
4247
docker run --privileged --rm tonistiigi/binfmt --install linux/arm64
4348
docker run --privileged --rm tonistiigi/binfmt --install linux/arm/v7
49+
4450
- name: "Run unit tests"
45-
run: go test -v ./pkg/...
51+
run: docker run -t --rm --privileged test-integration go test -v ./pkg/...
4652
- name: "Run integration tests"
4753
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
4854
- name: "Run integration tests (flaky)"
4955
run: docker run -t --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
5056

5157
windows:
5258
timeout-minutes: 40
53-
runs-on: windows-latest
59+
runs-on: windows-2022
60+
env:
61+
GO_INSTALL_DESTINATION: /c/opt
62+
GOOS: windows
5463
defaults:
5564
run:
5665
shell: bash
5766
steps:
58-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
- name: "Clone"
68+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5969
with:
6070
fetch-depth: 1
61-
- name: Set GO env
71+
- name: "Setup environment"
6272
run: |
6373
# Get latest containerd
6474
args=(curl --proto '=https' --tlsv1.2 -fsSL -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28")
@@ -67,31 +77,58 @@ jobs:
6777
} || args+=(-H "Authorization: Bearer $GITHUB_TOKEN")
6878
ctd_v="$("${args[@]}" https://api.github.com/repos/containerd/containerd/tags | jq -rc .[0].name)"
6979
echo "CONTAINERD_VERSION=${ctd_v:1}" >> "$GITHUB_ENV"
70-
71-
. ./hack/build-integration-canary.sh
72-
canary::golang::latest
73-
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
80+
# Get latest go version
81+
echo "GO_VERSION=$(make install-go-resolve-version)" >> "$GITHUB_ENV"
82+
echo "PATH=$GO_INSTALL_DESTINATION/go/bin:$HOME/go/bin:$PATH" >> "$GITHUB_ENV"
83+
- name: "Cache go"
84+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
85+
id: cache-go
7486
with:
75-
go-version: ${{ env.GO_VERSION }}
76-
check-latest: true
77-
- run: go install ./cmd/nerdctl
78-
- run: make install-dev-tools
79-
# This here is solely to get the cni install script, which has not been modified in 3+ years.
80-
# There is little to no reason to update this to latest containerd
81-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
87+
path: /c/opt/go
88+
key: golang-${{ env.GOOS }}-${{ env.GO_VERSION }}
89+
- name: "Cache dev-tools"
90+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
91+
id: cache-go-dev
8292
with:
83-
repository: containerd/containerd
84-
ref: "v1.7.25"
85-
path: containerd
86-
fetch-depth: 1
87-
- name: "Set up CNI"
88-
working-directory: containerd
89-
run: GOPATH=$(go env GOPATH) script/setup/install-cni-windows
93+
path: ~/go/bin
94+
key: golang-dev-${{ env.GOOS }}-${{ env.GO_VERSION }}-${{ hashFiles('Makefile') }}
95+
- if: ${{ steps.cache-go.outputs.cache-hit != 'true' }}
96+
name: "Setup go"
97+
continue-on-error: false
98+
run: make install-go
99+
- if: ${{ steps.cache-go-dev.outputs.cache-hit != 'true' }}
100+
name: "Setup dev tools"
101+
continue-on-error: false
102+
run: |
103+
which go
104+
go version
105+
echo $PATH
106+
uname -s
107+
ls -lA /c/opt/go/bin
108+
echo version:
109+
/c/opt/go/bin/go version
110+
chmod a+x /c/opt/go/bin/go
111+
echo version above
112+
/c/opt/go/bin/go version
113+
echo version above 2
114+
make install-dev-tools
115+
- name: "Setup nerdctl"
116+
run: go install ./cmd/nerdctl
117+
- name: "Setup cni"
118+
run: |
119+
# CNI install script has not been modified in 3+ years.
120+
# There is little to no reason to update this to latest containerd
121+
curl -fsSLO https://raw.githubusercontent.com/containerd/containerd/refs/tags/v1.7.25/script/setup/install-cni-windows
122+
GOPATH=$(go env GOPATH) ./install-cni-windows
123+
go install ./cmd/nerdctl
90124
# Windows setup script can only use released versions
91-
- name: "Set up containerd"
125+
- name: "Setup containerd"
92126
env:
93127
ctrdVersion: ${{ env.CONTAINERD_VERSION }}
94128
run: powershell hack/configure-windows-ci.ps1
129+
130+
- name: "Run unit tests"
131+
run: go test -v ./pkg/...
95132
- name: "Run integration tests"
96133
run: ./hack/test-integration.sh -test.only-flaky=false
97134
- name: "Run integration tests (flaky)"

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ORG_PREFIXES := "github.com/containerd"
2626

2727
DOCKER ?= docker
2828
GO ?= go
29-
GOOS ?= $(shell $(GO) env GOOS)
29+
GOOS ?= $(shell $(GO) env GOOS 2>/dev/null || true)
3030
ifeq ($(GOOS),windows)
3131
BIN_EXT := .exe
3232
endif
@@ -55,13 +55,16 @@ ARCH := amd64
5555
ifeq ($(shell uname -m), aarch64)
5656
ARCH = arm64
5757
endif
58-
OS := linux
58+
OS := windows
5959
ifeq ($(shell uname -s), Darwin)
6060
OS = darwin
6161
endif
6262
ifeq ($(shell uname -s), FreeBSD)
6363
OS = freebsd
6464
endif
65+
#ifeq ($(shell uname -s), Linux)
66+
# OS = linux
67+
#endif
6568

6669
ifdef VERBOSE
6770
VERBOSE_FLAG := -v
@@ -263,11 +266,13 @@ GO_INSTALL_DESTINATION ?= /opt/$(BINARY)-dev-tools
263266
install-go:
264267
$(call title, $@)
265268
@mkdir -p $(GO_INSTALL_DESTINATION)
266-
@if [ ! -e $(GO_INSTALL_DESTINATION)/go ]; then curl -fsSL --proto '=https' --tlsv1.2 https://go.dev/dl/$(shell curl -fsSL --proto "=https" --tlsv1.3 "https://go.dev/dl/?mode=json&include=all" | \
267-
jq -rc 'map(select($(GO_VERSION_SELECTOR)))[0].files | map(select(.os=="$(OS)" and .arch=="$(ARCH)"))[0].filename') | \
268-
tar xzC $(GO_INSTALL_DESTINATION) || exit; \
269+
@if [ ! -e $(GO_INSTALL_DESTINATION)/go ]; then cd $(GO_INSTALL_DESTINATION); \
270+
curl -o go.archive -fsSL --proto '=https' --tlsv1.2 https://go.dev/dl/$(shell \
271+
curl -fsSL --proto "=https" --tlsv1.2 "https://go.dev/dl/?mode=json&include=all" | \
272+
jq -rc 'map(select($(GO_VERSION_SELECTOR)))[0].files | map(select(.os=="$(OS)" and .arch=="$(ARCH)"))[0].filename'); \
273+
[ "$(OS)" = windows ] && unzip go.archive || tar xzf go.archive; \
269274
else \
270-
echo "Install already detected, doing nothing."; \
275+
echo "Install already detected in $(GO_INSTALL_DESTINATION), doing nothing."; \
271276
fi
272277
@echo Remember to add to your profile: export PATH="$(GO_INSTALL_DESTINATION)/go/bin:\$$HOME/go/bin:\$$PATH"
273278
$(call footer, $@)

hack/build-integration-canary.sh

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ readonly root
2828
# "Blacklisting" here means that any dependency which name is blacklisted will be left untouched, at the version
2929
# currently pinned in the Dockerfile.
3030
# This is convenient so that currently broken alpha/beta/RC can be held back temporarily to keep the build green
31-
blacklist=()
31+
blacklist=(
32+
)
3233

3334
# List all the repositories we depend on to build and run integration tests
3435
dependencies=(
@@ -162,13 +163,18 @@ latest::release(){
162163
[ ! "$ignore" ] || ! grep -q "$ignore" <<<"$line" || continue
163164
name="$(echo "$line" | jq -rc .name)"
164165
if [ "$name" == "" ] || [ "$name" == null ] ; then
165-
log::debug " > bogus release name ($name) ignored"
166-
continue
166+
# Kubo latest releases are NOT setting a release name anymore :/
167+
# Hail mary on .tag_name...
168+
name="$(echo "$line" | jq -rc .tag_name)"
169+
if [ "$name" == "" ] || [ "$name" == null ] ; then
170+
log::debug " > bogus release name: $line"
171+
continue
172+
fi
167173
fi
168174
log::debug " > found release: $name"
169-
if version::compare <(echo "$line" | jq -rc .name); then
175+
if version::compare <(echo "$name"); then
170176
higher_data="$line"
171-
higher_readable="$(echo "$line" | jq -rc .name | sed -E 's/(.*[ ])?(v?[0-9][0-9.a-z-]+).*/\2/')"
177+
higher_readable="$(echo "$name" | sed -E 's/(.*[ ])?(v?[0-9][0-9.a-z-]+).*/\2/')"
172178
fi
173179
done < <(github::releases "$repo")
174180

@@ -211,7 +217,6 @@ assets::get(){
211217
######################
212218
# Script
213219
######################
214-
215220
canary::build::integration(){
216221
docker_args=(docker build -t test-integration --target test-integration)
217222

@@ -291,58 +296,8 @@ canary::build::integration(){
291296
docker_args+=(--build-arg "${shortsafename}_VERSION=$higher_readable")
292297
done
293298

294-
hub_available_go_version="$(canary::golang::hublatest)"
295-
if [ "$hub_available_go_version" != "" ]; then
296-
docker_args+=(--build-arg "GO_VERSION=$hub_available_go_version")
297-
fi
299+
docker_args+=(--build-arg "GO_VERSION=$GO_VERSION")
298300

299301
log::debug "${docker_args[*]} ."
300302
"${docker_args[@]}" "."
301303
}
302-
303-
# Hub usually has a delay before available golang version show-up. This method will find the latest available one.
304-
# See
305-
# - https://github.com/containerd/nerdctl/issues/3224
306-
# - https://github.com/containerd/nerdctl/issues/3306
307-
canary::golang::hublatest(){
308-
local hub_tags
309-
local go_version
310-
local available_version=""
311-
local index
312-
313-
hub_tags="$(http::get /dev/stdout "https://registry-1.docker.io/v2/library/golang/tags/list" -H "Authorization: Bearer $(http::get /dev/stdout "https://auth.docker.io/token?service=registry.docker.io&scope=repository%3Alibrary%2Fgolang%3Apull" | jq -rc .access_token)")"
314-
315-
index=0
316-
while [ "$available_version" == "" ] && [ "$index" -lt 5 ]; do
317-
go_version="$(http::get /dev/stdout "https://go.dev/dl/?mode=json&include=all" | jq -rc .[$index].version)"
318-
go_version="${go_version##*go}"
319-
available_version="$(printf "%s" "$hub_tags" | jq -rc ".tags[] | select(.==\"$go_version\")")"
320-
((index++))
321-
done || true
322-
323-
printf "%s" "$available_version"
324-
}
325-
326-
canary::golang::latest(){
327-
# Enable extended globbing features to use advanced pattern matching
328-
shopt -s extglob
329-
330-
# Get latest golang version and split it in components
331-
norm=()
332-
while read -r line; do
333-
line_trimmed="${line//+([[:space:]])/}"
334-
norm+=("$line_trimmed")
335-
done < \
336-
<(sed -E 's/^go([0-9]+)[.]([0-9]+)([.]([0-9]+))?(([a-z]+)([0-9]+))?/\1.\2\n\4\n\6\n\7/i' \
337-
<(curl -fsSL "https://go.dev/dl/?mode=json&include=all" | jq -rc .[0].version) \
338-
)
339-
340-
# Serialize version, making sure we have a patch version, and separate possible rcX into .rc-X
341-
[ "${norm[1]}" != "" ] || norm[1]="0"
342-
norm[1]=".${norm[1]}"
343-
[ "${norm[2]}" == "" ] || norm[2]="-${norm[2]}"
344-
[ "${norm[3]}" == "" ] || norm[3]=".${norm[3]}"
345-
# Save it
346-
IFS=
347-
echo "GO_VERSION=${norm[*]}" >> "$GITHUB_ENV"
348-
}

0 commit comments

Comments
 (0)