#!/bin/sh refname="$1" oldrev="$2" newrev="$3" zero=$(guix environment --ad-hoc git -- git hash-object --stdin &2 echo "Creating a new branch, $refname..." span="$newrev" fi if test "x$newrev" = "x$zero" then >&2 echo "Deleting a branch, that's OK." exit 0 fi if test "x$refname" = "xrefs/notes/dist" then >&2 echo "Error: the server does not accept dist notes." exit 1 fi >&2 echo "Checking all refs in range $span." for ref in $(guix environment --ad-hoc git -- git rev-list $span) do # If there is not already a note on the refs/notes/dist ref, then we # should run the CI. >&2 echo "Checking new commit $ref." if git notes --ref="refs/notes/dist" list "$ref" then >&2 echo "CI already ran for $ref, skipping." else >&2 echo "This commit has not seen CI yet." CLONEREPO=$(mktemp -d 2>/dev/null || mktemp -d -t "clone") REPO=$(pwd) cd "$CLONEREPO" guix environment --ad-hoc --pure git -- git clone "$REPO" . guix environment --ad-hoc --container git -- git checkout "$ref" guix environment --ad-hoc --container git -- git checkout-index -a -f --prefix=source/ if OUTCOME=$(guix build -c 4 -L guix -f ci.scm) then cd $REPO export BLOB="$(git hash-object -w $OUTCOME/*.tar.gz)" >&2 echo "Adding blob $BLOB as the results of the CI." guix environment --ad-hoc --container git -- git notes --ref=refs/notes/dist add \ --allow-empty -f -C "$BLOB" "$ref" rm -rf $CLONEREPO else cd $REPO rm -rf $CLONEREPO exit 1 fi fi done