Skip to content

Commit

Permalink
test: test build on docker and nerdctl
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <kweizh@gmail.com>
  • Loading branch information
zwpaper committed Feb 20, 2023
1 parent e484ec1 commit 94622b3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ concurrency:
jobs:
test-build:
runs-on: ubuntu-latest
strategy:
matrix:
builder:
- docker
- nerdctl
steps:
- uses: actions/checkout@v3
- name: Set up Go
Expand All @@ -33,15 +38,25 @@ jobs:
run: |
make build
- name: Install Nerdctl and Start Containerd
if: ${{ matrix.builder == 'nerdctl' }}
shell: bash
run: |
curl -sSL https://github.com/containerd/nerdctl/releases/download/v1.1.0/nerdctl-full-1.1.0-linux-amd64.tar.gz -o - | sudo tar -xz -C /usr/local
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
containerd-rootless-setuptool.sh install
containerd-rootless-setuptool.sh install-buildkit-containerd
- name: Build Image
shell: bash
run: |
make build-image
BUILDER=${{ matrix.builder }} make build-image
- name: Build Cluster Image
shell: bash
run: |
make build-cluster-image
BUILDER=${{ matrix.builder }} make build-cluster-image
test-kwok:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -170,6 +185,7 @@ jobs:
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
containerd-rootless-setuptool.sh install
containerd-rootless-setuptool.sh install-buildkit-containerd
- name: Make pki directory
if: ${{ matrix.kwokctl-runtime == 'binary' }}
Expand Down
48 changes: 48 additions & 0 deletions test/release/build.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,76 @@ docker buildx build --tag=kwok:${VERSION} --platform=linux/amd64 --load -f image
EOF
}

function want_image_nerdctl() {
cat <<EOF
nerdctl build --tag=kwok:${VERSION} --platform=linux/amd64 -f images/kwok/Dockerfile .
EOF
}

function want_image_with_push() {
cat <<EOF
docker buildx build --tag=kwok:${VERSION} --platform=linux/amd64 --push -f images/kwok/Dockerfile .
EOF
}

function want_image_nerdctl_with_push() {
cat <<EOF
nerdctl build --tag=kwok:${VERSION} --platform=linux/amd64 -f images/kwok/Dockerfile .
nerdctl push --platform=linux/amd64 kwok:${VERSION}
EOF
}

function want_image_with_push_staging() {
cat <<EOF
docker buildx build --tag=${IMAGE_PREFIX}/kwok:${PREFIX}-${VERSION} --platform=linux/amd64 --push -f images/kwok/Dockerfile .
EOF
}

function want_image_nerdctl_with_push_staging() {
cat <<EOF
nerdctl build --tag=${IMAGE_PREFIX}/kwok:${PREFIX}-${VERSION} --platform=linux/amd64 -f images/kwok/Dockerfile .
nerdctl push --platform=linux/amd64 ${IMAGE_PREFIX}/kwok:${PREFIX}-${VERSION}
EOF
}

function want_cluster_image() {
cat <<EOF
docker buildx build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=cluster:${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 --load -f images/cluster/Dockerfile .
EOF
}

function want_cluster_image_nerdctl() {
cat <<EOF
nerdctl build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=cluster:${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 -f images/cluster/Dockerfile .
EOF
}

function want_cluster_image_with_push() {
cat <<EOF
docker buildx build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=cluster:${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 --push -f images/cluster/Dockerfile .
EOF
}

function want_cluster_image_nerdctl_with_push() {
cat <<EOF
nerdctl build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=cluster:${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 -f images/cluster/Dockerfile .
nerdctl push --platform=linux/amd64 cluster:${VERSION}-k8s.v${LAST_KUBE_RELEASE}
EOF
}

function want_cluster_image_with_push_staging() {
cat <<EOF
docker buildx build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=${IMAGE_PREFIX}/cluster:${PREFIX}-${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 --push -f images/cluster/Dockerfile .
EOF
}

function want_cluster_image_nerdctl_with_push_staging() {
cat <<EOF
nerdctl build --build-arg=kube_version=v${LAST_KUBE_RELEASE} --tag=${IMAGE_PREFIX}/cluster:${PREFIX}-${VERSION}-k8s.v${LAST_KUBE_RELEASE} --platform=linux/amd64 -f images/cluster/Dockerfile .
nerdctl push --platform=linux/amd64 ${IMAGE_PREFIX}/cluster:${PREFIX}-${VERSION}-k8s.v${LAST_KUBE_RELEASE}
EOF
}

function want_cross_build() {
cat <<EOF
GOOS=linux GOARCH=amd64 go build -ldflags '-X sigs.k8s.io/kwok/pkg/consts.Version=${VERSION} -X sigs.k8s.io/kwok/pkg/consts.KubeVersion=v${LAST_KUBE_RELEASE}' -o ./bin/linux/amd64/kwok ./cmd/kwok
Expand Down Expand Up @@ -267,10 +307,18 @@ function main() {
make --no-print-directory -C "${ROOT_DIR}" PUSH=true image | diff -u <(want_image_with_push) - || failed+=("image-with-push")
make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} STAGING_IMAGE_PREFIX=${IMAGE_PREFIX} image | diff -u <(want_image_with_push_staging) - || failed+=("image-with-push-staging")

BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" image | diff -u <(want_image_nerdctl) - || failed+=("image-nerdctl")
BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" PUSH=true image | diff -u <(want_image_nerdctl_with_push) - || failed+=("image-nerdctl-with-push")
BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} STAGING_IMAGE_PREFIX=${IMAGE_PREFIX} image | diff -u <(want_image_nerdctl_with_push_staging) - || failed+=("image--nerdctl-with-push-staging")

make --no-print-directory -C "${ROOT_DIR}" cluster-image | diff -u <(want_cluster_image) - || failed+=("cluster-image")
make --no-print-directory -C "${ROOT_DIR}" PUSH=true cluster-image | diff -u <(want_cluster_image_with_push) - || failed+=("cluster-image-with-push")
make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} STAGING_IMAGE_PREFIX=${IMAGE_PREFIX} cluster-image | diff -u <(want_cluster_image_with_push_staging) - || failed+=("cluster-image-with-push-staging")

BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" cluster-image | diff -u <(want_cluster_image_nerdctl) - || failed+=("cluster-image-nerdctl")
BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" PUSH=true cluster-image | diff -u <(want_cluster_image_nerdctl_with_push) - || failed+=("cluster-image-nerdctl-with-push")
BUILDER=nerdctl make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} STAGING_IMAGE_PREFIX=${IMAGE_PREFIX} cluster-image | diff -u <(want_cluster_image_nerdctl_with_push_staging) - || failed+=("cluster-image-nerdctl-with-push-staging")

make --no-print-directory -C "${ROOT_DIR}" cross-build | diff -u <(want_cross_build) - || failed+=("cross-build")
make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket cross-build | diff -u <(want_cross_build_with_push_bucket) - || failed+=("cross-build-with-push-bucket")
make --no-print-directory -C "${ROOT_DIR}" PUSH=true BUCKET=bucket STAGING=true STAGING_PREFIX=${PREFIX} cross-build | diff -u <(want_cross_build_with_push_bucket_staging) - || failed+=("cross-build-with-push-bucket-staging")
Expand Down

0 comments on commit 94622b3

Please sign in to comment.