Files
argocd-apps/ci/test-runner-hooks.sh
T
unkin-agent ef2e6f2c80 add iuclabs-release tag-only runner scale set (#589)
IUCLabs release workflows must upload to artifactapi, which the default runner set cannot reach. A separate tag-only scale set keeps that access away from branch and PR jobs.

- add `iuclabs-release` scale set (0-2 runners) with `RUNNER_MODE=release`; `iuclabs-k8s` sets `RUNNER_MODE=default`
- job-started hook refuses any job when `RUNNER_MODE` is unset, empty or unknown
- release mode allows only `push` of `refs/tags/v[0-9]*`
- release egress allows traefik-internal pods on 443, which reaches every internal gateway host, not only artifactapi; L4 cannot narrow it and the alternative is plain HTTP to the api pods carrying a bearer token
- hook tests cover both modes and missing/invalid mode

Reviewed-on: #589
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
2026-11-18 23:00:05 +11:00

61 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
hook=apps/base/iuclabs-runners/job-started.sh
fixtures=ci/fixtures/runner-hooks
fail=0
# check <want> <mode|unset> <event|-> <fixture|->
check() {
local want=$1 mode=$2 event=$3 fixture=$4 got=0
local -a env=(-u GITHUB_EVENT_NAME -u GITHUB_EVENT_PATH -u RUNNER_MODE)
[ "$mode" = unset ] || env+=("RUNNER_MODE=$mode")
[ "$event" = - ] || env+=("GITHUB_EVENT_NAME=$event")
[ "$fixture" = - ] || env+=("GITHUB_EVENT_PATH=$fixtures/$fixture")
env "${env[@]}" "$hook" >/dev/null 2>&1 || got=1
if [ "$got" -ne "$want" ]; then
echo "FAIL: mode=$mode $event $fixture exit=$got want=$want" >&2
fail=1
fi
}
for m in unset "" bogus true Default; do
check 1 "$m" push push.json
check 1 "$m" push tag-push.json
check 1 "$m" pull_request pr-member.json
done
for e in push workflow_dispatch schedule merge_group release; do
check 0 default "$e" push.json
done
check 0 default pull_request pr-member.json
check 0 default pull_request pr-same-repo.json
check 1 default pull_request pr-fork-none.json
check 1 default pull_request pr-fork-spoofed.json
check 1 default pull_request pr-deleted-fork.json
check 1 default pull_request push.json
for e in pull_request_target workflow_run pull_request_review pull_request_review_comment issue_comment issues discussion discussion_comment create delete unknown_event; do
check 1 default "$e" pr-member.json
done
check 1 default pull_request_review pr-fork-none.json
check 1 default issue_comment issue-comment.json
check 1 default push -
check 1 default push missing.json
check 1 default push invalid.txt
check 1 default - push.json
check 0 default push tag-push.json
check 0 release push tag-push.json
check 1 release push tag-push-vagrant.json
check 1 release push tag-push-nov.json
check 1 release push push.json
for e in pull_request pull_request_target workflow_dispatch schedule merge_group release workflow_run issue_comment create unknown_event; do
check 1 release "$e" tag-push.json
done
check 1 release pull_request pr-same-repo.json
check 1 release - tag-push.json
check 1 release push -
check 1 release push invalid.txt
exit "$fail"