Skip to content

Commit a676bd0

Browse files
authored
Merge pull request #121 from crazy-max/hack-split-test-benchmark
ci: split test and benchmark jobs
2 parents 79bfeff + a7e0774 commit a676bd0

File tree

5 files changed

+101
-14
lines changed

5 files changed

+101
-14
lines changed

Diff for: .github/workflows/ci.yml

+72-2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,75 @@ jobs:
9797
artifact_key: ${{ needs.get-env.outputs.BUILDKIT_ARTIFACT_KEY }}
9898

9999
test:
100+
runs-on: ubuntu-24.04
101+
needs:
102+
- buildkit-binaries
103+
env:
104+
TEST_FLAGS: -v
105+
TEST_IMAGE_BUILD: 0
106+
TEST_IMAGE_ID: buildkit-bench
107+
TEST_RESULTS_DIR: bin/results
108+
steps:
109+
-
110+
name: Download binaries
111+
uses: actions/download-artifact@v4
112+
with:
113+
path: /tmp/buildkit-binaries
114+
pattern: ${{ env.BUILDKIT_ARTIFACT_KEY }}-*
115+
merge-multiple: true
116+
-
117+
name: Extract binaries
118+
run: |
119+
mkdir -p ./bin/buildkit-binaries
120+
for f in "/tmp/buildkit-binaries"/*.tar.gz; do
121+
(set -x ; tar -xzvf "$f" -C ./bin/buildkit-binaries && rm "$f")
122+
done
123+
tree -nph ./bin/buildkit-binaries
124+
-
125+
name: Set up Docker Buildx
126+
uses: docker/setup-buildx-action@v3
127+
with:
128+
version: ${{ env.SETUP_BUILDX_VERSION }}
129+
driver: docker
130+
-
131+
name: Set up QEMU
132+
uses: docker/setup-qemu-action@v3
133+
-
134+
name: Build test image
135+
uses: docker/bake-action@v5
136+
with:
137+
source: "{{defaultContext}}"
138+
targets: tests
139+
provenance: false
140+
set: |
141+
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
142+
*.contexts.buildkit-binaries=cwd://bin/buildkit-binaries
143+
*.output=type=docker,name=${{ env.TEST_IMAGE_ID }}
144+
-
145+
name: Checkout
146+
uses: actions/checkout@v4
147+
-
148+
name: Test
149+
run: |
150+
./hack/test
151+
env:
152+
TEST_TYPES: test
153+
-
154+
name: Result
155+
run: |
156+
resultPath=./${{ env.TEST_RESULTS_DIR }}/gotestoutput-tests.json
157+
mv ./${{ env.TEST_RESULTS_DIR }}/gotestoutput.json $resultPath
158+
jq . $resultPath
159+
-
160+
name: Upload results
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: tests-results
164+
path: ${{ env.TEST_RESULTS_DIR }}
165+
if-no-files-found: error
166+
retention-days: 1
167+
168+
benchmark:
100169
runs-on: ubuntu-24.04
101170
needs:
102171
- prepare
@@ -110,7 +179,6 @@ jobs:
110179
TEST_IMAGE_BUILD: 0
111180
TEST_IMAGE_ID: buildkit-bench
112181
TEST_RESULTS_DIR: bin/results
113-
TEST_GEN: 0
114182
steps:
115183
-
116184
name: Download binaries
@@ -151,10 +219,11 @@ jobs:
151219
name: Checkout
152220
uses: actions/checkout@v4
153221
-
154-
name: Test
222+
name: Benchmark
155223
run: |
156224
./hack/test
157225
env:
226+
TEST_TYPES: benchmark
158227
TEST_BENCH_REGEXP: ${{ matrix.test }}$
159228
TEST_BENCH_RUN: ${{ matrix.count }}
160229
TEST_BENCH_TIME: ${{ matrix.benchtime }}
@@ -179,6 +248,7 @@ jobs:
179248
runs-on: ubuntu-24.04
180249
needs:
181250
- test
251+
- benchmark
182252
steps:
183253
-
184254
name: Download results

Diff for: README.md

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ changes from default branch. You can also specify a commit to test or multiple
2626
references and tweak the benchmark settings:
2727

2828
```bash
29+
# run only tests
30+
TEST_TYPES=test make test
31+
32+
# run only benchmarks
33+
TEST_TYPES=benchmark make test
34+
2935
# run a specific benchmark
3036
TEST_BENCH_REGEXP=/BenchmarkBuildLocal$ make test
3137

Diff for: hack/test

+23-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -eu -o pipefail
55
: "${GITHUB_ACTIONS=}"
66
: "${GITHUB_EVENT_NAME=}"
77

8+
: "${TEST_TYPES=test benchmark}"
89
: "${TEST_IMAGE_BUILD=1}"
910
: "${TEST_IMAGE_ID=buildkit-bench}"
1011
: "${TEST_RESULTS_DIR=bin/results}"
@@ -51,6 +52,27 @@ if [ "$GITHUB_ACTIONS" = "true" ]; then
5152
fi
5253
fi
5354

55+
gotestArgs="-json -mod=vendor"
56+
testTypeSet=false
57+
for testType in $TEST_TYPES; do
58+
case "$testType" in
59+
test)
60+
testTypeSet=true
61+
;;
62+
benchmark)
63+
gotestArgs="$gotestArgs -bench=${TEST_BENCH_REGEXP:-.} -benchtime=${TEST_BENCH_TIME:-1x} -benchmem"
64+
;;
65+
*)
66+
echo "Unknown test type: $testType"
67+
exit 1
68+
;;
69+
esac
70+
done
71+
if [ "$testTypeSet" = false ]; then
72+
gotestArgs="$gotestArgs -run=^$"
73+
fi
74+
gotestArgs="$gotestArgs ${TEST_FLAGS:--v} ${TEST_PKG:-./test/...}"
75+
5476
(
5577
set -x
5678
docker run --rm --privileged $dockerConfigMount \
@@ -62,5 +84,5 @@ fi
6284
-e BUILDKIT_REF_RANDOM=$BUILDKIT_REF_RANDOM \
6385
-e REGISTRY_MIRROR_DIR=/root/.cache/registry \
6486
$TEST_IMAGE_ID \
65-
sh -c "go test -bench=${TEST_BENCH_REGEXP:-.} -benchtime=${TEST_BENCH_TIME:-1x} -benchmem -json -mod=vendor ${TEST_FLAGS:--v} ${TEST_PKG:-./test/...} | gotestmetrics parse --output $TEST_OUT_DIR/gotestoutput.json"
87+
sh -c "go test ${gotestArgs} | gotestmetrics parse --output $TEST_OUT_DIR/gotestoutput.json"
6688
)

Diff for: test/build_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func BenchmarkBuild(b *testing.B) {
2828
benchmarkBuildHighParallelization32x,
2929
benchmarkBuildHighParallelization64x,
3030
benchmarkBuildHighParallelization128x,
31-
benchmarkBuildHighParallelization256x,
3231
benchmarkBuildFileTransfer,
3332
), testutil.WithMirroredImages(mirroredImages))
3433
}
@@ -117,9 +116,6 @@ func benchmarkBuildHighParallelization64x(b *testing.B, sb testutil.Sandbox) {
117116
func benchmarkBuildHighParallelization128x(b *testing.B, sb testutil.Sandbox) {
118117
benchmarkBuildHighParallelization(b, sb, 128)
119118
}
120-
func benchmarkBuildHighParallelization256x(b *testing.B, sb testutil.Sandbox) {
121-
benchmarkBuildHighParallelization(b, sb, 256)
122-
}
123119
func benchmarkBuildHighParallelization(b *testing.B, sb testutil.Sandbox, n int) {
124120
dockerfile := []byte(`
125121
FROM busybox:latest AS base

Diff for: testconfig.yml

-7
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ runs:
6060
duration:
6161
description: Time (s)
6262
chart: boxplot
63-
BenchmarkBuildHighParallelization256x:
64-
description: Build high parallelization (256x)
65-
count: 4
66-
metrics:
67-
duration:
68-
description: Time (s)
69-
chart: boxplot
7063
BenchmarkBuildFileTransfer:
7164
description: Build with substantial file transfer
7265
count: 4

0 commit comments

Comments
 (0)