#!/bin/sh set -eu root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) catalog="$root/catalog/maidn-node-static-image.yaml" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT step() { awk -v name="$1" ' $0 == " - name: " name { found=1 } found && $0 ~ /^ - name: / && $0 != " - name: " name { exit } found { print } ' "$catalog" } [ "$(grep -c '^apiVersion: tekton.dev/v1$' "$catalog")" -eq 1 ] [ "$(grep -c '^kind: Task$' "$catalog")" -eq 1 ] grep -qF 'runAsNonRoot: true' "$catalog" grep -qF 'maidn.io/maidncli-pipeline-task: build-and-push' "$catalog" grep -qF 'workspace=artifacts' "$catalog" for param in url revision image output-directory build-configuration base-image target-directory; do grep -qF " - name: $param" "$catalog" done grep -qF ' - name: artifacts' "$catalog" ! grep -qF 'maidn-git-clone' "$catalog" ! grep -qF 'maidn-node-static-build' "$catalog" ! grep -qF 'maidn-node-static-push' "$catalog" step clone > "$tmp/clone" step build-layer > "$tmp/build-layer" step validate-push-inputs > "$tmp/validate-push-inputs" step push > "$tmp/push" grep -qF 'emptyDir: {}' "$catalog" grep -qF 'secretName: forgejo-git-credentials' "$catalog" grep -qF 'mountPath: /var/run/secrets/forgejo-git-credentials' "$tmp/clone" grep -qF 'GIT_ASKPASS=/tmp/git-askpass GIT_TERMINAL_PROMPT=0 git clone "$REPOSITORY_URL" "$SOURCE_PATH"' "$tmp/clone" ! grep -qF 'registry-credentials' "$tmp/clone" ! grep -qF 'forgejo-git-credentials' "$tmp/build-layer" ! grep -qF 'GIT_CREDENTIALS_PATH' "$tmp/build-layer" ! grep -qF 'registry-credentials' "$tmp/build-layer" grep -qF 'value: --max-old-space-size=384' "$tmp/build-layer" grep -qF 'memory: 256Mi' "$tmp/build-layer" grep -qF 'memory: 512Mi' "$tmp/build-layer" grep -qF 'tar -C "$layer_dir" -cf "$ARTIFACT_PATH/layer.tar" "$target_path"' "$tmp/build-layer" grep -qF 'for memory_peak_path in /sys/fs/cgroup/memory.peak /sys/fs/cgroup/memory/memory.max_usage_in_bytes; do' "$tmp/build-layer" grep -qF "if [ -r \"\$memory_peak_path\" ] && memory_peak=\$(cat \"\$memory_peak_path\"); then" "$tmp/build-layer" grep -qF 'image: alpine:3.21.3' "$tmp/validate-push-inputs" grep -qF 'case "$IMAGE" in git.pingu.pw/*) ;; *) exit 1 ;; esac' "$tmp/validate-push-inputs" ! grep -qF 'forgejo-git-credentials' "$tmp/validate-push-inputs" grep -qF 'image: gcr.io/go-containerregistry/crane:v0.21.7' "$tmp/push" grep -qF 'mountPath: /tekton/home/.docker' "$tmp/push" grep -qF ' - --new_layer=$(workspaces.artifacts.path)/layer.tar' "$tmp/push" ! grep -qF 'forgejo-git-credentials' "$tmp/push" kubectl kustomize "$root/catalog" > "$tmp/catalog.yaml" [ "$(grep -c '^kind: Task$' "$tmp/catalog.yaml")" -eq 2 ] grep -qF ' name: maidn-node-static-image' "$tmp/catalog.yaml"