diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 55e3453..6a9f76f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -295,6 +295,49 @@ jobs: --checklist-confirmed \ --checklist-categories 1,2,3,4,5,6,7,8,9,10,11,12,13 \ --body "Auto-approved: all CI checks passed (validate, molecule-tests)." + - name: Wait for molecule tests to complete + env: + CI_GITEA_API_TOKEN: ${{ secrets.CI_GITEA_API_TOKEN }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + . .venv/bin/activate 2>/dev/null || true + # Poll commit status until all required checks pass or fail + MAX_WAIT=600 # 10 minutes + ELAPSED=0 + while [ $ELAPSED -lt $MAX_WAIT ]; do + STATUS=$(curl -s -H "Authorization: token $CI_GITEA_API_TOKEN" \ + "https://git.oblachno.oblachno.fyi/api/v1/repos/${{ github.repository }}/commits/$HEAD_SHA/status" \ + | python3 -c " + import sys,json + d=json.load(sys.stdin) + statuses={s['context']:s['status'] for s in d.get('statuses',[])} + # Check if all molecule-tests contexts are terminal (success/failure) + mol_contexts=[k for k in statuses if 'molecule-tests' in k] + if not mol_contexts: + print('pending') + elif all(statuses[k] in ('success','failure') for k in mol_contexts): + if any(statuses[k]=='failure' for k in mol_contexts): + print('failure') + else: + print('success') + else: + print('pending') + ") + echo "Molecule tests status: $STATUS (elapsed: ${ELAPSED}s)" + if [ "$STATUS" = "success" ]; then + echo "All molecule tests passed." + break + elif [ "$STATUS" = "failure" ]; then + echo "ERROR: Molecule tests failed. Aborting auto-merge." + exit 1 + fi + sleep 30 + ELAPSED=$((ELAPSED + 30)) + done + if [ $ELAPSED -ge $MAX_WAIT ]; then + echo "ERROR: Timed out waiting for molecule tests." + exit 1 + fi - name: Squash merge with task ID env: CI_GITEA_API_TOKEN: ${{ secrets.CI_GITEA_API_TOKEN }}