Skip to content

Commit 20fe64b

Browse files
committed
ci: gate E2E iOS on PR approval
Adds an approval-gate job that checks whether the PR has at least one APPROVED review. The expensive macos-15 build job only runs when that gate passes (either via a fresh approval submission, or on subsequent commits to an already-approved PR). This avoids burning macOS runner minutes on every push to feature branches, while still keeping the check required for merge.
1 parent d4c550a commit 20fe64b

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/e2e-ios.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,58 @@
11
name: 📱 E2E iOS (Maestro)
22
on:
3+
pull_request_review:
4+
types: [submitted]
35
pull_request:
46
branches:
57
- main
8+
types: [synchronize, ready_for_review]
69

710
concurrency:
811
group: ${{ github.workflow }}-${{ github.ref }}
912
cancel-in-progress: true
1013

1114
jobs:
15+
# Only run the (expensive) macOS build once a reviewer has approved the PR,
16+
# or on subsequent commits to a PR that already has an approval.
17+
approval-gate:
18+
name: 🔐 Approval gate
19+
runs-on: ubuntu-latest
20+
outputs:
21+
approved: ${{ steps.check.outputs.approved }}
22+
steps:
23+
- name: Check for approval
24+
id: check
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
PR_NUM="${{ github.event.pull_request.number || github.event.review.pull_request.number }}"
29+
if [ -z "$PR_NUM" ]; then
30+
echo "No PR number; skipping."
31+
echo "approved=false" >> "$GITHUB_OUTPUT"
32+
exit 0
33+
fi
34+
# If this run was triggered by a review submission, check it's an approval.
35+
if [ "${{ github.event_name }}" = "pull_request_review" ] && [ "${{ github.event.review.state }}" != "approved" ]; then
36+
echo "Review state is ${{ github.event.review.state }}, not approved."
37+
echo "approved=false" >> "$GITHUB_OUTPUT"
38+
exit 0
39+
fi
40+
# Otherwise look up the latest review per reviewer on this PR.
41+
STATE=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUM/reviews" \
42+
--jq '[.[] | select(.state=="APPROVED" or .state=="CHANGES_REQUESTED")] | sort_by(.submitted_at) | last | .state' \
43+
|| echo "")
44+
if [ "$STATE" = "APPROVED" ]; then
45+
echo "PR is approved."
46+
echo "approved=true" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "PR has no APPROVED review yet (latest review: ${STATE:-none}). Skipping E2E."
49+
echo "approved=false" >> "$GITHUB_OUTPUT"
50+
fi
51+
1252
maestro-ios:
1353
name: 🧪 Maestro smoke tests (iOS sim)
54+
needs: approval-gate
55+
if: needs.approval-gate.outputs.approved == 'true'
1456
runs-on: macos-15
1557
timeout-minutes: 60
1658
env:

0 commit comments

Comments
 (0)