From 2265b6615ee8bae7373a332e35e430e9e0755ed4 Mon Sep 17 00:00:00 2001 From: Charles Hall Date: Fri, 1 Nov 2024 09:15:51 -0700 Subject: [PATCH] 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. --- bin/job | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/job b/bin/job index 7f3ad091..23db0ad7 100755 --- a/bin/job +++ b/bin/job @@ -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 "$@"