fix: improve iOS CI workflow with pipefail, fix Python indentation, add setup docs

- Add set -o pipefail for proper build error detection
- Replace PIPESTATUS with $? (works correctly with pipefail)
- Fix Python indentation in inline scripts (avoids YAML linter false positives)
- Remove MergeTitle from Gitea merge API call (uses default)
- Add docs/ci-cd-setup.md with Mac runner and secrets setup guide
This commit is contained in:
2026-06-26 20:42:58 +00:00
parent 87e0610a62
commit c1cbc02826
2 changed files with 330 additions and 35 deletions

View File

@@ -55,14 +55,15 @@ jobs:
cd tabatago-swift
xcodegen generate
- name: Build & Install on iPhone
- name: Build for iPhone
env:
IPHONE_UDID: ${{ secrets.IPHONE_UDID }}
run: |
cd tabatago-swift
# Build for device (build only — installation requires USB/OTA tooling)
# Use tee to capture full output while still streaming to stdout
# Use tee to capture full log while showing last 40 lines on stdout
set -o pipefail
xcodebuild build \
-scheme TabataGo \
-sdk iphoneos \
@@ -74,7 +75,7 @@ jobs:
CODE_SIGN_STYLE=Automatic \
2>&1 | tee ../build/xcodebuild.log | tail -40
BUILD_EXIT=${PIPESTATUS[0]}
BUILD_EXIT=$?
if [ $BUILD_EXIT -ne 0 ]; then
echo ""
echo "❌ Build FAILED (exit code: $BUILD_EXIT)"
@@ -95,7 +96,7 @@ jobs:
REPO="${{ github.repository }}"
RESP=$(curl -sk -w "\n%{http_code}" -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Authorization: token $GITEA_TOKEN \
-H "Content-Type: application/json" \
-d '{"body":"## 📱 Prêt à tester !\n\nL'"'"'app a été buildée pour ton iPhone.\n\n- Teste les changements\n- Reply **LGTM** pour merger\n- Reply **KO** pour bloquer"}' \
"${GITEA_HOST}/api/v1/repos/${REPO}/issues/${PR}/comments")
@@ -136,7 +137,7 @@ jobs:
# Récupérer le dernier ID de commentaire existant comme point de départ
LAST_ID=$(curl -sk \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Authorization: token $GITEA_TOKEN \
"${API}/issues/${PR_NUMBER}/comments" | \
python3 -c "import json,sys; cs=json.load(sys.stdin); print(cs[-1]['id'] if isinstance(cs,list) and cs else 0)" 2>/dev/null || echo 0)
@@ -150,7 +151,7 @@ jobs:
# Récupérer tous les commentaires
COMMENTS=$(curl -sk \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Authorization: token $GITEA_TOKEN \
"${API}/issues/${PR_NUMBER}/comments" 2>/dev/null)
if [ -z "$COMMENTS" ]; then
@@ -159,12 +160,12 @@ jobs:
# Vérifier les nouveaux commentaires (ID > LAST_ID)
NEW_COMMENTS=$(echo "$COMMENTS" | python3 -c "
import json, sys
last_id = $LAST_ID
cs = json.load(sys.stdin)
new = [c for c in cs if isinstance(c, dict) and c.get('id', 0) > last_id]
print(json.dumps(new))
" 2>/dev/null)
import json, sys
last_id = $LAST_ID
cs = json.load(sys.stdin)
new = [c for c in cs if isinstance(c, dict) and c.get('id', 0) > last_id]
print(json.dumps(new))
" 2>/dev/null)
if [ -z "$NEW_COMMENTS" ] || [ "$NEW_COMMENTS" = "[]" ]; then
# Petit heartbeat toutes les 2 min
@@ -176,28 +177,28 @@ print(json.dumps(new))
# Mettre à jour LAST_ID au plus récent
LAST_ID=$(echo "$COMMENTS" | python3 -c "
import json, sys
cs = json.load(sys.stdin)
ids = [c['id'] for c in cs if isinstance(c, dict)]
print(max(ids) if ids else 0)
" 2>/dev/null || echo "$LAST_ID")
import json, sys
cs = json.load(sys.stdin)
ids = [c['id'] for c in cs if isinstance(c, dict)]
print(max(ids) if ids else 0)
" 2>/dev/null || echo "$LAST_ID")
# Vérifier LGTM (insensible à la casse, dans le texte du commentaire)
if echo "$NEW_COMMENTS" | python3 -c "
import json, sys
cs = json.load(sys.stdin)
for c in cs:
body = c.get('body', '')
if 'lgtm' in body.strip().lower():
print('MATCH')
break
" 2>/dev/null | grep -q MATCH; then
import json, sys
cs = json.load(sys.stdin)
for c in cs:
body = c.get('body', '')
if 'lgtm' in body.strip().lower():
print('MATCH')
break
" 2>/dev/null | grep -q MATCH; then
echo ""
echo "✅ LGTM reçu ! Merge de la PR..."
MERGE_RESP=$(curl -sk -w "\n%{http_code}" -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Authorization: token $GITEA_TOKEN \
-H "Content-Type: application/json" \
-d "{\"Do\":\"merge\",\"MergeTitle\":\"${{ github.event.pull_request.title }}\"}" \
-d "{\"Do\":\"merge\"}" \
"${API}/pulls/${PR_NUMBER}/merge")
MERGE_HTTP=$(echo "$MERGE_RESP" | tail -1)
@@ -214,14 +215,14 @@ for c in cs:
# Vérifier KO (insensible à la casse)
if echo "$NEW_COMMENTS" | python3 -c "
import json, sys
cs = json.load(sys.stdin)
for c in cs:
body = c.get('body', '')
if body.strip().lower() == 'ko':
print('MATCH')
break
" 2>/dev/null | grep -q MATCH; then
import json, sys
cs = json.load(sys.stdin)
for c in cs:
body = c.get('body', '')
if body.strip().lower() == 'ko':
print('MATCH')
break
" 2>/dev/null | grep -q MATCH; then
echo ""
echo "❌ KO reçu. PR bloquée."
exit 1