Skip to content

Commit 63119fd

Browse files
authored
Merge pull request containerd#4188 from apostasie/ci-2025-05-summaries
[CI]: breakout 7: integration tests reports
2 parents 504a1e1 + 16e2310 commit 63119fd

File tree

8 files changed

+229
-18
lines changed

8 files changed

+229
-18
lines changed

.github/workflows/job-build.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ jobs:
4242
- if: ${{ inputs.canary }}
4343
name: "Init (canary): retrieve GO_VERSION"
4444
run: |
45+
. ./hack/github/action-helpers.sh
4546
latest_go="$(. ./hack/provisioning/version/fetch.sh; go::canary::for::go-setup)"
4647
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
4748
[ "$latest_go" != "" ] || \
48-
echo "::warning title=No canary go::There is currently no canary go version to test. Steps will not run."
49+
github::log::warning "No canary go" "There is currently no canary go version to test. Steps will not run."
4950
5051
- if: ${{ env.GO_VERSION != '' }}
5152
name: "Init: install go"
@@ -57,13 +58,41 @@ jobs:
5758
- if: ${{ env.GO_VERSION != '' }}
5859
name: "Run: make binaries"
5960
run: |
61+
. ./hack/github/action-helpers.sh
62+
63+
github::md::table::header "OS" "Arch" "Result" "Time" >> $GITHUB_STEP_SUMMARY
64+
65+
failure=
66+
67+
build(){
68+
local goos="$1"
69+
local goarch="${2:-amd64}"
70+
local goarm="${3:-}"
71+
local result
72+
73+
github::timer::begin
74+
75+
GOOS="$goos" GOARCH="$goarch" GOARM="$goarm" make binaries \
76+
&& result="$decorator_success" \
77+
|| {
78+
failure=true
79+
result="$decorator_failure"
80+
}
81+
82+
[ ! "$goarm" ] || goarch="$goarch/v$goarm"
83+
github::md::table::line "$goos" "$goarch" "$result" "$(github::timer::format <(github::timer::tick))" >> $GITHUB_STEP_SUMMARY
84+
}
85+
6086
# We officially support these
61-
GOOS=linux make binaries
62-
GOOS=windows make binaries
63-
GOOS=freebsd make binaries
64-
GOOS=darwin make binaries
65-
GOARCH=arm GOARM=6 make binaries
87+
build linux
88+
build linux arm64
89+
build windows
90+
build freebsd
91+
build darwin
92+
build linux arm 6
6693
# These architectures are not released, but we still verify that we can at least compile
67-
GOARCH=ppc64le make binaries
68-
GOARCH=riscv64 make binaries
69-
GOARCH=s390x make binaries
94+
build linux ppc64le
95+
build linux riscv64
96+
build linux s390x
97+
98+
[ ! "$failure" ] || exit 1

.github/workflows/job-test-in-container.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ jobs:
146146
if echo "${ROOTLESSKIT_VERSION}" | grep -q v1; then
147147
WORKAROUND_ISSUE_622=1
148148
fi
149-
echo "WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622}" >> "$GITHUB_ENV"
149+
echo "WORKAROUND_ISSUE_622=$WORKAROUND_ISSUE_622" >> "$GITHUB_ENV"
150150
- name: "Run: integration tests"
151151
run: |
152+
. ./hack/github/action-helpers.sh
153+
github::md::h2 "non-flaky" >> "$GITHUB_STEP_SUMMARY"
154+
152155
# IPV6 note: nested IPv6 network inside docker and qemu is complex and needs a bunch of sysctl config.
153156
# Therefore, it's hard to debug why the IPv6 tests fail in such an isolation layer.
154157
# On the other side, using the host network is easier at configuration.
@@ -158,18 +161,21 @@ jobs:
158161
&& args=(test-integration ./hack/test-integration.sh) \
159162
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/test-integration.sh)
160163
if [ "${{ inputs.ipv6 }}" == true ]; then
161-
docker run --network host -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} "${args[@]}" -test.only-flaky=false -test.only-ipv6 -test.target=${{ inputs.binary }}
164+
docker run --network host -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.only-ipv6 -test.target=${{ inputs.binary }}
162165
else
163-
docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} "${args[@]}" -test.only-flaky=false -test.target=${{ inputs.binary }}
166+
docker run -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=false -test.target=${{ inputs.binary }}
164167
fi
165168
# FIXME: this NEEDS to go away
166169
- name: "Run: integration tests (flaky)"
167170
run: |
171+
. ./hack/github/action-helpers.sh
172+
github::md::h2 "flaky" >> "$GITHUB_STEP_SUMMARY"
173+
168174
[ "${{ inputs.target }}" == "rootful" ] \
169175
&& args=(test-integration ./hack/test-integration.sh) \
170176
|| args=(test-integration-${{ inputs.target }} /test-integration-rootless.sh ./hack/test-integration.sh)
171177
if [ "${{ inputs.ipv6 }}" == true ]; then
172-
docker run --network host -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} "${args[@]}" -test.only-flaky=true -test.only-ipv6 -test.target=${{ inputs.binary }}
178+
docker run --network host -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.only-ipv6 -test.target=${{ inputs.binary }}
173179
else
174-
docker run -t --rm --privileged -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622} "${args[@]}" -test.only-flaky=true -test.target=${{ inputs.binary }}
180+
docker run -t --rm --privileged -e GITHUB_STEP_SUMMARY="$GITHUB_STEP_SUMMARY" -v "$GITHUB_STEP_SUMMARY":"$GITHUB_STEP_SUMMARY" -e WORKAROUND_ISSUE_622=${WORKAROUND_ISSUE_622:-} "${args[@]}" -test.only-flaky=true -test.target=${{ inputs.binary }}
175181
fi

.github/workflows/job-test-in-host.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ jobs:
156156
go install ./cmd/nerdctl
157157
echo "::endgroup::"
158158
159+
choco install jq
160+
159161
- if: ${{ env.SHOULD_RUN == 'yes' }}
160162
name: "Init: install dev tools"
161163
run: |
@@ -167,15 +169,24 @@ jobs:
167169
- if: ${{ contains(inputs.runner, 'ubuntu') && env.SHOULD_RUN == 'yes' }}
168170
name: "Run (linux): integration tests (IPv6)"
169171
run: |
172+
. ./hack/github/action-helpers.sh
173+
github::md::h2 "ipv6" >> "$GITHUB_STEP_SUMMARY"
174+
170175
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-ipv6
171176
172177
- if: ${{ env.SHOULD_RUN == 'yes' }}
173178
name: "Run: integration tests"
174179
run: |
180+
. ./hack/github/action-helpers.sh
181+
github::md::h2 "non-flaky" >> "$GITHUB_STEP_SUMMARY"
182+
175183
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=false
176184
177185
# FIXME: this must go
178186
- if: ${{ env.SHOULD_RUN == 'yes' }}
179187
name: "Run: integration tests (flaky)"
180188
run: |
189+
. ./hack/github/action-helpers.sh
190+
github::md::h2 "flaky" >> "$GITHUB_STEP_SUMMARY"
191+
181192
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=true

.github/workflows/workflow-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- go-version: "1.24"
7575
canary: true
7676
with:
77-
timeout: 5
77+
timeout: 10
7878
go-version: ${{ matrix.go-version }}
7979
runner: ubuntu-24.04
8080
canary: ${{ matrix.canary && true || false }}

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ CMD ["bash", "--login", "-i"]
295295
FROM base AS test-integration
296296
ARG DEBIAN_FRONTEND=noninteractive
297297
# `expect` package contains `unbuffer(1)`, which is used for emulating TTY for testing
298+
# `jq` is required to generate test summaries
298299
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
299300
expect \
301+
jq \
300302
git \
301303
make
302304
# We wouldn't need this if Docker Hub could have "golang:${GO_VERSION}-ubuntu"

hack/github/action-helpers.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
# shellcheck disable=SC2034
18+
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
19+
20+
readonly decorator_success=""
21+
readonly decorator_failure=""
22+
23+
github::md::h1(){
24+
printf "# %s\n" "$1"
25+
}
26+
27+
github::md::h2(){
28+
printf "## %s\n" "$1"
29+
}
30+
31+
github::md::h3(){
32+
printf "### %s\n" "$1"
33+
}
34+
35+
github::md::bq(){
36+
local x
37+
for x in "$@"; do
38+
printf "> %s\n" "$1"
39+
done
40+
}
41+
42+
github::md::table::header(){
43+
printf "|"
44+
for x in "$@"; do
45+
printf " %s |" "$x"
46+
done
47+
printf "\n"
48+
printf "|"
49+
for x in "$@"; do
50+
printf "%s|" "---"
51+
done
52+
printf "\n"
53+
}
54+
55+
github::md::table::line(){
56+
printf "|"
57+
for x in "$@"; do
58+
printf " %s |" "$x"
59+
done
60+
printf "\n"
61+
}
62+
63+
github::md::pie(){
64+
local title="$1"
65+
local label
66+
local value
67+
shift
68+
69+
printf '```mermaid\npie\n title %s\n' "$title"
70+
while [ "$#" -gt 0 ]; do
71+
label="$1"
72+
value="$2"
73+
shift
74+
shift
75+
printf ' "%s" : %s\n' "$label" "$value"
76+
done
77+
printf '```\n\n'
78+
79+
}
80+
81+
github::log::group(){
82+
echo "::group::$*"
83+
}
84+
85+
github::log::endgroup(){
86+
echo "::endgroup::"
87+
}
88+
89+
github::log::warning(){
90+
local title="$1"
91+
local msg="$2"
92+
93+
echo "::warning title=$title::$msg"
94+
}
95+
96+
_begin=${_begin:-}
97+
_duration=
98+
github::timer::begin(){
99+
_begin="$(date +%s)"
100+
}
101+
102+
github::timer::tick(){
103+
local tick
104+
105+
tick="$(date +%s)"
106+
printf "%s" "$((tick - _begin))"
107+
}
108+
109+
github::timer::format() {
110+
local t
111+
t="$(cat "$1")"
112+
local h=$((t/60/60%24))
113+
local m=$((t/60%60))
114+
local s=$((t%60))
115+
116+
[[ "$h" == 0 ]] || printf "%d hours " "$h"
117+
[[ "$m" == 0 ]] || printf "%d minutes " "$m"
118+
printf '%d seconds' "$s"
119+
}

hack/github/gotestsum-reporter.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
# shellcheck disable=SC2034,SC2015
18+
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
19+
root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)"
20+
readonly root
21+
22+
# shellcheck source=/dev/null
23+
. "$root"/action-helpers.sh
24+
25+
GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/null}"
26+
27+
{
28+
github::md::h3 "Total number of tests: $TESTS_TOTAL"
29+
github::md::pie "Status" "Skipped" "$TESTS_SKIPPED" "Failed" "$TESTS_FAILED" "Passed" "$(( TESTS_TOTAL - TESTS_FAILED - TESTS_SKIPPED ))"
30+
31+
# shellcheck disable=SC2207
32+
pie=($(jq -rc 'select(has("Test") | not) | select(.Elapsed) | select(.Elapsed > 0) | "\(.Package) \(.Elapsed) "' < "$GOTESTSUM_JSONFILE"))
33+
github::md::pie "Time spent per package" "${pie[@]}"
34+
35+
github::md::h3 "Failing tests"
36+
echo '```'
37+
jq -rc 'select(.Action == "fail") | select(.Test) | .Test' < "$GOTESTSUM_JSONFILE"
38+
echo '```'
39+
40+
github::md::h3 "Tests taking more than 15 seconds"
41+
echo '```'
42+
gotestsum tool slowest --threshold 15s --jsonfile "$GOTESTSUM_JSONFILE"
43+
echo '```'
44+
} >> "$GITHUB_STEP_SUMMARY"

hack/test-integration.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ readonly needsudo="${WITH_SUDO:-}"
3232

3333
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
3434
args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/../cmd/nerdctl/...)
35+
# FIXME: not working on windows. Need to change approach: move away from --post-run-command and
36+
# just process the log file. This might also allow multi-steps/multi-target results aggregation.
37+
[ "$(uname -s)" != "Linux" ] || args+=(--post-run-command "$root"/github/gotestsum-reporter.sh)
3538

3639
if [ "$#" == 0 ]; then
3740
"$root"/test-integration.sh -test.only-flaky=false
@@ -51,6 +54,3 @@ if [ "$needsudo" == "true" ] || [ "$needsudo" == "yes" ] || [ "$needsudo" == "1"
5154
else
5255
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -args -test.allow-kill-daemon "$@"
5356
fi
54-
55-
echo "These are the tests that took more than 10 seconds:"
56-
gotestsum tool slowest --threshold 10s --jsonfile /tmp/test-integration.log

0 commit comments

Comments
 (0)