aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/oci-tasks')
-rwxr-xr-xtests/oci-tasks87+87 −0
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/oci-tasks b/tests/oci-tasks
new file mode 100755
--- /dev/null
+++ b/tests/oci-tasks
@@ -0,0 +1,87 @@
+#!/bin/sh -eu
+# SPDX-FileCopyrightText: 2026 Nikolay Govorov
+# SPDX-License-Identifier: 0BSD
+
+root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+mkdir -p "$work/bin" "$work/project/chart/templates"
+: > "$work/project/Dockerfile"
+cat > "$work/project/chart/Chart.yaml" <<'EOF'
+apiVersion: v2
+name: fixture
+version: 0.0.0
+EOF
+cat > "$work/project/chart/values.yaml" <<'EOF'
+image: fixture
+EOF
+cat > "$work/project/chart/templates/configmap.yaml" <<'EOF'
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: fixture
+EOF
+
+cat > "$work/bin/docker" <<'EOF'
+#!/bin/sh
+printf '%s\n' "$@" > "$OCI_TEST_DOCKER_LOG"
+EOF
+cat > "$work/bin/helm" <<'EOF'
+#!/bin/sh
+printf '%s\n' "$@" >> "$OCI_TEST_HELM_LOG"
+if [ "$1" = package ]; then
+ destination=
+ version=
+ shift
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --destination) destination=$2; shift 2 ;;
+ --version) version=$2; shift 2 ;;
+ *) shift ;;
+ esac
+ done
+ : > "$destination/fixture-$version.tgz"
+fi
+EOF
+chmod +x "$work/bin/docker" "$work/bin/helm"
+export PATH="$work/bin:$PATH"
+export OCI_TEST_DOCKER_LOG="$work/docker.log"
+export OCI_TEST_HELM_LOG="$work/helm.log"
+
+"$root/tasks/container" \
+ --context "$work/project" \
+ --platform linux/amd64 \
+ --target site \
+ --build-arg APP=site \
+ --build-arg 'TITLE=hello world' \
+ --label 'org.example.title=Example site' \
+ --tag ghcr.io/example/site:sha-abc \
+ --tag ghcr.io/example/site:latest \
+ --cache-scope site \
+ --provenance false \
+ --sbom false \
+ --push
+
+grep -qx -- 'buildx' "$work/docker.log"
+grep -qx -- '--target' "$work/docker.log"
+grep -qx -- 'site' "$work/docker.log"
+grep -qx -- 'TITLE=hello world' "$work/docker.log"
+grep -qx -- 'org.example.title=Example site' "$work/docker.log"
+grep -qx -- 'ghcr.io/example/site:sha-abc' "$work/docker.log"
+grep -qx -- 'ghcr.io/example/site:latest' "$work/docker.log"
+grep -qx -- 'type=gha,mode=max,scope=site' "$work/docker.log"
+grep -qx -- '--push' "$work/docker.log"
+
+"$root/tasks/chart" \
+ --chart "$work/project/chart" \
+ --version 1.2.3 \
+ --app-version sha-abc \
+ --output "$work/output" \
+ --push oci://ghcr.io/example/charts
+
+grep -qx -- 'lint' "$work/helm.log"
+grep -qx -- 'package' "$work/helm.log"
+grep -qx -- 'push' "$work/helm.log"
+grep -qx -- 'oci://ghcr.io/example/charts' "$work/helm.log"
+
+echo 'oci tasks: ok'