From 1cdb9d106b5d3df0c46a751dca2e7b7ab8e42c90 Mon Sep 17 00:00:00 2001 From: Vivien Kraus Date: Wed, 1 Jan 2020 00:00:00 +0100 Subject: Set up the project infrastructure --- hooks/ChangeLog | 8 ++++++++ hooks/update | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 hooks/ChangeLog create mode 100755 hooks/update (limited to 'hooks') diff --git a/hooks/ChangeLog b/hooks/ChangeLog new file mode 100644 index 0000000..2a86088 --- /dev/null +++ b/hooks/ChangeLog @@ -0,0 +1,8 @@ +2020-12-04 Vivien Kraus + + * update: build with 4 cores + +2020-11-25 Vivien Kraus + + * pre-commit: Check that the code is indented in the pre-commit hook. + diff --git a/hooks/update b/hooks/update new file mode 100755 index 0000000..1fc463d --- /dev/null +++ b/hooks/update @@ -0,0 +1,58 @@ +#!/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 -- cgit v1.2.3