From 2d1facfb41effea0d5178670029b3f852c78875c Mon Sep 17 00:00:00 2001 From: millianlmx Date: Mon, 20 Jul 2026 09:34:29 +0200 Subject: [PATCH] fix(ci): call scripts/pr_lgtm_scanner.py instead of inline python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inline python3 -c body in wait-approval raised IndentationError: unexpected indent because YAML block scalars dedent content to the first line's indent, leaving the python body with leading whitespace. Replace with a call to scripts/pr_lgtm_scanner.py (added in the previous commit). Add a shallow Checkout step to wait-approval so the script is present on the runner. This is the third indentation fix attempt for this scanner: - column-0 python → YAML parse failure - indented python → Python IndentationError - standalone file → no indentation concerns (this commit) --- .github/workflows/pr-iphone-deploy.yml | 47 ++++++++++---------------- 1 file changed, 18 insertions(+), 29 deletions(-) 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)