a163c26860
The IUCLabs terraform repos plan/apply from GitHub Actions, but the existing scale sets only reach public :443 and Vault, so they cannot reach the Consul state backend or the internal provider endpoints.
- add `iuclabs-infra` scale set (runs-on `iuclabs-infra`, max 2 runners)
- add `infra` hook mode allowing only IUCLabs/terraform-{git,vault,artifactapi,authentik,binarylane}
- allow egress to Consul, Vault, traefik-internal/external, rke2-ingress-nginx, authentik-server and public :443
- extend runner hook tests for the infra mode
Reviewed-on: #591
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
75 lines
2.8 KiB
Bash
Executable File
75 lines
2.8 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|-> [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 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
|
|
|
|
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 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
|
|
|
|
exit "$fail"
|