Files
sharedinbox/.forgejo/workflows/ci.yml
T
Thomas Guettler b5e607df66 fix(ci): make wait-time + LAST_DEPLOYED_SHA lookups use real Forgejo API
The previous CI fixes (#522, #524) replaced /actions/tasks with
/actions/runs in the wait-time steps but did not update the field
lookups. Runs use index_in_repo + created; tasks use run_number +
created_at. The mismatch meant every wait-time step silently printed
"unknown (API lookup failed)" — harmless on its own, but it signalled
that the surrounding deploy/website change-detection logic was also
calling endpoints that do not exist on Forgejo.

The check-changes job's LAST_DEPLOYED_SHA python iterated up to 285
successful runs, calling /actions/runs/{run_id}/jobs for each — but
Forgejo's API has no such endpoint, so every call 404'd. urllib was
also called with no timeout, so on slow/transient Codeberg responses
the script could hang past the 5-minute job timeout. That is what
caused "Detect Changed Files" to start failing every hour from
run #2165 onward (issue #527).

Switch both classes of API call to endpoints Forgejo actually serves:

- Wait-time steps: query /actions/runs?run_number=\$RUN_NUMBER (the
  swagger-documented filter) which returns one run; read the run's
  created field. Add --max-time 30 and || true so a transient API
  failure cannot fail the step.
- LAST_DEPLOYED_SHA: query /actions/tasks?status=success&limit=100 once
  and filter client-side for the specific job (Build & Deploy to Play
  Store / Build & Update Website) under the right workflow_id. Task
  records expose head_sha, so no second per-run lookup is needed. Pass
  timeout=60 to urlopen so the step cannot hang.

Verified against the live Codeberg API: wait-time returns the actual
queued timestamp for run #2173, and LAST_DEPLOYED_SHA resolves to the
expected most-recent successful Play Store / Website deploy SHA.

Closes #527
2026-06-07 11:58:38 +00:00

40 lines
1.3 KiB
YAML

name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
name: Full Project Check
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Print runner wait time
env:
FORGEJO_TOKEN: ${{ github.token }}
RUN_NUMBER: ${{ github.run_number }}
run: |
runner_start=$(date +%s)
created=$(curl -sf --max-time 30 \
-H "Authorization: token $FORGEJO_TOKEN" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runs?run_number=$RUN_NUMBER" \
| python3 -c "import sys,json;rs=json.load(sys.stdin).get('workflow_runs',[]);print(rs[0]['created'] if rs else '')" 2>/dev/null) || true
if [ -n "$created" ]; then
queued_epoch=$(date -d "$created" +%s)
wait_seconds=$((runner_start - queued_epoch))
echo "Runner wait time: ${wait_seconds}s (queued at $created)"
else
echo "Runner wait time: unknown (API lookup failed)"
fi
- uses: actions/checkout@v4
- name: Setup Dagger Remote Engine
env:
SOPS_AGE_KEY: ${{ secrets.SOPS_AGE_KEY }}
run: scripts/setup_dagger_remote.sh
- name: Run Full Check Suite
run: task check-dagger