fix(ci): pr-iphone-deploy.yml fails to parse — indent python3 body inside run: | (#14)
Some checks failed
CI / Deploy (push) Has been cancelled
Admin Web Docker / Docker Build Validation (push) Has been cancelled
Admin Web Docker / Semantic Release (push) Has been cancelled
Admin Web Docker / Build & Push Docker Image (push) Has been cancelled
Admin Web Docker / Admin Web Tests (push) Has been cancelled
CI / Detect Changes (push) Has been cancelled
CI / YouTube Worker (push) Has been cancelled
Some checks failed
CI / Deploy (push) Has been cancelled
Admin Web Docker / Docker Build Validation (push) Has been cancelled
Admin Web Docker / Semantic Release (push) Has been cancelled
Admin Web Docker / Build & Push Docker Image (push) Has been cancelled
Admin Web Docker / Admin Web Tests (push) Has been cancelled
CI / Detect Changes (push) Has been cancelled
CI / YouTube Worker (push) Has been cancelled
This commit was merged in pull request #14.
This commit is contained in:
48
.github/workflows/pr-iphone-deploy.yml
vendored
48
.github/workflows/pr-iphone-deploy.yml
vendored
@@ -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,34 +262,13 @@ jobs:
|
||||
COMMENTS=$(curl -s -H "Authorization: token ${GT_TOKEN}" \
|
||||
"${API}/issues/${PR}/comments?limit=50&page=1")
|
||||
|
||||
DECISION=$(python3 - "$COMMENTS" <<'PY'
|
||||
import json, re, sys
|
||||
MARKER = "<!-- tabatago:ready-to-test -->"
|
||||
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 the bot's own "Ready to test" comment — its body mentions
|
||||
# LGTM/KO as instructions and would otherwise self-trigger.
|
||||
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")
|
||||
PY
|
||||
)
|
||||
# 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)
|
||||
|
||||
Reference in New Issue
Block a user