From 7464357787178621cb1f1b5fff03c0939d88f9bb Mon Sep 17 00:00:00 2001 From: millianlmx Date: Fri, 26 Jun 2026 22:27:13 +0000 Subject: [PATCH] fix: remove arch -arm64 from xcodegen (runner already handles it) --- .gitea/workflows/pr-iphone-deploy.yml | 2 +- _create_pr.py | 36 +++++++++ hermes-verify-workflow.sh | 103 ++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 _create_pr.py create mode 100644 hermes-verify-workflow.sh diff --git a/.gitea/workflows/pr-iphone-deploy.yml b/.gitea/workflows/pr-iphone-deploy.yml index e588ec1..2cc3978 100644 --- a/.gitea/workflows/pr-iphone-deploy.yml +++ b/.gitea/workflows/pr-iphone-deploy.yml @@ -37,7 +37,7 @@ jobs: xcodebuild -version - name: Install xcodegen - run: arch -arm64 brew install xcodegen + run: brew install xcodegen - name: Generate Xcode project run: | diff --git a/_create_pr.py b/_create_pr.py new file mode 100644 index 0000000..09e19c4 --- /dev/null +++ b/_create_pr.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +import subprocess, json, sys + +# Get the token from git remote +remote = subprocess.run( + ["git", "remote", "get-url", "origin"], + capture_output=True, text=True, cwd="/opt/data/projects/tabatago" +).stdout.strip() + +# Extract token from https://TOKEN@gitea.1000co.fr/... +token = remote.split("@")[0].replace("https://", "") + +# Make API call +import urllib.request + +url = "https://gitea.1000co.fr/api/v1/repos/millianlmx/tabatago/pulls" +data = json.dumps({ + "title": "ci: add iPhone deploy workflow + CI/CD setup docs", + "body": "## Summary\n\nAdds CI/CD pipeline for automatic iPhone deployment on PR.\n\n### Changes\n- **.gitea/workflows/pr-iphone-deploy.yml**: Builds TabataGo for iPhone, installs on device, posts Ready to test comment, waits for LGTM/KO, auto-merges\n- **docs/ci-cd-setup.md**: Mac runner + secrets setup guide\n\n### Secrets required\n- `IPHONE_UDID` - target device UDID\n- `GITEA_TOKEN` - Gitea API token\n\nRuns on: `macos` runner", + "head": "ci/iphone-deploy-workflow", + "base": "main" +}).encode() + +req = urllib.request.Request(url, data=data, method="POST") +req.add_header("Authorization", f"token {token}") +req.add_header("Content-Type", "application/json") + +try: + with urllib.request.urlopen(req) as resp: + result = json.loads(resp.read()) + print(f"✅ PR created: #{result.get('number')} - {result.get('html_url', result.get('url', ''))}") + print(json.dumps(result, indent=2)) +except urllib.error.HTTPError as e: + err = e.read().decode() + print(f"❌ HTTP {e.code}: {err}") + sys.exit(1) diff --git a/hermes-verify-workflow.sh b/hermes-verify-workflow.sh new file mode 100644 index 0000000..a6355b5 --- /dev/null +++ b/hermes-verify-workflow.sh @@ -0,0 +1,103 @@ +#!/bin/bash +# Hermes verification: tabatago iPhone deploy workflow +PASS=0 +FAIL=0 + +REPO=/opt/data/projects/tabatago +WF="$REPO/.gitea/workflows/pr-iphone-deploy.yml" +DOCS="$REPO/docs/ci-cd-setup.md" + +pass() { PASS=$((PASS + 1)); echo "PASS"; } +fail() { FAIL=$((FAIL + 1)); echo "FAIL"; } + +echo "=== Hermes Verify: iPhone Deploy Workflow ===" + +echo -n "[1] Workflow exists: " +test -f "$WF" && pass || fail + +echo -n "[2] Workflow has pull_request trigger: " +grep -q 'pull_request:' "$WF" && pass || fail + +echo -n "[3] Workflow has build-deploy job: " +grep -q 'build-deploy' "$WF" && pass || fail + +echo -n "[4] Workflow has wait-approval job: " +grep -q 'wait-approval' "$WF" && pass || fail + +echo -n "[5] runs-on macos: " +grep -q 'runs-on: macos' "$WF" && pass || fail + +echo -n "[6] xcodegen generate: " +grep -q 'xcodegen generate' "$WF" && pass || fail + +echo -n "[7] TabataGo scheme: " +grep -q 'TabataGo' "$WF" && pass || fail + +echo -n "[8] IPHONE_UDID secret: " +grep -q 'IPHONE_UDID' "$WF" && pass || fail + +echo -n "[9] GITEA_TOKEN secret: " +grep -q 'GITEA_TOKEN' "$WF" && pass || fail + +echo -n "[10] LGTM polling: " +grep -q 'LGTM' "$WF" && pass || fail + +echo -n "[11] Merge logic: " +grep -qi 'merge' "$WF" && pass || fail + +echo -n "[12] Docs exist: " +test -f "$DOCS" && pass || fail + +echo -n "[13] Docs covers macOS: " +grep -q 'macOS' "$DOCS" && pass || fail + +echo -n "[14] Docs covers IPHONE_UDID: " +grep -q 'IPHONE_UDID' "$DOCS" && pass || fail + +echo -n "[15] Docs covers GITEA_TOKEN: " +grep -q 'GITEA_TOKEN' "$DOCS" && pass || fail + +echo -n "[16] Docs covers Troubleshooting: " +grep -q 'Troubleshooting' "$DOCS" && pass || fail + +echo -n "[17] PR open on Gitea: " +PR_CHECK=$(python3 -c " +import subprocess, json, urllib.request +remote = subprocess.run(['git','-C','$REPO','remote','get-url','origin'], capture_output=True, text=True).stdout.strip() +token = remote.split('@')[0].replace('https://', '') +req = urllib.request.Request( + 'https://gitea.1000co.fr/api/v1/repos/millianlmx/tabatago/pulls?state=open&head=ci/iphone-deploy-workflow', + headers={'Authorization': f'token {token}'} +) +with urllib.request.urlopen(req) as resp: + prs = json.loads(resp.read()) +pr = prs[0] +print(f'{pr[\"number\"]}|{pr[\"mergeable\"]}|{pr[\"base\"][\"ref\"]}') +" 2>/dev/null) + +PR_NUM=$(echo "$PR_CHECK" | cut -d'|' -f1) +if [ -n "$PR_NUM" ]; then + echo "PASS (##$PR_NUM)" && PASS=$((PASS + 1)) +else + echo "FAIL" && FAIL=$((FAIL + 1)) +fi + +echo -n "[18] PR mergeable: " +MERGEABLE=$(echo "$PR_CHECK" | cut -d'|' -f2) +if [ "$MERGEABLE" = "True" ]; then + echo "PASS" && PASS=$((PASS + 1)) +else + echo "FAIL (got: $MERGEABLE)" && FAIL=$((FAIL + 1)) +fi + +echo -n "[19] PR targets main: " +BASE=$(echo "$PR_CHECK" | cut -d'|' -f3) +if [ "$BASE" = "main" ]; then + echo "PASS" && PASS=$((PASS + 1)) +else + echo "FAIL (got: $BASE)" && FAIL=$((FAIL + 1)) +fi + +echo "=========================================" +echo "Results: $PASS passed, $FAIL failed" +if [ "$FAIL" -gt 0 ]; then exit 1; else echo "=== ALL VERIFICATIONS PASSED ==="; fi