Skip to content

Commit ae25096

Browse files
committed
Adding summaries for CI workflows
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent a7ad81e commit ae25096

5 files changed

Lines changed: 191 additions & 17 deletions

File tree

.github/workflows/job-build.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ on:
1717
required: false
1818
default: false
1919
type: boolean
20-
2120
env:
2221
GOTOOLCHAIN: local
2322

@@ -42,10 +41,11 @@ jobs:
4241
- if: ${{ inputs.canary }}
4342
name: "Init (canary): retrieve GO_VERSION"
4443
run: |
44+
. ./hack/github/action-helpers.sh
4545
latest_go="$(. ./hack/provisioning/version/fetch.sh; go::canary::for::go-setup)"
4646
printf "GO_VERSION=%s\n" "$latest_go" >> "$GITHUB_ENV"
4747
[ "$latest_go" != "" ] || \
48-
echo "::warning title=No canary go::There is currently no canary go version to test. Steps will not run."
48+
github::log::warning "No canary go" "There is currently no canary go version to test. Steps will not run."
4949
5050
- if: ${{ env.GO_VERSION != '' }}
5151
name: "Init: install go"
@@ -56,14 +56,43 @@ jobs:
5656

5757
- if: ${{ env.GO_VERSION != '' }}
5858
name: "Run: make binaries"
59+
id: run
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-integration-host.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
shell: bash
6060

6161
env:
62-
SHOULD_RUN: yes
62+
SHOULD_RUN: "yes"
6363
GO_VERSION: ${{ inputs.go-version }}
6464
# Both Docker and nerdctl on linux need rootful right now
6565
WITH_SUDO: ${{ contains(inputs.runner, 'ubuntu') }}
@@ -169,11 +169,13 @@ jobs:
169169
run: |
170170
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-ipv6
171171
172-
- name: "Run: integration tests"
172+
- if: ${{ env.SHOULD_RUN == 'yes' }}
173+
name: "Run: integration tests"
173174
run: |
174175
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=false
175176
176177
# FIXME: this must go
177-
- name: "Run: integration tests (flaky)"
178+
- if: ${{ env.SHOULD_RUN == 'yes' }}
179+
name: "Run: integration tests (flaky)"
178180
run: |
179181
./hack/test-integration.sh -test.target=${{ inputs.binary }} -test.only-flaky=true

hack/github/action-helpers.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
#root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)"
20+
#readonly root
21+
# shellcheck source=/dev/null
22+
#. "$root/../../scripts/lib.sh"
23+
24+
readonly decorator_success=""
25+
readonly decorator_failure=""
26+
27+
github::md::h1(){
28+
printf "# %s\n" "$1"
29+
}
30+
31+
github::md::h2(){
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::log::group(){
64+
echo "::group::$*"
65+
}
66+
67+
github::log::endgroup(){
68+
echo "::endgroup::"
69+
}
70+
71+
github::log::warning(){
72+
local title="$1"
73+
local msg="$2"
74+
75+
echo "::warning title=$title::$msg"
76+
}
77+
78+
_begin=${_begin:-}
79+
_duration=
80+
github::timer::begin(){
81+
_begin="$(date +%s)"
82+
}
83+
84+
github::timer::tick(){
85+
local tick
86+
87+
tick="$(date +%s)"
88+
printf "%s" "$((tick - _begin))"
89+
}
90+
91+
github::timer::format() {
92+
local t
93+
t="$(cat "$1")"
94+
local h=$((t/60/60%24))
95+
local m=$((t/60%60))
96+
local s=$((t%60))
97+
98+
[[ "$h" == 0 ]] || printf "%d hours " "$h"
99+
[[ "$m" == 0 ]] || printf "%d minutes " "$m"
100+
printf '%d seconds' "$s"
101+
}

hack/github/gotestsum-reporter.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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::h2 "Top level statistics"
29+
github::md::table::header "Skipped" "Failed" "Passed" "Total"
30+
github::md::table::line "$TESTS_SKIPPED" "$TESTS_FAILED" "$(( TESTS_TOTAL - TESTS_FAILED - TESTS_SKIPPED ))" "$TESTS_TOTAL"
31+
32+
github::md::h2 "Time split per-package"
33+
github::md::table::header "Package" "Time spent"
34+
jq -rc 'select(has("Test") | not) | select(.Elapsed) | "| \(.Package) | \(.Elapsed) |"' < "$GOTESTSUM_JSONFILE"
35+
36+
github::md::h2 "Failing tests"
37+
echo '```'
38+
jq -rc 'select(.Action == "fail") | select(.Test) | .Test' < "$GOTESTSUM_JSONFILE"
39+
echo '```'
40+
41+
github::md::h2 "Duration: worst offenders over 10 seconds"
42+
echo '```'
43+
gotestsum tool slowest --threshold 10s --jsonfile "$GOTESTSUM_JSONFILE"
44+
echo '```'
45+
} > "$GITHUB_STEP_SUMMARY"

hack/test-integration.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ readonly retries="2"
3131
readonly needsudo="${WITH_SUDO:-}"
3232

3333
# See https://github.com/containerd/nerdctl/blob/main/docs/testing/README.md#about-parallelization
34-
args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/../cmd/nerdctl/...)
34+
args=(--format=testname --post-run-command "$root"/hack/github/gotestsum-reporter.sh --jsonfile /tmp/test-integration.log --packages="$root"/../cmd/nerdctl/...)
3535

3636
if [ "$#" == 0 ]; then
3737
"$root"/test-integration.sh -test.only-flaky=false
@@ -51,6 +51,3 @@ if [ "$needsudo" == "true" ] || [ "$needsudo" == "yes" ] || [ "$needsudo" == "1"
5151
else
5252
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -args -test.allow-kill-daemon "$@"
5353
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)