53 lines
1.7 KiB
Bash
Executable File
53 lines
1.7 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() {
|
|
local want=$1 event=$2 fixture=$3 release=${4:-} got=0
|
|
local -a env=(-u GITHUB_EVENT_NAME -u GITHUB_EVENT_PATH -u RUNNER_RELEASE_ONLY)
|
|
[ -z "$release" ] || env+=("RUNNER_RELEASE_ONLY=$release")
|
|
[ "$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: $event $fixture release=$release exit=$got want=$want" >&2
|
|
fail=1
|
|
fi
|
|
}
|
|
|
|
for e in push workflow_dispatch schedule merge_group release; do
|
|
check 0 "$e" push.json
|
|
done
|
|
check 0 pull_request pr-member.json
|
|
check 0 pull_request pr-same-repo.json
|
|
check 1 pull_request pr-fork-none.json
|
|
check 1 pull_request pr-fork-spoofed.json
|
|
check 1 pull_request pr-deleted-fork.json
|
|
check 1 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 "$e" pr-member.json
|
|
done
|
|
check 1 pull_request_review pr-fork-none.json
|
|
check 1 issue_comment issue-comment.json
|
|
check 1 push -
|
|
check 1 push missing.json
|
|
check 1 push invalid.txt
|
|
check 1 - push.json
|
|
check 0 push tag-push.json
|
|
|
|
check 0 push tag-push.json true
|
|
check 1 push push.json true
|
|
check 1 push tag-push-nov.json true
|
|
for e in pull_request workflow_dispatch schedule merge_group release; do
|
|
check 1 "$e" tag-push.json true
|
|
done
|
|
check 1 pull_request pr-same-repo.json true
|
|
check 1 push - true
|
|
check 1 push invalid.txt true
|
|
check 1 push tag-push.json yes
|
|
|
|
exit "$fail"
|