|
1 | 1 | name: 📱 E2E iOS (Maestro) |
2 | 2 | on: |
| 3 | + pull_request_review: |
| 4 | + types: [submitted] |
3 | 5 | pull_request: |
4 | 6 | branches: |
5 | 7 | - main |
| 8 | + types: [synchronize, ready_for_review] |
6 | 9 |
|
7 | 10 | concurrency: |
8 | 11 | group: ${{ github.workflow }}-${{ github.ref }} |
9 | 12 | cancel-in-progress: true |
10 | 13 |
|
11 | 14 | 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 | +
|
12 | 52 | maestro-ios: |
13 | 53 | name: 🧪 Maestro smoke tests (iOS sim) |
| 54 | + needs: approval-gate |
| 55 | + if: needs.approval-gate.outputs.approved == 'true' |
14 | 56 | runs-on: macos-15 |
15 | 57 | timeout-minutes: 60 |
16 | 58 | env: |
|
0 commit comments