run some jobs on the final commit only

These are too expensive to be worth running against all commits.
This commit is contained in:
Charles Hall 2024-12-11 11:25:54 -08:00
parent f4dfb496e1
commit 9e3738d330
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF

25
bin/job
View file

@ -49,6 +49,26 @@ commit_passed() (
[[ -f ".gitlab-ci.d/passed/$1/$(git rev-parse HEAD)" ]] [[ -f ".gitlab-ci.d/passed/$1/$(git rev-parse HEAD)" ]]
) )
contains() (
set -euo pipefail
local -n xs=$1
for x in "${xs[@]}"; do
if [[ "$x" == "$2" ]]; then
return 0
else
return 1
fi
done
)
# Jobs that should only run on the latest commit rather than since the branch's
# base.
last_commit_only=(
artifacts
)
run() ( run() (
set -euo pipefail set -euo pipefail
@ -67,7 +87,10 @@ run() (
cd "$(git rev-parse --show-toplevel)" cd "$(git rev-parse --show-toplevel)"
if [[ -z "${CI_MERGE_REQUEST_DIFF_BASE_SHA+x}" ]]; then if \
[[ -z "${CI_MERGE_REQUEST_DIFF_BASE_SHA+x}" ]] \
|| contains last_commit_only "$job"
then
echo "Running against latest commit only..." echo "Running against latest commit only..."
job_"$job" || bail job_"$job" || bail