run ci for each commit

GitLab doesn't seem to have built-in support for this because of course
it doesn't.

To do this, we move the job scripts to a different file to make it
possible to share code between job scripts.
This commit is contained in:
Charles Hall 2024-11-01 09:15:51 -07:00
parent a5eba45472
commit 2265b6615e
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF

18
bin/job
View file

@ -24,8 +24,9 @@ job_pages() (
bail() (
set -euo pipefail
git show --shortstat
echo
echo "Job failed"
echo "Failure caused by the above commit"
exit 1
)
@ -47,7 +48,20 @@ run() (
cd "$(git rev-parse --show-toplevel)"
job_"$job" || bail
if [[ -z "${CI_MERGE_REQUEST_DIFF_BASE_SHA+x}" ]]; then
echo "Running against latest commit only..."
job_"$job" || bail
else
echo "Running against all commits since this branch's base..."
readarray -t commits < \
<(git rev-list --reverse "$CI_MERGE_REQUEST_DIFF_BASE_SHA..HEAD")
for commit in "${commits[@]}"; do
git checkout "$commit"
job_"$job" || bail
done
fi
)
run "$@"