Skip to content

Commit 23b6d53

Browse files
committed
Switch from shellscripts-based CI to Go-based CI
Recently, it is becoming harder and harder to maintain shellscript-based CI. Let's switch to golang-based tests. This makes it easy to write test codes in a type-safe & modular manner, with leveraging rich language features of Go. Signed-off-by: Kohei Tokunaga <[email protected]>
1 parent 366bc3c commit 23b6d53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4978
-3483
lines changed

.github/workflows/benchmark.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,33 @@ jobs:
99
runs-on: ubuntu-20.04
1010
name: HelloBench
1111
env:
12-
BENCHMARK_LOG_DIR: ${{ github.workspace }}/log/
13-
BENCHMARK_RESULT_DIR: ${{ github.workspace }}/benchmark/
14-
BENCHMARK_REGISTRY: ghcr.io
15-
BENCHMARK_USER: stargz-containers
12+
BENCHMARK_LOG_FILE: ${{ github.workspace }}/benchmark-result/run.log
13+
BENCHMARK_RESULT_DIR: ${{ github.workspace }}/benchmark-result/
14+
BENCHMARK_TARGET_REPOSITORY: ghcr.io/stargz-containers
1615
BENCHMARK_TARGETS: python:3.9 gcc:10.2.0 postgres:13.1 tomcat:10.0.0-jdk15-openjdk-buster
1716
BENCHMARK_SAMPLES_NUM: 5
1817
BENCHMARK_PERCENTILE: 95
19-
BENCHMARK_PERCENTILES_GRANULARITY: 25
18+
BENCHMARK_PERCENTILE_GRANULARITY: 25
2019
steps:
2120
- name: Install tools
2221
run: |
2322
sudo apt-get update && sudo apt-get --no-install-recommends install -y gnuplot
2423
pip install numpy
2524
- uses: actions/checkout@v2
25+
with:
26+
path: src/github.com/containerd/stargz-snapshotter
2627
- name: Prepare directories
27-
run: mkdir "${BENCHMARK_RESULT_DIR}" "${BENCHMARK_LOG_DIR}"
28+
run: mkdir -p "${BENCHMARK_RESULT_DIR}"
2829
- name: Get instance information
2930
run: |
3031
curl -H "Metadata:true" "http://169.254.169.254/metadata/instance?api-version=2019-11-01" | \
3132
jq '{ location : .compute.location, vmSize : .compute.vmSize }' | \
3233
tee ${{ env.BENCHMARK_RESULT_DIR }}/instance.json
3334
- name: Run benchmark
35+
env:
36+
STARGZ_SNAPSHOTTER_PROJECT_ROOT: ${{ github.workspace }}/src/github.com/containerd/stargz-snapshotter
3437
run: make benchmark
38+
working-directory: src/github.com/containerd/stargz-snapshotter
3539
- uses: actions/upload-artifact@v1
3640
if: ${{ always() }}
3741
with:

.github/workflows/nightly.yml

+1-30
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,13 @@ on:
1818
env:
1919
DOCKER_BUILDKIT: 1
2020
DOCKER_BUILD_ARGS: --build-arg=CONTAINERD_VERSION=master # do tests with the latest containerd
21+
GO_TEST_FLAGS: -parallel 4
2122

2223
jobs:
2324
integration:
2425
runs-on: ubuntu-20.04
2526
name: Integration
2627
steps:
27-
- name: Install htpasswd for setting up private registry
28-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
2928
- uses: actions/checkout@v2
3029
- name: Run integration test
3130
run: make integration
32-
33-
test-optimize:
34-
runs-on: ubuntu-20.04
35-
name: Optimize
36-
steps:
37-
- name: Install htpasswd for setting up private registry
38-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
39-
- uses: actions/checkout@v2
40-
- name: Run test for optimize subcommand of ctr-remote
41-
run: make test-optimize
42-
43-
test-pullsecrets:
44-
runs-on: ubuntu-20.04
45-
name: PullSecrets
46-
steps:
47-
- name: Install htpasswd for setting up private registry
48-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
49-
- uses: actions/checkout@v2
50-
- name: Run test for pulling image from private registry on Kubernetes
51-
run: make test-pullsecrets
52-
53-
test-cri:
54-
runs-on: ubuntu-20.04
55-
name: CRIValidation
56-
steps:
57-
- uses: actions/checkout@v2
58-
- name: Varidate the runtime through CRI
59-
run: make test-cri

.github/workflows/tests.yml

+6-59
Original file line numberDiff line numberDiff line change
@@ -37,76 +37,23 @@ jobs:
3737
strategy:
3838
fail-fast: false
3939
matrix:
40-
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
40+
buildargs: ["", "CONTAINERD_VERSION=master"] # released version & master version
4141
builtin: ["true", "false"]
4242
exclude:
4343
- buildargs: ""
4444
builtin: "true"
4545
steps:
46-
- name: Install htpasswd for setting up private registry
47-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
4846
- uses: actions/checkout@v2
47+
with:
48+
path: src/github.com/containerd/stargz-snapshotter
4949
- name: Run integration test
5050
env:
5151
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
5252
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
53+
GO_TEST_FLAGS: -parallel 1
54+
STARGZ_SNAPSHOTTER_PROJECT_ROOT: ${{ github.workspace }}/src/github.com/containerd/stargz-snapshotter
5355
run: make integration
54-
55-
test-optimize:
56-
runs-on: ubuntu-20.04
57-
name: Optimize
58-
strategy:
59-
fail-fast: false
60-
matrix:
61-
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
62-
steps:
63-
- name: Install htpasswd for setting up private registry
64-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
65-
- uses: actions/checkout@v2
66-
- name: Run test for optimize subcommand of ctr-remote
67-
env:
68-
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
69-
run: make test-optimize
70-
71-
test-pullsecrets:
72-
runs-on: ubuntu-20.04
73-
name: PullSecrets
74-
strategy:
75-
fail-fast: false
76-
matrix:
77-
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
78-
builtin: ["true", "false"]
79-
exclude:
80-
- buildargs: ""
81-
builtin: "true"
82-
steps:
83-
- name: Install htpasswd for setting up private registry
84-
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
85-
- uses: actions/checkout@v2
86-
- name: Run test for pulling image from private registry on Kubernetes
87-
env:
88-
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
89-
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
90-
run: make test-pullsecrets
91-
92-
test-cri:
93-
runs-on: ubuntu-20.04
94-
name: CRIValidation
95-
strategy:
96-
fail-fast: false
97-
matrix:
98-
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
99-
builtin: ["true", "false"]
100-
exclude:
101-
- buildargs: ""
102-
builtin: "true"
103-
steps:
104-
- uses: actions/checkout@v2
105-
- name: Varidate the runtime through CRI
106-
env:
107-
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
108-
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
109-
run: make test-cri
56+
working-directory: src/github.com/containerd/stargz-snapshotter
11057

11158
#
11259
# Project checks

Dockerfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ FROM golang:1.15-buster AS golang-base
2525
# Build containerd
2626
FROM golang-base AS containerd-dev
2727
ARG CONTAINERD_VERSION
28-
RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
28+
RUN --mount=type=cache,target=/root/.cache/go-build \
29+
--mount=type=cache,target=/go/pkg/mod \
30+
apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
2931
git clone -b ${CONTAINERD_VERSION} --depth 1 \
3032
https://github.com/containerd/containerd $GOPATH/src/github.com/containerd/containerd && \
3133
cd $GOPATH/src/github.com/containerd/containerd && \
@@ -35,7 +37,9 @@ RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
3537
FROM golang-base AS containerd-snapshotter-dev
3638
ARG CONTAINERD_VERSION
3739
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
38-
RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
40+
RUN --mount=type=cache,target=/root/.cache/go-build \
41+
--mount=type=cache,target=/go/pkg/mod \
42+
apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
3943
git clone -b ${CONTAINERD_VERSION} --depth 1 \
4044
https://github.com/containerd/containerd $GOPATH/src/github.com/containerd/containerd && \
4145
echo 'require github.com/containerd/stargz-snapshotter v0.0.0\nreplace github.com/containerd/stargz-snapshotter => '$GOPATH'/src/github.com/containerd/stargz-snapshotter\nreplace github.com/containerd/stargz-snapshotter/estargz => '$GOPATH'/src/github.com/containerd/stargz-snapshotter/estargz' \
@@ -48,7 +52,9 @@ RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
4852
# Build runc
4953
FROM golang-base AS runc-dev
5054
ARG RUNC_VERSION
51-
RUN apt-get update -y && apt-get install -y libseccomp-dev && \
55+
RUN --mount=type=cache,target=/root/.cache/go-build \
56+
--mount=type=cache,target=/go/pkg/mod \
57+
apt-get update -y && apt-get install -y libseccomp-dev && \
5258
git clone -b ${RUNC_VERSION} --depth 1 \
5359
https://github.com/opencontainers/runc $GOPATH/src/github.com/opencontainers/runc && \
5460
cd $GOPATH/src/github.com/opencontainers/runc && \
@@ -61,7 +67,9 @@ ARG GOARM
6167
ARG SNAPSHOTTER_BUILD_FLAGS
6268
ARG CTR_REMOTE_BUILD_FLAGS
6369
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
64-
RUN cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
70+
RUN --mount=type=cache,target=/root/.cache/go-build \
71+
--mount=type=cache,target=/go/pkg/mod \
72+
cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
6573
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make containerd-stargz-grpc && \
6674
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${CTR_REMOTE_BUILD_FLAGS} make ctr-remote
6775

@@ -114,7 +122,7 @@ RUN apt-get update && apt-get install -y iptables && \
114122
FROM kindest/node:v1.20.0 AS kind-builtin-snapshotter
115123
COPY --from=containerd-snapshotter-dev /out/bin/containerd /out/bin/containerd-shim-runc-v2 /usr/local/bin/
116124
COPY --from=snapshotter-dev /out/ctr-remote /usr/local/bin/
117-
COPY ./script/config/ /
125+
COPY ./script/config-builtin/ /
118126
RUN apt-get update -y && apt-get install --no-install-recommends -y fuse
119127
ENTRYPOINT [ "/usr/local/bin/entrypoint", "/sbin/init" ]
120128

Makefile

+7-14
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,19 @@ clean:
6464

6565
test:
6666
@echo "$@"
67-
@GO111MODULE=$(GO111MODULE_VALUE) go test -race ./...
68-
@cd ./estargz ; GO111MODULE=$(GO111MODULE_VALUE) go test -race ./...
67+
@GO111MODULE=$(GO111MODULE_VALUE) ENABLE_INTEGRATION_TEST=false go test $(GO_TEST_FLAGS) -race ./...
68+
@cd ./estargz ; GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) -race ./...
6969

7070
test-root:
7171
@echo "$@"
72-
@GO111MODULE=$(GO111MODULE_VALUE) go test -race ./snapshot -test.root
72+
@GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) -race ./snapshot -test.root
7373

7474
test-all: test-root test
7575

7676
integration:
77-
@./script/integration/test.sh
78-
79-
test-optimize:
80-
@./script/optimize/test.sh
77+
@echo "$@"
78+
@GO111MODULE=$(GO111MODULE_VALUE) ENABLE_INTEGRATION_TEST=true go test $(GO_TEST_FLAGS) -v -timeout=0 ./integration
8179

8280
benchmark:
83-
@./script/benchmark/test.sh
84-
85-
test-pullsecrets:
86-
@./script/pullsecrets/test.sh
87-
88-
test-cri:
89-
@./script/cri/test.sh
81+
@echo "$@"
82+
@GO111MODULE=$(GO111MODULE_VALUE) go test -v -timeout=0 ./benchmark

0 commit comments

Comments
 (0)