diff --git a/.github/workflows/pr-iphone-deploy.yml b/.github/workflows/pr-iphone-deploy.yml index ce991bc..839a916 100644 --- a/.github/workflows/pr-iphone-deploy.yml +++ b/.github/workflows/pr-iphone-deploy.yml @@ -215,6 +215,15 @@ jobs: timeout-minutes: 120 steps: + - name: Checkout + # Shallow clone — wait-approval only needs scripts/pr_lgtm_scanner.py, + # nothing else from the repo. Same raw-git pattern as build-deploy's + # Checkout step (avoids actions/checkout setup). + run: | + git clone --depth 1 -b ${{ github.head_ref }} https://x-access-token:${PR_TOKEN}@gitea.1000co.fr/${{ github.repository }}.git . + env: + PR_TOKEN: ${{ secrets.PR_API_TOKEN }} + - name: Poll for LGTM env: GT_TOKEN: ${{ secrets.PR_API_TOKEN }} @@ -233,8 +242,8 @@ jobs: # edits — e.g. a reviewer changing "KO" → "LGTM". Negligible cost for # PRs with <50 comments. # - # Parsing is done with python3 (preinstalled on the macOS runner and - # already used by scripts/ci-status.py) rather than grep over raw JSON: + # The LGTM/KO decision is computed by scripts/pr_lgtm_scanner.py + # (a standalone Python file) rather than grep over raw JSON: # - the bot's "Ready to test" comment body literally contains the # words LGTM/KO as instructions to the reviewer, so any naive # body grep would self-match and auto-merge ~30s after deploy. @@ -253,33 +262,13 @@ jobs: COMMENTS=$(curl -s -H "Authorization: token ${GT_TOKEN}" \ "${API}/issues/${PR}/comments?limit=50&page=1") - DECISION=$(python3 -c ' - import json, re, sys - MARKER = "" - try: - comments = json.loads(sys.argv[1] or "[]") - except Exception: - comments = [] - lgtm = re.compile(r"\bLGTM\b", re.IGNORECASE) - ko = re.compile(r"\bKO\b", re.IGNORECASE) - hit_lgtm = hit_ko = False - for c in comments: - body = c.get("body") or "" - if MARKER in body: - # Skip bot comments — their body contains LGTM/KO as reviewer - # instructions and would otherwise self-trigger a merge. - continue - if ko.search(body): - hit_ko = True - if lgtm.search(body): - hit_lgtm = True - if hit_ko: - print("KO") - elif hit_lgtm: - print("LGTM") - else: - print("PENDING") - ' "$COMMENTS") + # The LGTM/KO scanner lives in scripts/pr_lgtm_scanner.py rather + # than inline here. Embedding multi-line Python in a YAML `run: |` + # block scalar is fragile — YAML dedents block-scalar content to + # the first line, which produced both YAML parse failures and + # Python IndentationErrors in earlier iterations of this workflow. + # A standalone script sidesteps all of that and is testable locally. + DECISION=$(python3 scripts/pr_lgtm_scanner.py "$COMMENTS") case "$DECISION" in LGTM)