Compare commits

..
4 Commits
10 changed files with 1129 additions and 3 deletions
+3
View File
@@ -0,0 +1,3 @@
.git
.gitea
out
+233
View File
@@ -0,0 +1,233 @@
name: release
on:
push:
branches: ['**']
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
contents: read
env:
KIND: minio
BIN: minio
PKG: minio
REGISTRY: git.vezha.io
steps:
- name: AC1 checkout the recipe
uses: https://git.vezha.io/actions/checkout@v4
with:
persist-credentials: false
- name: AC2 pins are complete and well formed
id: pins
run: sh vezha/gates.sh pins "$KIND" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_OUTPUT"
- name: AC3 no unpinned reference and workflow lint
run: sh vezha/gates.sh refs "$KIND"
- name: tools docker cli and jq
run: |
command -v docker >/dev/null 2>&1 || { apt-get update -qq; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker.io >/dev/null; }
command -v jq >/dev/null 2>&1 || { apt-get update -qq; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq jq >/dev/null; }
docker version --format 'client {{.Client.Version}} server {{.Server.Version}}'
jq --version
- name: AC1 provenance of the import, anonymous
run: sh vezha/gates.sh provenance-remote
- name: AC1 checkout the pinned upstream source
uses: https://git.vezha.io/actions/checkout@v4
with:
ref: ${{ steps.pins.outputs.UPSTREAM_COMMIT }}
path: src
fetch-depth: 1
persist-credentials: false
- name: AC1 source tree is at the pinned commit
run: sh vezha/gates.sh provenance-src
- name: AC7 source offer URLs answer anonymously
run: sh vezha/gates.sh source-urls
- name: negative controls, every gate must refuse its planted input
run: sh vezha/gates.sh self-test
- name: names and build arguments
run: |
TAG=$(sh vezha/gates.sh make-tag)
{ echo "TAG=$TAG"; echo "IMG=$REGISTRY/para/$PKG:$TAG"; echo "LOCAL=vezha-build-$KIND:$GITHUB_RUN_ID"; } >> "$GITHUB_ENV"
mkdir -p out
sh vezha/gates.sh pins "$KIND" | sed 's/^/--build-arg=/' > out/build-args
echo "tag $TAG"
- name: AC2 pins stage proves the source tree and the module
run: |
mapfile -t ARGS < out/build-args
docker build --target pins -f vezha/Dockerfile "${ARGS[@]}" -t "$LOCAL-pins" .
- name: AC4 build stage and binary hash A
run: |
mapfile -t ARGS < out/build-args
docker build --target build -f vezha/Dockerfile "${ARGS[@]}" -t "$LOCAL-build" .
cid=$(docker create "$LOCAL-build")
docker cp "$cid:/out/$BIN" "out/$BIN.a"
docker cp "$cid:/out/$BIN.sha256" out/sha.a
docker rm "$cid" > /dev/null
A=$(sha256sum "out/$BIN.a" | cut -d' ' -f1)
if [ "$A" != "$(cat out/sha.a)" ]; then
echo "REFUSED build: the extracted binary does not match the build stage's sha file"
exit 1
fi
echo "BINARY_SHA256=$A" >> "$GITHUB_ENV"
echo "binary sha256 A: $A"
- name: AC6 final image and content check
run: |
mapfile -t ARGS < out/build-args
sh vezha/gates.sh render-source vezha/SOURCE.tmpl vezha/SOURCE
docker build -f vezha/Dockerfile "${ARGS[@]}" "--build-arg=RECIPE_COMMIT=$GITHUB_SHA" "--build-arg=BINARY_SHA256=$BINARY_SHA256" -t "$IMG" .
RECIPE_COMMIT="$GITHUB_SHA" sh vezha/check-image.sh "$KIND" "$IMG"
- name: AC4 version output carries the pinned release and commit
run: |
out=$(docker run --rm --label "io.vezha.smoke=$GITHUB_RUN_ID" "$IMG" --version)
echo "$out"
case "$out" in
*"$UPSTREAM_RELEASE"*"commit-id=$UPSTREAM_COMMIT"*) echo "version output names $UPSTREAM_RELEASE and $UPSTREAM_COMMIT" ;;
*) echo "REFUSED version: --version does not name $UPSTREAM_RELEASE and commit-id=$UPSTREAM_COMMIT"; exit 1 ;;
esac
- name: AC5 reproducible, second no-cache build of the build stage
run: |
mapfile -t ARGS < out/build-args
docker build --no-cache --target build -f vezha/Dockerfile "${ARGS[@]}" -t "$LOCAL-build2" .
cid=$(docker create "$LOCAL-build2")
docker cp "$cid:/out/$BIN" "out/$BIN.b"
docker rm "$cid" > /dev/null
B=$(sha256sum "out/$BIN.b" | cut -d' ' -f1)
if [ "$B" != "$BINARY_SHA256" ]; then
echo "REFUSED reproducible: second build has sha256 $B, first has $BINARY_SHA256"
exit 1
fi
echo "both builds have sha256 $B"
- name: AC7 source offer in the image resolves anonymously
run: sh vezha/gates.sh source-offer "$IMG" "$KIND" "$UPSTREAM_RELEASE"
- name: AC4 the mc inside the image is the pinned mc release
run: |
out=$(docker run --rm --entrypoint /usr/bin/mc --label "io.vezha.smoke=$GITHUB_RUN_ID" "$IMG" --version)
echo "$out"
case "$out" in
*RELEASE.2025-08-13T08-35-41Z*) echo "mc --version names RELEASE.2025-08-13T08-35-41Z" ;;
*) echo "REFUSED version: /usr/bin/mc --version does not name RELEASE.2025-08-13T08-35-41Z"; exit 1 ;;
esac
- name: AC8 smoke of the built server with the mc image
run: HEALTH=yes sh vezha/smoke.sh smoke "$IMG" "$MC_IMAGE"
- name: AC9 volume continuity from the stopgap server to the built server
run: sh vezha/smoke.sh continuity git.vezha.io/para/minio@sha256:a1a8bd4ac40ad7881a245bab97323e18f971e4d4cba2c2007ec1bedd21cbaba2 "$IMG" "$MC_IMAGE"
- name: AC10 preflight, write-once tag and the stopgap tags before
run: |
sh vezha/gates.sh preflight "$KIND" "$GITHUB_REF" "${MC_IMAGE:-}"
sh vezha/gates.sh tag "$PKG" "$TAG"
sh vezha/gates.sh stopgap | tee out/stopgap.before
- name: publish tools, pinned syft and oras installed before any login
if: github.ref == 'refs/heads/vezha'
run: |
curl -fsSLO https://github.com/anchore/syft/releases/download/v1.50.0/syft_1.50.0_linux_amd64.tar.gz
echo "bf7b29ff57f06da30918266a0e1c2885a8f99784798d1bdb1628886aa015d788 syft_1.50.0_linux_amd64.tar.gz" | sha256sum -c -
tar -xzf syft_1.50.0_linux_amd64.tar.gz syft
install -m 0755 syft /usr/local/bin/syft
curl -fsSLO https://github.com/oras-project/oras/releases/download/v1.3.3/oras_1.3.3_linux_amd64.tar.gz
echo "9ce999f8d2de03fc03968b29d743077a58783e545e5eaa53917ca177352d0e59 oras_1.3.3_linux_amd64.tar.gz" | sha256sum -c -
tar -xzf oras_1.3.3_linux_amd64.tar.gz oras
install -m 0755 oras /usr/local/bin/oras
syft version
oras version
- name: publish SBOM generated before the image
if: github.ref == 'refs/heads/vezha'
run: |
syft "docker:$IMG" -o "spdx-json=out/sbom.spdx.json"
test -s out/sbom.spdx.json
- name: publish login to the registry
if: github.ref == 'refs/heads/vezha'
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER || github.actor }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
sh vezha/gates.sh login-guard
echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
- name: publish SBOM artifact pushed before the image
if: github.ref == 'refs/heads/vezha'
run: cd out && oras push "$REGISTRY/para/$PKG-sbom:$TAG" --artifact-type application/spdx+json sbom.spdx.json:application/spdx+json
- name: publish the image and cross-check its digest
if: github.ref == 'refs/heads/vezha'
run: |
docker push "$IMG" | tee out/push.log
D=$(sed -n 's/.*digest: \(sha256:[0-9a-f]\{64\}\).*/\1/p' out/push.log | tail -1)
if [ -z "$D" ]; then
echo "REFUSED push: no digest in the push output"
exit 1
fi
R=$(sh vezha/gates.sh digest "$PKG" "$TAG")
if [ "$R" != "$D" ]; then
echo "REFUSED push: docker push printed $D but the registry serves $R for $TAG"
exit 1
fi
echo "DIGEST=$D" >> "$GITHUB_ENV"
- name: publish AC11 digest proof, pull by digest and compare the binary
if: github.ref == 'refs/heads/vezha'
run: |
REF="$REGISTRY/para/$PKG@$DIGEST"
docker rmi "$IMG" > /dev/null
sh vezha/gates.sh prove "$REF" "$BIN" "$BINARY_SHA256"
docker run --rm --label "io.vezha.smoke=$GITHUB_RUN_ID" "$REF" --version
oras pull "$REGISTRY/para/$PKG-sbom:$TAG" -o out/sbom-back
grep -q '"spdxVersion"' out/sbom-back/sbom.spdx.json
echo "the SBOM was pulled back and is SPDX JSON"
- name: publish AC11 the PUBLISHED line
if: github.ref == 'refs/heads/vezha'
run: |
LINE="PUBLISHED $REGISTRY/para/$PKG@$DIGEST tag=$TAG binary-sha256=$BINARY_SHA256"
echo "$LINE" | grep -Eq '^PUBLISHED git\.vezha\.io/para/(minio|minio-mc)@sha256:[0-9a-f]{64} tag=[a-z0-9._-]+ binary-sha256=[0-9a-f]{64}$' || { echo "REFUSED published: malformed line"; exit 1; }
echo "$LINE"
echo "$LINE" > out/published.txt
cd out && oras push "$REGISTRY/para/$PKG-published:$TAG" published.txt:text/plain
- name: publish AC10 stopgap tags unchanged after the run
if: github.ref == 'refs/heads/vezha'
run: |
sh vezha/gates.sh stopgap > out/stopgap.after
diff out/stopgap.before out/stopgap.after
echo "the stopgap tags resolve to the same digests as before the run"
- name: publish AC7 source offer of the pulled digest resolves anonymously
if: github.ref == 'refs/heads/vezha'
run: sh vezha/gates.sh source-offer "$REGISTRY/para/$PKG@$DIGEST" "$KIND" "$UPSTREAM_RELEASE"
- name: cleanup of this run's containers, networks, volumes and images
if: always()
run: |
for c in $(docker ps -aq --filter "label=io.vezha.smoke=$GITHUB_RUN_ID"); do docker rm -f "$c" > /dev/null 2>&1 || true; done
for n in $(docker network ls -q --filter "label=io.vezha.smoke=$GITHUB_RUN_ID"); do docker network rm "$n" > /dev/null 2>&1 || true; done
for v in $(docker volume ls -q --filter "label=io.vezha.smoke=$GITHUB_RUN_ID"); do docker volume rm "$v" > /dev/null 2>&1 || true; done
for i in "${LOCAL:-none}-pins" "${LOCAL:-none}-build" "${LOCAL:-none}-build2" "${IMG:-none}" "${REGISTRY}/para/${PKG}@${DIGEST:-none}"; do docker rmi "$i" > /dev/null 2>&1 || true; done
docker logout "$REGISTRY" > /dev/null 2>&1 || true
+2
View File
@@ -1 +1,3 @@
/src/
/out/
/vezha/SOURCE
+74
View File
@@ -0,0 +1,74 @@
ARG GO_BUILDER
ARG MC_IMAGE
FROM ${GO_BUILDER} AS pins
ARG UPSTREAM_RELEASE
ARG UPSTREAM_COMMIT
ARG MODULE
ARG MODULE_VERSION
ARG MODULE_SUM
ENV GOTOOLCHAIN=local GOFLAGS=-mod=readonly CGO_ENABLED=0 GOOS=linux GOARCH=amd64
COPY src /src
WORKDIR /src
RUN set -eu; \
test "$(git rev-parse HEAD)" = "${UPSTREAM_COMMIT}" || { echo "REFUSED pins: src HEAD is not UPSTREAM_COMMIT"; exit 1; }; \
test -z "$(git status --porcelain)" || { echo "REFUSED pins: src working tree is not clean"; git status --porcelain; exit 1; }; \
test "$(go list -m)" = "${MODULE}" || { echo "REFUSED pins: src module is not MODULE"; exit 1; }; \
scratch="$(mktemp -d)"; \
(cd "${scratch}" && env -u GOFLAGS go mod download -json "${MODULE}@${MODULE_VERSION}" > "${scratch}/module.json"); \
sum="$(sed -n 's/^[[:space:]]*"Sum": "\([^"]*\)".*/\1/p' "${scratch}/module.json")"; \
hash="$(sed -n 's/^[[:space:]]*"Hash": "\([^"]*\)".*/\1/p' "${scratch}/module.json")"; \
test "${sum}" = "${MODULE_SUM}" || { echo "REFUSED pins: module sum is ${sum}, PINS says MODULE_SUM=${MODULE_SUM}"; exit 1; }; \
test "${hash}" = "${UPSTREAM_COMMIT}" || { echo "REFUSED pins: module origin hash is ${hash}, PINS says UPSTREAM_COMMIT=${UPSTREAM_COMMIT}"; exit 1; }; \
go mod download; \
go mod verify
FROM pins AS build
ARG UPSTREAM_RELEASE
ARG UPSTREAM_COMMIT
RUN set -eu; \
LDFLAGS="$(MINIO_RELEASE=RELEASE go run buildscripts/gen-ldflags.go "${UPSTREAM_RELEASE#RELEASE.}")"; \
case "${LDFLAGS}" in *"cmd.ReleaseTag=${UPSTREAM_RELEASE} "*) ;; *) echo "REFUSED build: ldflags lack ReleaseTag=${UPSTREAM_RELEASE}"; exit 1;; esac; \
case "${LDFLAGS}" in *"cmd.CommitID=${UPSTREAM_COMMIT} "*) ;; *) echo "REFUSED build: ldflags lack CommitID=${UPSTREAM_COMMIT}"; exit 1;; esac; \
mkdir -p /out; \
go build -trimpath -tags kqueue -ldflags "${LDFLAGS}" -o /out/minio .; \
go version -m /out/minio > /out/buildinfo.txt; \
grep -Eq "^[[:space:]]+build[[:space:]]+vcs.revision=${UPSTREAM_COMMIT}$" /out/buildinfo.txt || { echo "REFUSED build: vcs.revision is not UPSTREAM_COMMIT"; exit 1; }; \
grep -Eq "^[[:space:]]+build[[:space:]]+vcs.modified=false$" /out/buildinfo.txt || { echo "REFUSED build: vcs.modified is not false"; exit 1; }; \
grep -Eq "^[[:space:]]+build[[:space:]]+-trimpath=true$" /out/buildinfo.txt || { echo "REFUSED build: -trimpath is not true"; exit 1; }; \
grep -Eq "^[[:space:]]+build[[:space:]]+CGO_ENABLED=0$" /out/buildinfo.txt || { echo "REFUSED build: CGO_ENABLED is not 0"; exit 1; }; \
grep -Eq "^[[:space:]]+build[[:space:]]+-tags=kqueue$" /out/buildinfo.txt || { echo "REFUSED build: -tags is not kqueue"; exit 1; }; \
cat /out/buildinfo.txt; \
sha256sum /out/minio | cut -d' ' -f1 > /out/minio.sha256; \
mkdir -p /rootfs/tmp /rootfs/etc; \
chmod 1777 /rootfs/tmp; \
printf 'root:x:0:0:root:/root:/sbin/nologin\n' > /rootfs/etc/passwd; \
printf 'root:x:0:\n' > /rootfs/etc/group
FROM ${MC_IMAGE} AS mc
FROM scratch
ARG UPSTREAM_RELEASE
ARG UPSTREAM_COMMIT
ARG RECIPE_COMMIT
ARG BINARY_SHA256
LABEL org.opencontainers.image.source="https://git.vezha.io/para/minio" \
org.opencontainers.image.revision="${UPSTREAM_COMMIT}" \
org.opencontainers.image.version="${UPSTREAM_RELEASE}" \
org.opencontainers.image.licenses="AGPL-3.0" \
io.vezha.recipe="${RECIPE_COMMIT}" \
io.vezha.binary.sha256="${BINARY_SHA256}"
ENV PATH=/usr/bin MC_CONFIG_DIR=/tmp/.mc
COPY --from=build /rootfs/ /
COPY --from=build /out/minio /usr/bin/minio
COPY --from=mc /usr/bin/mc /usr/bin/mc
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=mc /licenses/ /licenses/mc/
COPY src/LICENSE /licenses/LICENSE
COPY src/CREDITS /licenses/CREDITS
COPY vezha/SOURCE /licenses/SOURCE
EXPOSE 9000
VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/minio"]
CMD ["server", "/data"]
HEALTHCHECK --interval=5s --timeout=5s --retries=10 CMD ["/usr/bin/mc", "ready", "local"]
+7
View File
@@ -0,0 +1,7 @@
UPSTREAM_RELEASE=RELEASE.2025-09-07T16-13-09Z
UPSTREAM_COMMIT=07c3a429bfed433e49018cb0f78a52145d4bedeb
MODULE=github.com/minio/minio
MODULE_VERSION=v0.0.0-20250907161309-07c3a429bfed
MODULE_SUM=h1:deu0m9BiyqnMbGWfJi1PpVyotSXlDnTmRIme1cUXnxo=
GO_BUILDER=golang:1.27.2-trixie@sha256:47667934874913a449b96faa7ef4777fa285d9ec29126ee80ed61c45b7cccf0e
MC_IMAGE=git.vezha.io/para/minio-mc@sha256:eb4ea9884b77704230e2423e9004d2fa738dc272876b9cc41a297d29443b8780
+35 -3
View File
@@ -1,5 +1,37 @@
# vezha build recipe for minio/minio
This branch carries the build recipe for the container image `git.vezha.io/para/minio`.
The upstream source is minio/minio (AGPL-3.0), imported unmodified with all its tags.
The recipe is built up by the commits on the development branch and fast-forwarded here once it is green.
This branch builds the container image `git.vezha.io/para/minio` from the unmodified upstream source of minio/minio, which is archived upstream and no longer publishes images.
The repository is an imported copy of minio/minio with all its tags. The `vezha` branch is an orphan branch that holds only the recipe.
## Licence and source offer (AGPL-3.0)
The image ships the unmodified minio binary and the unmodified mc binary (copied from `git.vezha.io/para/minio-mc`, pinned in `PINS` as `MC_IMAGE`), both licensed under the GNU Affero General Public License v3.
The complete corresponding source of minio is the tag named in `PINS` (`UPSTREAM_RELEASE`) in this public repository:
`https://git.vezha.io/para/minio/src/tag/<UPSTREAM_RELEASE>`.
Each image carries `/licenses/LICENSE`, `/licenses/CREDITS` and `/licenses/SOURCE`, and the mc licence files and source offer under `/licenses/mc/`.
`SOURCE` names the upstream URL, the release and commit, the tag URL, the recipe commit, the builder image digest, the Go module version and sum, and the sha256 of the binary.
Nothing in this recipe patches the upstream source. A patch would make the binary a modified version and would need its own source offer.
## Files
- `PINS`: every pinned input. Builds refuse a missing, empty, duplicated or unknown key.
- `Dockerfile`: stages `pins`, `build`, `mc` and the final scratch image; no BuildKit-only syntax.
- `gates.sh`, `check-image.sh`, `smoke.sh`: the checks the workflow runs; `SOURCE.tmpl` is rendered into `/licenses/SOURCE`.
- `.gitea/workflows/release.yml`: verify on every push, publish on `vezha`.
## Image notes
The image is `FROM scratch`: the minio and mc binaries, the CA bundle, a root-only passwd and group, a world-writable `/tmp`, and the licence files.
It runs as root because the production data volume is root-owned; changing the user would break existing data.
It has `HEALTHCHECK ["/usr/bin/mc","ready","local"]`, `ENV PATH=/usr/bin` and `ENV MC_CONFIG_DIR=/tmp/.mc`, `ENTRYPOINT ["/usr/bin/minio"]`, `CMD ["server","/data"]`, `VOLUME /data` and `EXPOSE 9000`.
The upstream `docker-entrypoint.sh` and its `*_FILE` environment defaults (`MINIO_ROOT_USER_FILE`, `MINIO_ROOT_PASSWORD_FILE`, `MINIO_ACCESS_KEY_FILE`, `MINIO_SECRET_KEY_FILE`, `MINIO_KMS_SECRET_KEY_FILE`, `MINIO_CONFIG_ENV_FILE`) and the user switch variables are not carried: credentials are passed as `MINIO_ROOT_USER` and `MINIO_ROOT_PASSWORD`.
## Release procedure
A run on a branch other than `vezha` builds and verifies only and reads no secret. A run on `vezha` also publishes `git.vezha.io/para/minio:<tag>`, where the tag is `<lowercased UPSTREAM_RELEASE>-<first 12 of UPSTREAM_COMMIT>-r<first 8 of the recipe commit>`.
Tags are write-once, there is no `latest`, and consumers pin by digest. A run on `vezha` refuses an `MC_IMAGE` that is not a `git.vezha.io/para/minio-mc` digest published by the mc recipe. The run prints one line per image:
`PUBLISHED git.vezha.io/para/minio@sha256:<digest> tag=<tag> binary-sha256=<sha256>`
To bump a pin, edit `PINS` on a branch, let the verify run go green, and fast-forward `vezha`; the new commit publishes a new tag.
The publish step needs the repository secret `REGISTRY_TOKEN` (a Gitea token with the `write:package` scope) and optionally `REGISTRY_USER`.
+24
View File
@@ -0,0 +1,24 @@
This image ships MinIO, licensed under the GNU Affero General Public License v3 (AGPL-3.0), unmodified.
It also ships mc (the MinIO Client, AGPL-3.0, unmodified) at /usr/bin/mc; its licence files and source offer are under /licenses/mc/.
Upstream project: https://github.com/minio/minio
Upstream release: @UPSTREAM_RELEASE@
Upstream commit: @UPSTREAM_COMMIT@
Corresponding source at that commit, tagged in this repository:
https://git.vezha.io/para/minio/src/tag/@UPSTREAM_RELEASE@
Source archive of that tag:
https://git.vezha.io/para/minio/archive/@UPSTREAM_RELEASE@.tar.gz
Build recipe repository: https://git.vezha.io/para/minio
Build recipe commit: @RECIPE_COMMIT@
Build recipe at that commit:
https://git.vezha.io/para/minio/src/commit/@RECIPE_COMMIT@
Go builder image: @GO_BUILDER@
Go module: @MODULE@ @MODULE_VERSION@
Go module sum: @MODULE_SUM@
Binary sha256 of /usr/bin/minio: @BINARY_SHA256@
mc image copied into this image: @MC_IMAGE@
The CA bundle /etc/ssl/certs/ca-certificates.crt is copied unmodified from the Go builder image (Debian ca-certificates; source: https://tracker.debian.org/pkg/ca-certificates).
+138
View File
@@ -0,0 +1,138 @@
#!/bin/sh
set -eu
kind=${1:?usage: check-image.sh <mc|minio> <image>}
image=${2:?usage: check-image.sh <mc|minio> <image>}
REGISTRY=git.vezha.io
OWNER=para
STOPGAP_MC_DIGEST=sha256:eb4ea9884b77704230e2423e9004d2fa738dc272876b9cc41a297d29443b8780
fail() {
printf 'REFUSED image: %s\n' "$1" >&2
exit 1
}
for v in UPSTREAM_RELEASE UPSTREAM_COMMIT RECIPE_COMMIT BINARY_SHA256 GO_BUILDER MODULE_VERSION MODULE_SUM; do
eval "val=\${$v:-}"
[ -n "$val" ] || fail "environment variable $v is empty"
done
tmp=$(mktemp -d)
cid=""
cleanup() {
if [ -n "$cid" ]; then
docker rm -f "$cid" > /dev/null 2>&1 || true
fi
rm -rf "$tmp"
}
trap cleanup EXIT
cid=$(docker create "$image")
docker export "$cid" > "$tmp/fs.tar"
tar -tvf "$tmp/fs.tar" | sed 's| link to .*||; s| -> .*||' > "$tmp/list.txt"
docker inspect "$cid" > "$tmp/inspect.json"
mode_of() {
awk -v p="$1" '{ n = $NF; sub(/^\.\//, "", n); sub(/\/$/, "", n); if (n == p) { print $1; exit } }' "$tmp/list.txt"
}
need_file() {
m=$(mode_of "$1")
[ -n "$m" ] || fail "$image has no /$1"
echo "image: /$1 present ($m)"
}
member() {
tar -xOf "$tmp/fs.tar" "$1" 2> /dev/null || tar -xOf "$tmp/fs.tar" "./$1"
}
cfg() {
jq -r "$1" "$tmp/inspect.json"
}
bin=$kind
need_file "usr/bin/$bin"
need_file etc/ssl/certs/ca-certificates.crt
need_file licenses/LICENSE
need_file licenses/CREDITS
need_file licenses/SOURCE
case $kind in
mc)
need_file bin/sh
;;
minio)
need_file usr/bin/mc
need_file etc/passwd
need_file etc/group
need_file licenses/mc/LICENSE
need_file licenses/mc/CREDITS
if [ "${MC_IMAGE:-}" != "$REGISTRY/$OWNER/minio-mc@$STOPGAP_MC_DIGEST" ]; then
need_file licenses/mc/SOURCE
fi
[ "$(mode_of tmp)" = drwxrwxrwt ] || fail "/tmp of $image is not mode 1777"
;;
esac
want_label() {
got=$(cfg ".[0].Config.Labels[\"$1\"] // \"\"")
[ "$got" = "$2" ] || fail "label $1 is '$got', expected '$2'"
echo "image: label $1 = $got"
}
want_label org.opencontainers.image.source "https://$REGISTRY/$OWNER/$kind"
want_label org.opencontainers.image.revision "$UPSTREAM_COMMIT"
want_label org.opencontainers.image.version "$UPSTREAM_RELEASE"
want_label org.opencontainers.image.licenses AGPL-3.0
want_label io.vezha.recipe "$RECIPE_COMMIT"
want_label io.vezha.binary.sha256 "$BINARY_SHA256"
want_cfg() {
got=$(cfg "$1")
[ "$got" = "$2" ] || fail "$3 is '$got', expected '$2'"
echo "image: $3 = $got"
}
user=$(cfg '.[0].Config.User // ""')
case $user in
"" | root | 0) echo "image: runs as root" ;;
*) fail "the image runs as user '$user', expected root" ;;
esac
case $kind in
mc)
want_cfg '.[0].Config.Entrypoint | tostring' '["mc"]' Entrypoint
want_cfg '.[0].Config.Cmd | tostring' 'null' Cmd
want_cfg '.[0].Config.Healthcheck | tostring' 'null' Healthcheck
;;
minio)
want_cfg '.[0].Config.Entrypoint | tostring' '["/usr/bin/minio"]' Entrypoint
want_cfg '.[0].Config.Cmd | tostring' '["server","/data"]' Cmd
want_cfg '.[0].Config.Volumes | keys | tostring' '["/data"]' Volumes
want_cfg '.[0].Config.ExposedPorts | keys | tostring' '["9000/tcp"]' ExposedPorts
want_cfg '.[0].Config.Healthcheck.Test | tostring' '["CMD","/usr/bin/mc","ready","local"]' Healthcheck
want_cfg '[.[0].Config.Env[] | select(. == "MC_CONFIG_DIR=/tmp/.mc")] | length' 1 MC_CONFIG_DIR
want_cfg '[.[0].Config.Env[] | select(. == "PATH=/usr/bin")] | length' 1 PATH
;;
esac
got=$(member "usr/bin/$bin" | sha256sum | cut -d' ' -f1)
[ "$got" = "$BINARY_SHA256" ] || fail "/usr/bin/$bin has sha256 $got, expected $BINARY_SHA256"
echo "image: /usr/bin/$bin sha256 $got"
member licenses/LICENSE | cmp -s - src/LICENSE || fail "/licenses/LICENSE differs from src/LICENSE"
member licenses/CREDITS | cmp -s - src/CREDITS || fail "/licenses/CREDITS differs from src/CREDITS"
member licenses/SOURCE > "$tmp/SOURCE"
for needle in \
"https://github.com/minio/$kind" \
"$UPSTREAM_RELEASE" \
"$UPSTREAM_COMMIT" \
"https://$REGISTRY/$OWNER/$kind/src/tag/$UPSTREAM_RELEASE" \
"https://$REGISTRY/$OWNER/$kind/archive/$UPSTREAM_RELEASE.tar.gz" \
"https://$REGISTRY/$OWNER/$kind/src/commit/$RECIPE_COMMIT" \
"$GO_BUILDER" \
"$MODULE_VERSION" \
"$MODULE_SUM" \
"$BINARY_SHA256"; do
grep -qF "$needle" "$tmp/SOURCE" || fail "/licenses/SOURCE does not name $needle"
done
echo "image: /licenses/SOURCE names the upstream, the tag, the recipe, the builder, the module and the binary"
[ -f .dockerignore ] || fail "no .dockerignore at the repository root"
echo "image: all checks passed for $image"
+426
View File
@@ -0,0 +1,426 @@
#!/bin/sh
set -eu
REGISTRY=git.vezha.io
OWNER=para
STOPGAP_SERVER_TAG=release.2025-09-07t16-13-09z
STOPGAP_SERVER_DIGEST=sha256:a1a8bd4ac40ad7881a245bab97323e18f971e4d4cba2c2007ec1bedd21cbaba2
STOPGAP_MC_TAG=release.2025-08-13t08-35-41z
STOPGAP_MC_DIGEST=sha256:eb4ea9884b77704230e2423e9004d2fa738dc272876b9cc41a297d29443b8780
TAG_RE='^release\.[0-9]{4}-[0-9]{2}-[0-9]{2}t[0-9]{2}-[0-9]{2}-[0-9]{2}z-[0-9a-f]{12}-r[0-9a-f]{8}$'
ACCEPT='application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json'
GUARD="if: github.ref == 'refs/heads/vezha'"
SELF=$0
refuse() {
printf 'REFUSED %s: %s\n' "$1" "$2" >&2
exit 1
}
pin_value() {
sed -n "s/^$1=//p" "$2"
}
anon_head() {
token=$(curl -fsS "https://$REGISTRY/v2/token?service=container_registry&scope=repository:$OWNER/$1:pull" | jq -r .token) || return 1
curl -sS -o /dev/null -D - -H "Authorization: Bearer $token" -H "Accept: $ACCEPT" "https://$REGISTRY/v2/$OWNER/$1/manifests/$2" \
| tr -d '\r' | awk '/^HTTP/ { s = $2 } tolower($1) == "docker-content-digest:" { d = $2 } END { print s, d }'
}
fetch_ok() {
i=0
code=none
while [ "$i" -lt 3 ]; do
code=$(curl -sS -o /dev/null -L -m 900 -w '%{http_code}' "$1" || true)
if [ "$code" = 200 ]; then
return 0
fi
i=$((i + 1))
sleep 5
done
echo "$1 answered $code" >&2
return 1
}
cmd_pins() {
kind=$1
file=${2:-vezha/PINS}
case $kind in
mc) last=BASE_IMAGE ;;
minio) last=MC_IMAGE ;;
*) refuse pins "unknown kind $kind" ;;
esac
keys="UPSTREAM_RELEASE UPSTREAM_COMMIT MODULE MODULE_VERSION MODULE_SUM GO_BUILDER $last"
[ -f "$file" ] || refuse pins "$file is missing"
n=0
while IFS= read -r line || [ -n "$line" ]; do
n=$((n + 1))
if printf '%s' "$line" | grep -q '[[:space:]"'"'"']'; then
refuse pins "line $n contains a space or a quote"
fi
printf '%s' "$line" | grep -Eq '^[A-Z_]+=' || refuse pins "line $n is not KEY=VALUE"
k=${line%%=*}
known=0
for x in $keys; do
if [ "$x" = "$k" ]; then
known=1
fi
done
[ "$known" = 1 ] || refuse pins "unknown key $k"
done < "$file"
for k in $keys; do
c=$(grep -c "^$k=" "$file" || true)
[ "$c" -ge 1 ] || refuse pins "missing key $k"
[ "$c" -le 1 ] || refuse pins "duplicate key $k"
[ -n "$(pin_value "$k" "$file")" ] || refuse pins "empty value for key $k"
done
shape() {
printf '%s' "$(pin_value "$1" "$file")" | grep -Eq "$2" || refuse pins "key $1 has an unexpected form"
}
shape UPSTREAM_RELEASE '^RELEASE\.[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}-[0-9]{2}-[0-9]{2}Z$'
shape UPSTREAM_COMMIT '^[0-9a-f]{40}$'
shape MODULE "^github\\.com/minio/$kind\$"
shape MODULE_VERSION '^v0\.0\.0-[0-9]{14}-[0-9a-f]{12}$'
shape MODULE_SUM '^h1:[A-Za-z0-9+/]{43}=$'
for k in $keys; do
printf '%s=%s\n' "$k" "$(pin_value "$k" "$file")"
done
}
wf_lint() {
f=$1
if grep -q 'pull_request' "$f"; then
refuse refs "the workflow has a pull_request trigger"
fi
if grep -n 'latest' "$f" | grep -v 'ubuntu-latest'; then
refuse refs "the workflow mentions latest (lines above)"
fi
grep -q '^ contents: read$' "$f" || refuse refs "permissions contents: read is missing"
awk -v g="$GUARD" '
function flush() {
if (name == "") return
if (secret) secretsteps++
if ((risky || secret) && !guarded) {
printf "REFUSED refs: step \"%s\" can push or read a secret and has no vezha-ref guard\n", name > "/dev/stderr"
bad = 1
}
}
/^ - name: / { flush(); name = $0; sub(/^ - name: /, "", name); risky = 0; secret = 0; guarded = 0 }
/docker login|docker push|oras push/ { risky = 1 }
/secrets\./ { secret = 1 }
index($0, g) { guarded = 1 }
END {
flush()
if (secretsteps != 1) {
printf "REFUSED refs: secrets. appears in %d steps, expected exactly 1\n", secretsteps > "/dev/stderr"
bad = 1
}
exit bad
}
' "$f" || exit 1
}
cmd_wf_lint() {
wf_lint "${1:-.gitea/workflows/release.yml}"
}
cmd_refs() {
kind=$1
df=vezha/Dockerfile
pins=vezha/PINS
case $kind in
mc) last=BASE_IMAGE ;;
minio) last=MC_IMAGE ;;
*) refuse refs "unknown kind $kind" ;;
esac
if grep -nE '^ARG[[:space:]]+[A-Za-z_][A-Za-z0-9_]*=' "$df"; then
refuse refs "a Dockerfile ARG has a default (lines above)"
fi
for k in GO_BUILDER $last; do
printf '%s' "$(pin_value "$k" "$pins")" | grep -Eq '^[^@[:space:]]+@sha256:[0-9a-f]{64}$' || refuse refs "$k is not pinned by @sha256 digest"
done
if [ "$kind" = minio ]; then
printf '%s' "$(pin_value MC_IMAGE "$pins")" | grep -Eq "^$REGISTRY/$OWNER/minio-mc@sha256:[0-9a-f]{64}\$" || refuse refs "MC_IMAGE is not $REGISTRY/$OWNER/minio-mc@sha256:<digest>"
fi
stages=""
while IFS= read -r line; do
case $line in
FROM\ *) ;;
*) continue ;;
esac
# shellcheck disable=SC2086
set -- $line
shift
case $1 in --*) refuse refs "FROM option $1 is not allowed" ;; esac
img=$1
case $img in
scratch) ;;
'${GO_BUILDER}' | '${BASE_IMAGE}' | '${MC_IMAGE}')
var=${img#\$\{}
var=${var%\}}
[ "$var" = GO_BUILDER ] || [ "$var" = "$last" ] || refuse refs "FROM uses $var which is not a pinned image key of this repo"
;;
*@sha256:*)
printf '%s' "$img" | grep -Eq '@sha256:[0-9a-f]{64}$' || refuse refs "FROM $img has a malformed digest"
;;
*)
found=0
for s in $stages; do
if [ "$s" = "$img" ]; then
found=1
fi
done
[ "$found" = 1 ] || refuse refs "FROM $img is not pinned by digest"
;;
esac
if [ "${2:-}" = AS ]; then
stages="$stages $3"
fi
done < "$df"
for f in $(grep -oE '^COPY[[:space:]]+--from=[^[:space:]]+' "$df" | sed 's/.*--from=//'); do
case $f in
*'$'*) refuse refs "COPY --from=$f takes a variable" ;;
esac
found=0
for s in $stages; do
if [ "$s" = "$f" ]; then
found=1
fi
done
[ "$found" = 1 ] || refuse refs "COPY --from=$f is not a stage of this Dockerfile"
done
wf_lint .gitea/workflows/release.yml
}
cmd_provenance_remote() {
: "${GITHUB_REPOSITORY:?}" "${UPSTREAM_RELEASE:?}" "${UPSTREAM_COMMIT:?}"
body=$(curl -fsS "https://$REGISTRY/api/v1/repos/$GITHUB_REPOSITORY") || refuse provenance "anonymous GET of the repository failed"
[ "$(printf '%s' "$body" | jq -r .private)" = false ] || refuse provenance "the repository is not public"
[ "$(printf '%s' "$body" | jq -r .has_actions)" = true ] || refuse provenance "the repository has no actions"
[ "$(printf '%s' "$body" | jq -r .default_branch)" = vezha ] || refuse provenance "the default branch is not vezha"
got=$(GIT_TERMINAL_PROMPT=0 git ls-remote "https://$REGISTRY/$GITHUB_REPOSITORY" "refs/tags/${UPSTREAM_RELEASE}^{}" | cut -f1)
[ "$got" = "$UPSTREAM_COMMIT" ] || refuse provenance "tag $UPSTREAM_RELEASE resolves to '$got' but PINS says UPSTREAM_COMMIT=$UPSTREAM_COMMIT"
echo "provenance: tag $UPSTREAM_RELEASE resolves to $got"
}
cmd_provenance_src() {
: "${UPSTREAM_COMMIT:?}"
head=$(git -C src rev-parse HEAD)
[ "$head" = "$UPSTREAM_COMMIT" ] || refuse provenance "src HEAD is $head but PINS says UPSTREAM_COMMIT=$UPSTREAM_COMMIT"
echo "provenance: src HEAD is $head"
}
cmd_source_urls() {
: "${GITHUB_REPOSITORY:?}" "${UPSTREAM_RELEASE:?}"
for u in "https://$REGISTRY/$GITHUB_REPOSITORY/src/tag/$UPSTREAM_RELEASE" "https://$REGISTRY/$GITHUB_REPOSITORY/archive/$UPSTREAM_RELEASE.tar.gz"; do
fetch_ok "$u" || refuse source-urls "anonymous fetch of $u failed"
echo "source-urls: $u -> 200"
done
}
cmd_make_tag() {
: "${UPSTREAM_RELEASE:?}" "${UPSTREAM_COMMIT:?}" "${GITHUB_SHA:?}"
lower=$(printf '%s' "$UPSTREAM_RELEASE" | tr 'A-Z' 'a-z')
printf '%s-%s-r%s\n' "$lower" "$(printf '%s' "$UPSTREAM_COMMIT" | cut -c1-12)" "$(printf '%s' "$GITHUB_SHA" | cut -c1-8)"
}
cmd_tag() {
pkg=$1
tag=$2
case $tag in
"$STOPGAP_SERVER_TAG" | "$STOPGAP_MC_TAG") refuse tag "$tag is a stopgap tag and is never written" ;;
esac
printf '%s' "$tag" | grep -Eq "$TAG_RE" || refuse tag "$tag does not have the immutable tag form"
r=$(anon_head "$pkg" "$tag") || refuse tag "the anonymous registry token request failed"
case ${r%% *} in
404) echo "tag: $pkg:$tag does not exist yet" ;;
200) refuse tag "$pkg:$tag already exists, tags are write-once" ;;
*) refuse tag "the registry answered ${r%% *} for $pkg:$tag" ;;
esac
}
cmd_digest() {
r=$(anon_head "$1" "$2") || refuse digest "the anonymous registry token request failed"
[ "${r%% *}" = 200 ] || refuse digest "the registry answered ${r%% *} for $1:$2"
printf '%s\n' "${r#* }"
}
cmd_stopgap() {
s=$(anon_head minio "$STOPGAP_SERVER_TAG") || refuse stopgap "the anonymous registry token request failed"
m=$(anon_head minio-mc "$STOPGAP_MC_TAG") || refuse stopgap "the anonymous registry token request failed"
[ "${s#* }" = "$STOPGAP_SERVER_DIGEST" ] || refuse stopgap "minio:$STOPGAP_SERVER_TAG resolves to '${s#* }'"
[ "${m#* }" = "$STOPGAP_MC_DIGEST" ] || refuse stopgap "minio-mc:$STOPGAP_MC_TAG resolves to '${m#* }'"
echo "minio:$STOPGAP_SERVER_TAG ${s#* }"
echo "minio-mc:$STOPGAP_MC_TAG ${m#* }"
}
cmd_preflight() {
kind=$1
ref=$2
mc_image=${3:-}
[ "$kind" = minio ] || return 0
[ "$ref" = refs/heads/vezha ] || return 0
printf '%s' "$mc_image" | grep -Eq "^$REGISTRY/$OWNER/minio-mc@sha256:[0-9a-f]{64}\$" || refuse preflight "MC_IMAGE '$mc_image' is not $REGISTRY/$OWNER/minio-mc@sha256:<digest>"
[ "$mc_image" != "$REGISTRY/$OWNER/minio-mc@$STOPGAP_MC_DIGEST" ] || refuse preflight "MC_IMAGE is the stopgap digest, which is never published from vezha"
}
cmd_login_guard() {
[ -n "${REGISTRY_TOKEN:-}" ] || {
echo "::error::REGISTRY_TOKEN secret is not set. Create a Gitea PAT with write:package scope and add it under repo Settings, Actions, Secrets."
refuse login-guard "REGISTRY_TOKEN is not set"
}
}
cmd_put_denied() {
[ "$1" -ne 0 ] || refuse put-denied "the read-only user's PUT succeeded"
grep -Eqi 'access denied|insufficient permissions' "$2" || refuse put-denied "the PUT failed but not with Access Denied"
}
cmd_prove() {
ref=$1
bin=$2
want=$3
docker pull "$ref" > /dev/null || refuse prove "pull of $ref failed"
cid=$(docker create "$ref") || refuse prove "docker create of $ref failed"
tmp=$(mktemp -d)
if ! docker cp "$cid:/usr/bin/$bin" "$tmp/$bin" > /dev/null; then
docker rm -f "$cid" > /dev/null
refuse prove "no /usr/bin/$bin in $ref"
fi
label=$(docker inspect -f '{{index .Config.Labels "io.vezha.binary.sha256"}}' "$cid")
docker rm -f "$cid" > /dev/null
got=$(sha256sum "$tmp/$bin" | cut -d' ' -f1)
rm -rf "$tmp"
[ "$got" = "$want" ] || refuse prove "/usr/bin/$bin in $ref has sha256 $got, expected $want"
[ "$label" = "$want" ] || refuse prove "label io.vezha.binary.sha256 of $ref is '$label', expected $want"
echo "prove: $ref carries /usr/bin/$bin with sha256 $got"
}
cmd_render_source() {
tmpl=$1
out=$2
sed \
-e "s|@UPSTREAM_RELEASE@|$UPSTREAM_RELEASE|g" \
-e "s|@UPSTREAM_COMMIT@|$UPSTREAM_COMMIT|g" \
-e "s|@RECIPE_COMMIT@|$GITHUB_SHA|g" \
-e "s|@GO_BUILDER@|$GO_BUILDER|g" \
-e "s|@MODULE@|$MODULE|g" \
-e "s|@MODULE_VERSION@|$MODULE_VERSION|g" \
-e "s|@MODULE_SUM@|$MODULE_SUM|g" \
-e "s|@BINARY_SHA256@|$BINARY_SHA256|g" \
-e "s|@BASE_IMAGE@|${BASE_IMAGE:-none}|g" \
-e "s|@MC_IMAGE@|${MC_IMAGE:-none}|g" \
"$tmpl" > "$out"
if grep -n '@[A-Z_0-9]*@' "$out"; then
refuse render-source "an unrendered placeholder remains (lines above)"
fi
}
cmd_source_offer() {
image=$1
repo=$2
release=$3
cid=$(docker create "$image") || refuse source-offer "docker create of $image failed"
tmp=$(mktemp -d)
if ! docker cp "$cid:/licenses" "$tmp/licenses" > /dev/null; then
docker rm -f "$cid" > /dev/null
refuse source-offer "$image has no /licenses"
fi
docker rm -f "$cid" > /dev/null
tagurl="https://$REGISTRY/$OWNER/$repo/src/tag/$release"
grep -qF "$tagurl" "$tmp/licenses/SOURCE" || refuse source-offer "/licenses/SOURCE does not name $tagurl"
urls=$(grep -rohE "https://$REGISTRY/[^[:space:])>\"']+" "$tmp/licenses" | sort -u)
[ -n "$urls" ] || refuse source-offer "no $REGISTRY URL in /licenses"
for u in $urls; do
fetch_ok "$u" || refuse source-offer "anonymous fetch of $u failed"
echo "source-offer: $u -> 200"
done
rm -rf "$tmp"
}
control() {
name=$1
gate=$2
shift 2
if out=$("$@" 2>&1); then
echo "CONTROL FAILED: $name was accepted" >&2
exit 1
fi
printf '%s' "$out" | grep -q "REFUSED $gate:" || {
echo "CONTROL FAILED: $name was refused without the REFUSED $gate message: $out" >&2
exit 1
}
echo "control ok: $name refused"
}
accept() {
name=$1
shift
"$@" > /dev/null 2>&1 || {
echo "CONTROL FAILED: $name was refused" >&2
exit 1
}
echo "control ok: $name accepted"
}
cmd_self_test() {
tmp=$(mktemp -d)
mc_stop="$REGISTRY/$OWNER/minio-mc@$STOPGAP_MC_DIGEST"
control "stopgap server tag" tag sh "$SELF" tag minio "$STOPGAP_SERVER_TAG"
control "stopgap mc tag" tag sh "$SELF" tag minio-mc "$STOPGAP_MC_TAG"
control "moving tag" tag sh "$SELF" tag minio-mc latest
control "stopgap digest as MC_IMAGE on vezha" preflight sh "$SELF" preflight minio refs/heads/vezha "$mc_stop"
control "tag form MC_IMAGE on vezha" preflight sh "$SELF" preflight minio refs/heads/vezha "$REGISTRY/$OWNER/minio-mc:$STOPGAP_MC_TAG"
control "empty MC_IMAGE on vezha" preflight sh "$SELF" preflight minio refs/heads/vezha ""
accept "stopgap MC_IMAGE off vezha" sh "$SELF" preflight minio refs/heads/dev/x "$mc_stop"
control "pull-by-digest of a different manifest" prove sh "$SELF" prove "$mc_stop" mc 0000000000000000000000000000000000000000000000000000000000000000
control "empty REGISTRY_TOKEN" login-guard env REGISTRY_TOKEN= sh "$SELF" login-guard
accept "set REGISTRY_TOKEN" env REGISTRY_TOKEN=present sh "$SELF" login-guard
printf 'mc: <ERROR> Unable to put. Access Denied.\n' > "$tmp/denied.txt"
printf 'done\n' > "$tmp/ok.txt"
control "allowed PUT" put-denied sh "$SELF" put-denied 0 "$tmp/ok.txt"
control "PUT that failed for another reason" put-denied sh "$SELF" put-denied 1 "$tmp/ok.txt"
accept "denied PUT" sh "$SELF" put-denied 1 "$tmp/denied.txt"
printf 'mc: <ERROR> Unable to write to one or more targets. Insufficient permissions to access this path.\n' > "$tmp/insufficient.txt"
accept "PUT refused for insufficient permissions" sh "$SELF" put-denied 1 "$tmp/insufficient.txt"
if [ -n "$(pin_value BASE_IMAGE vezha/PINS)" ]; then
kind=mc
last=BASE_IMAGE
else
kind=minio
last=MC_IMAGE
fi
for k in UPSTREAM_RELEASE UPSTREAM_COMMIT MODULE MODULE_VERSION MODULE_SUM GO_BUILDER $last; do
grep -v "^$k=" vezha/PINS > "$tmp/pins.missing" || true
sed "s|^$k=.*|$k=|" vezha/PINS > "$tmp/pins.empty"
control "PINS without $k" pins sh "$SELF" pins "$kind" "$tmp/pins.missing"
control "PINS with empty $k" pins sh "$SELF" pins "$kind" "$tmp/pins.empty"
done
printf 'on:\n pull_request:\njobs:\n' > "$tmp/wf.pr"
control "workflow with a pull_request trigger" refs sh "$SELF" wf-lint "$tmp/wf.pr"
rm -rf "$tmp"
echo "self-test: every control behaved"
}
cmd=${1:?usage: gates.sh <command> [args]}
shift
case $cmd in
pins) cmd_pins "$@" ;;
refs) cmd_refs "$@" ;;
wf-lint) cmd_wf_lint "$@" ;;
provenance-remote) cmd_provenance_remote ;;
provenance-src) cmd_provenance_src ;;
source-urls) cmd_source_urls ;;
make-tag) cmd_make_tag ;;
tag) cmd_tag "$@" ;;
digest) cmd_digest "$@" ;;
stopgap) cmd_stopgap ;;
preflight) cmd_preflight "$@" ;;
login-guard) cmd_login_guard ;;
put-denied) cmd_put_denied "$@" ;;
prove) cmd_prove "$@" ;;
render-source) cmd_render_source "$@" ;;
source-offer) cmd_source_offer "$@" ;;
self-test) cmd_self_test ;;
*) refuse usage "unknown command $cmd" ;;
esac
+187
View File
@@ -0,0 +1,187 @@
#!/bin/sh
set -eu
mode=${1:?usage: smoke.sh smoke <server image> <client image> | smoke.sh continuity <old server image> <new server image> <client image>}
shift
run=${GITHUB_RUN_ID:-local}
suffix=$$
LABEL="io.vezha.smoke=$run"
NET="vezha-smoke-$run-$suffix"
VOL="vezha-smoke-$run-$suffix-data"
SRV="vezha-smoke-$run-$suffix-srv"
GATES=$(dirname "$0")/gates.sh
T=$(mktemp -d)
fail() {
printf 'REFUSED smoke: %s\n' "$1" >&2
exit 1
}
cleanup() {
docker rm -f "$SRV" > /dev/null 2>&1 || true
docker network rm "$NET" > /dev/null 2>&1 || true
docker volume rm "$VOL" > /dev/null 2>&1 || true
rm -rf "$T"
}
trap cleanup EXIT
rand() {
head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n'
}
U=$(rand | cut -c1-16)
P=$(rand)
RO_SECRET=$(rand)
echo "::add-mask::$U"
echo "::add-mask::$P"
echo "::add-mask::$RO_SECRET"
docker network create --label "$LABEL" "$NET" > /dev/null
docker volume create --label "$LABEL" "$VOL" > /dev/null
start_server() {
docker run -d --name "$SRV" --label "$LABEL" --network "$NET" --network-alias minio \
-e "MINIO_ROOT_USER=$U" -e "MINIO_ROOT_PASSWORD=$P" -v "$VOL:/data" \
"$1" server /data --console-address :9001 > /dev/null
i=0
until docker exec "$SRV" mc ready local > /dev/null 2>&1; do
i=$((i + 1))
if [ "$i" -gt 60 ]; then
docker logs "$SRV" >&2 || true
fail "mc ready local did not succeed within 60 seconds for $1"
fi
sleep 1
done
echo "smoke: $1 is ready after $i seconds"
}
stop_server() {
docker stop "$SRV" > /dev/null
docker logs "$SRV" > "$T/$1.log" 2>&1
docker rm "$SRV" > /dev/null
}
mcr() {
docker run --rm --label "$LABEL" --network "$NET" -e "MC_HOST_s=http://$U:$P@minio:9000" "$CLIENT" "$@"
}
mcr_in() {
docker run --rm -i --label "$LABEL" --network "$NET" -e "MC_HOST_s=http://$U:$P@minio:9000" "$CLIENT" "$@"
}
mcr_ro() {
docker run --rm --label "$LABEL" --network "$NET" -e "MC_HOST_r=http://rouser:$RO_SECRET@minio:9000" "$CLIENT" "$@"
}
mcr_ro_in() {
docker run --rm -i --label "$LABEL" --network "$NET" -e "MC_HOST_r=http://rouser:$RO_SECRET@minio:9000" "$CLIENT" "$@"
}
sha_of() {
sha256sum "$1" | cut -d' ' -f1
}
make_objects() {
head -c 1048576 /dev/urandom > "$T/o1"
head -c 1048576 /dev/urandom > "$T/o2"
S1=$(sha_of "$T/o1")
S2=$(sha_of "$T/o2")
[ "$S1" != "$S2" ] || fail "the two random objects are equal"
}
write_two_versions() {
mcr mb s/vbkt
mcr version enable s/vbkt
mcr_in pipe s/vbkt/key < "$T/o1"
mcr_in pipe s/vbkt/key < "$T/o2"
}
read_back_versions() {
got=$(mcr cat s/vbkt/key | sha256sum | cut -d' ' -f1)
[ "$got" = "$S2" ] || fail "cat of the key is $got, expected the second object $S2"
mcr ls --versions --json s/vbkt/key > "$T/ls.json"
count=$(jq -s '[.[] | select(.versionId != null)] | length' "$T/ls.json")
[ "$count" = 2 ] || fail "ls --versions shows $count versions, expected 2"
distinct=$(jq -s '[.[] | select(.versionId != null) | .versionId] | unique | length' "$T/ls.json")
[ "$distinct" = 2 ] || fail "the two versions share a versionId"
found=""
for id in $(jq -rs '.[] | select(.versionId != null) | .versionId' "$T/ls.json"); do
got=$(mcr cat --version-id "$id" s/vbkt/key | sha256sum | cut -d' ' -f1)
echo "smoke: version $id has sha256 $got"
found="$found $got"
done
case $found in
*"$S1"*) ;;
*) fail "no version of the key reads back as the first object $S1" ;;
esac
case $found in
*"$S2"*) ;;
*) fail "no version of the key reads back as the second object $S2" ;;
esac
echo "smoke: both versions read back by versionId with matching sha256"
}
case $mode in
smoke)
SERVER=${1:?server image}
CLIENT=${2:?client image}
make_objects
start_server "$SERVER"
if [ "${HEALTH:-no}" = yes ]; then
i=0
until [ "$(docker inspect -f '{{.State.Health.Status}}' "$SRV")" = healthy ]; do
i=$((i + 1))
[ "$i" -le 60 ] || fail "the image HEALTHCHECK did not reach healthy within 60 seconds"
sleep 1
done
echo "smoke: the image HEALTHCHECK is healthy"
fi
write_two_versions
read_back_versions
mcr admin user add s rouser "$RO_SECRET" > /dev/null
mcr admin policy attach s readonly --user rouser > /dev/null
got=$(mcr_ro cat r/vbkt/key | sha256sum | cut -d' ' -f1)
[ "$got" = "$S2" ] || fail "the read-only user cannot read the key"
code=0
mcr_ro_in pipe r/vbkt/denied < "$T/o1" > "$T/put.out" 2>&1 || code=$?
echo "smoke: the read-only PUT exited $code with:"
cat "$T/put.out"
sh "$GATES" put-denied "$code" "$T/put.out"
echo "smoke: the read-only user's PUT is denied"
for n in 1 2; do
docker run --rm --label "$LABEL" --network "$NET" --entrypoint /bin/sh "$CLIENT" -c "
mc alias set local http://minio:9000 $U $P &&
mc mb --ignore-existing local/leasevibe-attachments &&
echo 'bucket ready';
" > /dev/null || fail "the minio-init script failed on run $n"
echo "smoke: minio-init run $n exited 0"
done
;;
continuity)
OLD=${1:?old server image}
NEW=${2:?new server image}
CLIENT=${3:?client image}
make_objects
start_server "$OLD"
write_two_versions
read_back_versions
stop_server old
start_server "$NEW"
read_back_versions
stop_server new
echo "--- first-start log of the old server"
cat "$T/old.log"
echo "--- start log of the new server on the same volume"
cat "$T/new.log"
grep -q 'Formatting' "$T/old.log" || fail "the old server's first-start log has no Formatting line, the re-format assertion would be vacuous"
if grep -q 'Formatting' "$T/new.log"; then
fail "the new server re-formatted the volume"
fi
echo "smoke: the new server started on the old volume without formatting it"
;;
*)
fail "unknown mode $mode"
;;
esac
echo "smoke: all assertions passed"