fix: something
runner nix smoke / nix label and flake smoke (push) Canceled after 0s

This commit is contained in:
2026-10-03 16:21:28 +00:00
parent be4ea774b2
commit 69ee136349
3 changed files with 76 additions and 7 deletions
@@ -508,7 +508,7 @@ gcr_sweep_stale_runners() {
case "$allowed_repo" in
*/\*)
owner="${allowed_repo%/*}"
repos="$(gcr_gitea_list_org_repos "$owner")" || {
repos="$(gcr_gitea_list_owner_repos "$owner")" || {
IFS=,
continue
}
+34 -6
View File
@@ -61,21 +61,49 @@ gcr_gitea_list_runners() {
done
}
# gcr_gitea_list_org_repos OWNER — prints fully-qualified repository names.
gcr_gitea_list_org_repos() {
# gcr_gitea_list_owner_repos OWNER — prints fully-qualified repository names.
# Allowed owner globs may refer to either organizations or users. Probe the
# organization route first, then use the user route on a confirmed 404.
gcr_gitea_list_owner_repos() {
owner="$1"
gcr_gitea_admin_token >/dev/null || return 1
owner_kind=orgs
page=1
while :; do
repos="$(gcr_gitea_curl -fsS \
"$GCR_GITEA_URL/api/v1/orgs/$owner/repos?page=$page&limit=50")" || return 1
printf '%s' "$repos" | jq -r '.[]? | .full_name'
count="$(printf '%s' "$repos" | jq 'length')" || return 1
owner_page="$(mktemp "${TMPDIR:-/tmp}/gcr-owner-repos.XXXXXX")" \
|| return 1
owner_status="$(gcr_gitea_curl -sS -o "$owner_page" -w '%{http_code}' \
"$GCR_GITEA_URL/api/v1/$owner_kind/$owner/repos?page=$page&limit=50")" \
|| { rm -f "$owner_page"; return 1; }
if [ "$owner_status" = 404 ] && [ "$owner_kind" = orgs ] && [ "$page" = 1 ]; then
owner_kind=users
rm -f "$owner_page"
continue
fi
[ "$owner_status" = 200 ] || {
rm -f "$owner_page"
return 1
}
jq -e 'type == "array"' "$owner_page" >/dev/null || {
rm -f "$owner_page"
return 1
}
jq -r '.[] | .full_name' "$owner_page"
count="$(jq 'length' "$owner_page")" || {
rm -f "$owner_page"
return 1
}
rm -f "$owner_page"
[ "$count" -lt 50 ] && return 0
page=$((page + 1))
done
}
# Compatibility name for callers outside active controller path.
gcr_gitea_list_org_repos() {
gcr_gitea_list_owner_repos "$1"
}
# gcr_gitea_job_state REPO JOB_ID — prints "<status>:<conclusion>".
gcr_gitea_job_state() {
repo="$1"; job_id="$2"
@@ -0,0 +1,41 @@
#!/bin/dash
set -eu
. "$LOG_SH"
. "$GITEA_SH"
export GITEA_ADMIN_TOKEN_FILE="$GCR_STATE_DIR/admin-token"
export GCR_GITEA_URL='https://gitea.example.test'
printf 'test-token\n' > "$GITEA_ADMIN_TOKEN_FILE"
gcr_gitea_admin_token() { printf 'test-token'; }
gcr_gitea_curl() {
output=""
previous=""
for arg do
if [ "$previous" = -o ]; then
output="$arg"
fi
previous="$arg"
done
case "$*" in
*'/orgs/yukkop/repos'*)
: > "$output"
printf '404'
;;
*'/users/yukkop/repos'*)
printf '[{"full_name":"yukkop/project"}]\n' > "$output"
printf '200'
;;
*'/orgs/hectic-lab/repos'*)
printf '[{"full_name":"hectic-lab/util.nix"}]\n' > "$output"
printf '200'
;;
*)
return 1
;;
esac
}
test "$(gcr_gitea_list_owner_repos yukkop)" = 'yukkop/project'
test "$(gcr_gitea_list_owner_repos hectic-lab)" = 'hectic-lab/util.nix'