#!/usr/bin/env bash set -euo pipefail hook=apps/base/iuclabs-runners/job-started.sh fixtures=ci/fixtures/runner-hooks fail=0 # check [repo] check() { local want=$1 mode=$2 event=$3 fixture=$4 repo=${5:-} got=0 local -a env=(-u GITHUB_EVENT_NAME -u GITHUB_EVENT_PATH -u GITHUB_REPOSITORY -u RUNNER_MODE) [ -z "$repo" ] || env+=("GITHUB_REPOSITORY=$repo") [ "$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 $repo 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 1 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 for r in terraform-git terraform-vault terraform-artifactapi terraform-authentik terraform-binarylane; do check 0 infra push push.json "IUCLabs/$r" check 0 infra pull_request pr-same-repo.json "IUCLabs/$r" check 1 infra pull_request pr-fork-none.json "IUCLabs/$r" check 1 infra pull_request pr-member.json "IUCLabs/$r" check 1 infra issue_comment issue-comment.json "IUCLabs/$r" done for r in IUCLabs/app IUCLabs/terraform-netbox iuclabs/terraform-git evil/terraform-git IUCLabs/terraform-git-x "IUCLabs/terraform-git "; do check 1 infra push push.json "$r" done check 1 infra push push.json check 1 infra push - IUCLabs/terraform-vault check 0 default push push.json IUCLabs/terraform-vault for r in rpmbuilder container-agent-base container-agent-dev container-agent-infra container-base container-gobuilder container-opentofu container-postfix container-rpmbuilder container-tea; do check 0 build push push.json "IUCLabs/$r" check 0 build pull_request pr-same-repo.json "IUCLabs/$r" check 1 build pull_request pr-fork-none.json "IUCLabs/$r" check 1 build issue_comment issue-comment.json "IUCLabs/$r" done for r in IUCLabs/terraform-git IUCLabs/container-evil iuclabs/rpmbuilder evil/rpmbuilder IUCLabs/rpmbuilder-x "IUCLabs/rpmbuilder "; do check 1 build push push.json "$r" done check 1 build push push.json check 1 build push - IUCLabs/rpmbuilder exit "$fail"