diff --git a/resources/shell-tools/.gitlab-ci.yml b/resources/shell-tools/.gitlab-ci.yml index b298ecd7373d2b6cbdc110c389a4f028389738ed..3b60c25201aea66998072d81eafc31376a932a02 100644 --- a/resources/shell-tools/.gitlab-ci.yml +++ b/resources/shell-tools/.gitlab-ci.yml @@ -16,4 +16,7 @@ shell-tools-test: stage: shell-tools-test script: - ./resources/shell-tools/test/fix-dockerfile-pinning.sh - - ./resources/shell-tools/test/multiarch.sh + - ./resources/shell-tools/test/manifest.sh + - ./resources/shell-tools/test/manifest-latest.sh + - ./resources/shell-tools/test/manifest-print.sh + - ./resources/shell-tools/test/manifest-push.sh diff --git a/resources/shell-tools/test/manifest-latest.sh b/resources/shell-tools/test/manifest-latest.sh new file mode 100755 index 0000000000000000000000000000000000000000..c44e0adfa563a26323fe33bf024e4b0015a7414d --- /dev/null +++ b/resources/shell-tools/test/manifest-latest.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -o pipefail +set -u + +BASEDIR=$(dirname "$0") + +podman build --format docker -t mytest-latest:test-amd64 -f- <<EOF +FROM scratch +EOF +podman build --format docker -t mytest-latest:test-arm64 -f- <<EOF +FROM scratch +EOF + +"$BASEDIR"/../bin/manifest.sh --local --latest mytest-latest:test registry.example.com/latest-test 1.2.3 + +ERRORS=0 +podman manifest inspect registry.example.com/latest-test:latest +ERRORS=$((ERRORS + "$?")) + +if [ "$ERRORS" = "0" ]; then + EXIT_CODE=0 +else + EXIT_CODE=1 +fi + +podman rmi -f registry.example.com/latest-test:1 \ + registry.example.com/latest-test:1.2 \ + registry.example.com/latest-test:1.2.3 \ + registry.example.com/latest-test:latest +podman rmi -f "$(podman images -q mytest-latest:test-amd64)" +podman rmi -f "$(podman images -q mytest-latest:test-arm64)" + +exit $EXIT_CODE diff --git a/resources/shell-tools/test/manifest-print.sh b/resources/shell-tools/test/manifest-print.sh new file mode 100755 index 0000000000000000000000000000000000000000..d8b6d43db7b3c2b0a12c37e7e6a7a5faa4fc80fb --- /dev/null +++ b/resources/shell-tools/test/manifest-print.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -o pipefail +set -u + +BASEDIR=$(dirname "$0") + +podman build --format docker -t mytest-latest:test-amd64 -f- <<EOF +FROM scratch +EOF +podman build --format docker -t mytest-latest:test-arm64 -f- <<EOF +FROM scratch +EOF + +MANIFESTS_TO_PUSH=$("$BASEDIR"/../bin/manifest.sh --local --print mytest-latest:test registry.example.com/latest-test 1.2.3) + +EXIT_CODE=1 + +if [ "$MANIFESTS_TO_PUSH" == "registry.example.com/latest-test:1 registry.example.com/latest-test:1.2 registry.example.com/latest-test:1.2.3" ]; then + EXIT_CODE=0 +fi + +podman rmi -f registry.example.com/latest-test:1 \ + registry.example.com/latest-test:1.2 \ + registry.example.com/latest-test:1.2.3 +podman rmi -f "$(podman images -q mytest-latest:test-amd64)" +podman rmi -f "$(podman images -q mytest-latest:test-arm64)" + +exit $EXIT_CODE diff --git a/resources/shell-tools/test/manifest-push.sh b/resources/shell-tools/test/manifest-push.sh new file mode 100755 index 0000000000000000000000000000000000000000..24560fe3012165abf6957367fe44f0c39eaf03dd --- /dev/null +++ b/resources/shell-tools/test/manifest-push.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -o pipefail +set -u + +BASEDIR=$(dirname "$0") + +podman build --format docker -t mytest-latest:test-amd64 -f- <<EOF +FROM scratch +EOF +podman build --format docker -t mytest-latest:test-arm64 -f- <<EOF +FROM scratch +EOF + +MANIFESTS_TO_PUSH=$("$BASEDIR"/../bin/manifest.sh --archs="amd64:arm64" --local --print mytest-latest:test registry.example.com/latest-test 1.2.3) + +EXIT_CODE=1 + +PUSHED=$("$BASEDIR"/../bin/manifest-push.sh --dry "$MANIFESTS_TO_PUSH") + +if [ "$PUSHED" == "registry.example.com/latest-test:1 registry.example.com/latest-test:1.2 registry.example.com/latest-test:1.2.3" ]; then + EXIT_CODE=0 +fi + +podman rmi -f registry.example.com/latest-test:1 \ + registry.example.com/latest-test:1.2 \ + registry.example.com/latest-test:1.2.3 +podman rmi -f "$(podman images -q mytest-latest:test-amd64)" +podman rmi -f "$(podman images -q mytest-latest:test-arm64)" + +exit $EXIT_CODE diff --git a/resources/shell-tools/test/manifest.sh b/resources/shell-tools/test/manifest.sh new file mode 100755 index 0000000000000000000000000000000000000000..f74de379bea9222e697f619d38338bab08afc411 --- /dev/null +++ b/resources/shell-tools/test/manifest.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -o pipefail +set -u + +BASEDIR=$(dirname "$0") + +podman build --format docker -t mytest-latest:test-amd64 -f- <<EOF +FROM scratch +EOF +podman build --format docker -t mytest-latest:test-arm64 -f- <<EOF +FROM scratch +EOF + +"$BASEDIR"/../bin/manifest.sh --archs="amd64:arm64" --local mytest-latest:test registry.example.com/latest-test 1.2.3 + +ERRORS=0 +podman manifest inspect registry.example.com/latest-test:1 +ERRORS=$((ERRORS + "$?")) +podman manifest inspect registry.example.com/latest-test:1.2 +ERRORS=$((ERRORS + "$?")) +podman manifest inspect registry.example.com/latest-test:1.2.3 +ERRORS=$((ERRORS + "$?")) + +if [ "$ERRORS" = "0" ]; then + EXIT_CODE=0 +else + EXIT_CODE=1 +fi + +podman rmi -f registry.example.com/latest-test:1 \ + registry.example.com/latest-test:1.2 \ + registry.example.com/latest-test:1.2.3 +podman rmi -f "$(podman images -q mytest-latest:test-amd64)" +podman rmi -f "$(podman images -q mytest-latest:test-arm64)" + +exit $EXIT_CODE