summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2024-04-03 14:54:37 -0400
committerBen Sima <ben@bsima.me>2024-04-03 16:18:12 -0400
commit432739b3e950f3ee33d4f083343b28f7755d0861 (patch)
treef7c6adfb16fe7fdb794a46a292d8599c83c189d3
parent5d15e98e07415803b477efa492e62d59c6ef6ccc (diff)
Enable CI for every commit
Uses git test to run CI on every commit before push.
-rw-r--r--.envrc1
-rwxr-xr-xBiz/Ci.sh59
-rwxr-xr-xBiz/Ide/hooks/pre-push57
3 files changed, 61 insertions, 56 deletions
diff --git a/.envrc b/.envrc
index c816943..05b10d0 100644
--- a/.envrc
+++ b/.envrc
@@ -42,6 +42,7 @@
git config --local branchless.test.alias.bild 'CODEROOT=$PWD bild **/*'
git config --local branchless.test.alias.lint 'CODEROOT=$PWD bild Biz/Lint.hs && _/bin/lint **/*'
git config --local branchless.test.alias.lintfix 'CODEROOT=$PWD bild Biz/Lint.hs && _/bin/lint --fix **/*'
+ git config --local branchless.test.alias.ci 'CODEROOT=$PWD Biz/Ci.sh'
#
# load local settings
. ./.envrc.local
diff --git a/Biz/Ci.sh b/Biz/Ci.sh
new file mode 100755
index 0000000..9dbfd5b
--- /dev/null
+++ b/Biz/Ci.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+#
+# A simple ci that saves its results in a git note, formatted according to
+# RFC-2822, more or less.
+#
+# To run this manually, exec the script. It will by default run the tests for
+# HEAD, whatever you currently have checked out.
+#
+# It would be cool to use a zero-knowledge proof mechanism here to prove that
+# so-and-so ran the tests, but I'll have to research how to do that.
+#
+##
+ set -uo pipefail
+ [[ -n $(git status -s) ]] && { echo fail: dirty worktree; exit 1; }
+##
+ at=$(date -R)
+ user=$(git config --get user.name)
+ mail=$(git config --get user.email)
+##
+ commit=$(git notes --ref=ci show HEAD || true)
+ if [[ -n "$commit" ]]
+ then
+ if grep -q "Lint-is: good" <<< "$commit"
+ then
+ exit 0
+ fi
+ if grep -q "Test-is: good" <<< "$commit"
+ then
+ exit 0
+ fi
+ fi
+##
+ runlint="$CODEROOT"/_/bin/lint
+ [[ ! -f "$runlint" ]] && bild "${BILD_ARGS:-""}" "${CODEROOT:?}"/Biz/Lint.hs
+ if "$runlint" "${CODEROOT:?}"/**/*
+ then
+ lint_result="good"
+ else
+ lint_result="fail"
+ exit 1
+ fi
+##
+ if bild "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/*
+ then
+ test_result="good"
+ else
+ test_result="fail"
+ exit 1
+ fi
+##
+ read -r -d '' note <<EOF
+Lint-is: $lint_result
+Test-is: $test_result
+Test-by: $user <$mail>
+Test-at: $at
+EOF
+##
+ git notes --ref=ci append -m "$note"
+##
diff --git a/Biz/Ide/hooks/pre-push b/Biz/Ide/hooks/pre-push
index eccd4cd..1a47699 100755
--- a/Biz/Ide/hooks/pre-push
+++ b/Biz/Ide/hooks/pre-push
@@ -1,57 +1,2 @@
#!/usr/bin/env bash
-#
-# A simple ci that saves its results in a git note, formatted according to
-# RFC-2822, more or less.
-#
-# To run this manually, exec the script. It will by default run the tests for
-# HEAD, whatever you currently have checked out.
-#
-# It would be cool to use a zero-knowledge proof mechanism here to prove that
-# so-and-so ran the tests, but I'll have to research how to do that.
-#
-##
- set -uo pipefail
- [[ -n $(git status -s) ]] && { echo fail: dirty worktree; exit 1; }
-##
- at=$(date -R)
- user=$(git config --get user.name)
- mail=$(git config --get user.email)
-##
- commit=$(git notes --ref=ci show HEAD || true)
- if [[ -n "$commit" ]]
- then
- if grep -q "Lint-is: good" <<< "$commit"
- then
- exit 0
- fi
- if grep -q "Test-is: good" <<< "$commit"
- then
- exit 0
- fi
- fi
-##
- if lint "${CODEROOT:?}"/**/*
- then
- lint_result="good"
- else
- lint_result="fail"
- exit 1
- fi
-##
- if bild "${BILD_ARGS:-""}" --test "${CODEROOT:?}"/**/*
- then
- test_result="good"
- else
- test_result="fail"
- exit 1
- fi
-##
- read -r -d '' note <<EOF
-Lint-is: $lint_result
-Test-is: $test_result
-Test-by: $user <$mail>
-Test-at: $at
-EOF
-##
- git notes --ref=ci append -m "$note"
-##
+git test run --command ci origin/live..HEAD --no-cache --jobs 5