Skip to content

Commit

Permalink
Switch from shellscripts-based CI to Go-based CI
Browse files Browse the repository at this point in the history
Recently, it is becoming harder and harder to maintain shellscript-based CI.
Let's switch to golang-based tests.
This will help us to write test codes in a type-safe & modular manner,
leveraging rich language features of Go.

Signed-off-by: Kohei Tokunaga <[email protected]>
  • Loading branch information
ktock committed Apr 29, 2021
1 parent 525f818 commit a0845c4
Show file tree
Hide file tree
Showing 58 changed files with 5,007 additions and 3,483 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,33 @@ jobs:
runs-on: ubuntu-20.04
name: HelloBench
env:
BENCHMARK_LOG_DIR: ${{ github.workspace }}/log/
BENCHMARK_RESULT_DIR: ${{ github.workspace }}/benchmark/
BENCHMARK_REGISTRY: ghcr.io
BENCHMARK_USER: stargz-containers
BENCHMARK_LOG_FILE: ${{ github.workspace }}/benchmark-result/run.log
BENCHMARK_RESULT_DIR: ${{ github.workspace }}/benchmark-result/
BENCHMARK_TARGET_REPOSITORY: ghcr.io/stargz-containers
BENCHMARK_TARGETS: python:3.9 gcc:10.2.0 postgres:13.1 tomcat:10.0.0-jdk15-openjdk-buster
BENCHMARK_SAMPLES_NUM: 5
BENCHMARK_PERCENTILE: 95
BENCHMARK_PERCENTILES_GRANULARITY: 25
BENCHMARK_PERCENTILE_GRANULARITY: 25
steps:
- name: Install tools
run: |
sudo apt-get update && sudo apt-get --no-install-recommends install -y gnuplot
pip install numpy
- uses: actions/checkout@v2
with:
path: src/github.com/containerd/stargz-snapshotter
- name: Prepare directories
run: mkdir "${BENCHMARK_RESULT_DIR}" "${BENCHMARK_LOG_DIR}"
run: mkdir -p "${BENCHMARK_RESULT_DIR}"
- name: Get instance information
run: |
curl -H "Metadata:true" "http://169.254.169.254/metadata/instance?api-version=2019-11-01" | \
jq '{ location : .compute.location, vmSize : .compute.vmSize }' | \
tee ${{ env.BENCHMARK_RESULT_DIR }}/instance.json
- name: Run benchmark
env:
STARGZ_SNAPSHOTTER_PROJECT_ROOT: ${{ github.workspace }}/src/github.com/containerd/stargz-snapshotter
run: make benchmark
working-directory: src/github.com/containerd/stargz-snapshotter
- uses: actions/upload-artifact@v1
if: ${{ always() }}
with:
Expand Down
35 changes: 5 additions & 30 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,17 @@ on:
env:
DOCKER_BUILDKIT: 1
DOCKER_BUILD_ARGS: --build-arg=CONTAINERD_VERSION=master # do tests with the latest containerd
GO_TEST_FLAGS: -parallel 4
STARGZ_SNAPSHOTTER_PROJECT_ROOT: ${{ github.workspace }}/src/github.com/containerd/stargz-snapshotter

jobs:
integration:
runs-on: ubuntu-20.04
name: Integration
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
with:
path: src/github.com/containerd/stargz-snapshotter
- name: Run integration test
run: make integration

test-optimize:
runs-on: ubuntu-20.04
name: Optimize
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
- name: Run test for optimize subcommand of ctr-remote
run: make test-optimize

test-pullsecrets:
runs-on: ubuntu-20.04
name: PullSecrets
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
- name: Run test for pulling image from private registry on Kubernetes
run: make test-pullsecrets

test-cri:
runs-on: ubuntu-20.04
name: CRIValidation
steps:
- uses: actions/checkout@v2
- name: Varidate the runtime through CRI
run: make test-cri
working-directory: src/github.com/containerd/stargz-snapshotter
65 changes: 6 additions & 59 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,76 +37,23 @@ jobs:
strategy:
fail-fast: false
matrix:
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
buildargs: ["", "CONTAINERD_VERSION=master"] # released version & master version
builtin: ["true", "false"]
exclude:
- buildargs: ""
builtin: "true"
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
with:
path: src/github.com/containerd/stargz-snapshotter
- name: Run integration test
env:
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
GO_TEST_FLAGS: -parallel 4
STARGZ_SNAPSHOTTER_PROJECT_ROOT: ${{ github.workspace }}/src/github.com/containerd/stargz-snapshotter
run: make integration

test-optimize:
runs-on: ubuntu-20.04
name: Optimize
strategy:
fail-fast: false
matrix:
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
- name: Run test for optimize subcommand of ctr-remote
env:
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
run: make test-optimize

test-pullsecrets:
runs-on: ubuntu-20.04
name: PullSecrets
strategy:
fail-fast: false
matrix:
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
builtin: ["true", "false"]
exclude:
- buildargs: ""
builtin: "true"
steps:
- name: Install htpasswd for setting up private registry
run: sudo apt-get update -y && sudo apt-get --no-install-recommends install -y apache2-utils
- uses: actions/checkout@v2
- name: Run test for pulling image from private registry on Kubernetes
env:
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
run: make test-pullsecrets

test-cri:
runs-on: ubuntu-20.04
name: CRIValidation
strategy:
fail-fast: false
matrix:
buildargs: ["", "--build-arg=CONTAINERD_VERSION=master"] # released version & master version
builtin: ["true", "false"]
exclude:
- buildargs: ""
builtin: "true"
steps:
- uses: actions/checkout@v2
- name: Varidate the runtime through CRI
env:
DOCKER_BUILD_ARGS: ${{ matrix.buildargs }}
BUILTIN_SNAPSHOTTER: ${{ matrix.builtin }}
run: make test-cri
working-directory: src/github.com/containerd/stargz-snapshotter

#
# Project checks
Expand Down
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ FROM golang:1.15-buster AS golang-base
# Build containerd
FROM golang-base AS containerd-dev
ARG CONTAINERD_VERSION
RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
git clone -b ${CONTAINERD_VERSION} --depth 1 \
https://github.com/containerd/containerd $GOPATH/src/github.com/containerd/containerd && \
cd $GOPATH/src/github.com/containerd/containerd && \
Expand All @@ -35,7 +37,9 @@ RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
FROM golang-base AS containerd-snapshotter-dev
ARG CONTAINERD_VERSION
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
git clone -b ${CONTAINERD_VERSION} --depth 1 \
https://github.com/containerd/containerd $GOPATH/src/github.com/containerd/containerd && \
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' \
Expand All @@ -48,7 +52,9 @@ RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev && \
# Build runc
FROM golang-base AS runc-dev
ARG RUNC_VERSION
RUN apt-get update -y && apt-get install -y libseccomp-dev && \
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
apt-get update -y && apt-get install -y libseccomp-dev && \
git clone -b ${RUNC_VERSION} --depth 1 \
https://github.com/opencontainers/runc $GOPATH/src/github.com/opencontainers/runc && \
cd $GOPATH/src/github.com/opencontainers/runc && \
Expand All @@ -61,7 +67,9 @@ ARG GOARM
ARG SNAPSHOTTER_BUILD_FLAGS
ARG CTR_REMOTE_BUILD_FLAGS
COPY . $GOPATH/src/github.com/containerd/stargz-snapshotter
RUN cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
cd $GOPATH/src/github.com/containerd/stargz-snapshotter && \
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${SNAPSHOTTER_BUILD_FLAGS} make containerd-stargz-grpc && \
PREFIX=/out/ GOARCH=${TARGETARCH:-amd64} GO_BUILD_FLAGS=${CTR_REMOTE_BUILD_FLAGS} make ctr-remote

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

Expand Down
21 changes: 7 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,19 @@ clean:

test:
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) go test -race ./...
@cd ./estargz ; GO111MODULE=$(GO111MODULE_VALUE) go test -race ./...
@GO111MODULE=$(GO111MODULE_VALUE) ENABLE_INTEGRATION_TEST=false go test $(GO_TEST_FLAGS) -race ./...
@cd ./estargz ; GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) -race ./...

test-root:
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) go test -race ./snapshot -test.root
@GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) -race ./snapshot -test.root

test-all: test-root test

integration:
@./script/integration/test.sh

test-optimize:
@./script/optimize/test.sh
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) ENABLE_INTEGRATION_TEST=true go test $(GO_TEST_FLAGS) -v -timeout=0 ./integration

benchmark:
@./script/benchmark/test.sh

test-pullsecrets:
@./script/pullsecrets/test.sh

test-cri:
@./script/cri/test.sh
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) go test -v -timeout=0 ./benchmark
Loading

0 comments on commit a0845c4

Please sign in to comment.