-
Notifications
You must be signed in to change notification settings - Fork 1.5k
198 lines (179 loc) · 6.52 KB
/
Copy pathbuild-pr.yml
File metadata and controls
198 lines (179 loc) · 6.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Build PR
on:
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
run-eslint-and-test:
name: ESLint and Test
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
permissions:
contents: read
uses: ./.github/workflows/eslint.yml
generate-pr-changelog:
name: Generate PR Changelog
needs: [run-eslint-and-test]
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Generate changelog
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr view "${{ github.event.pull_request.number }}" --json title,number,commits > pr.json
node .github/scripts/changelog.js pr
- name: Upload changelog artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: release-changelog
path: changelog.txt
retention-days: 15
android-build-store:
name: Build Android
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/build-android.yml
needs: [run-eslint-and-test, generate-pr-changelog]
secrets: inherit
with:
trigger: "pr"
ios-build-store:
name: Build iOS
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
permissions:
contents: read
pull-requests: write
uses: ./.github/workflows/build-ios.yml
needs: [run-eslint-and-test, generate-pr-changelog]
secrets: inherit
with:
trigger: "pr"
# Runs first (cheap, secret-free): validates flow tags, then narrows the shard
# list to the shards sniffler flags as impacted. `should_run=false` is a
# confident zero (no source touched) that skips the whole e2e stage below.
e2e-shards:
name: E2E Shard Preflight
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
shards: ${{ steps.select.outputs.shards }}
should_run: ${{ steps.select.outputs.should_run }}
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Checkout and Setup Node
uses: ./.github/actions/setup-node
- name: Assert Maestro shard coverage
id: full
run: bash .github/scripts/assert-maestro-shards.sh
- name: Select impacted shards
id: select
env:
IS_RELEASE_LANE: ${{ github.event.pull_request.base.ref == 'master' || contains(github.event.pull_request.labels.*.name, 'release') }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
FULL_SHARDS: ${{ steps.full.outputs.shards }}
run: bash .github/scripts/select-impacted-shards.sh
e2e-hold:
name: E2E Hold
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
needs: [e2e-shards]
permissions: {}
environment: approve_e2e_testing
runs-on: ubuntu-latest
steps:
- run: echo "Waiting for manual approval..."
e2e-build-android:
name: E2E Build Android
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/e2e-build-android.yml
needs: [e2e-shards, e2e-hold]
secrets: inherit
e2e-run-android:
name: E2E Run Android
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/maestro-android.yml
needs: [e2e-build-android, e2e-shards]
secrets: inherit
strategy:
matrix:
shard: ${{ fromJSON(needs.e2e-shards.outputs.shards) }}
fail-fast: false
with:
shard: ${{ matrix.shard }}
e2e-build-ios:
name: E2E Build iOS
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/e2e-build-ios.yml
needs: [e2e-shards, e2e-hold]
secrets: inherit
e2e-run-ios:
name: E2E Run iOS
if: ${{ github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
permissions:
contents: read
uses: ./.github/workflows/maestro-ios.yml
needs: [e2e-build-ios, e2e-shards]
secrets: inherit
strategy:
matrix:
shard: ${{ fromJSON(needs.e2e-shards.outputs.shards) }}
fail-fast: false
with:
shard: ${{ matrix.shard }}
# Single required e2e status check. Always publishes one stable context, so an
# intentional confident-zero skip merges clean while a real shard failure blocks.
e2e-result:
name: E2E Result
if: ${{ always() && github.repository == 'RocketChat/Rocket.Chat.ReactNative' }}
needs: [e2e-shards, e2e-run-android, e2e-run-ios]
permissions: {}
runs-on: ubuntu-latest
steps:
- name: Aggregate e2e outcome
env:
SHARDS_RESULT: ${{ needs.e2e-shards.result }}
SHOULD_RUN: ${{ needs.e2e-shards.outputs.should_run }}
SHARDS: ${{ needs.e2e-shards.outputs.shards }}
ANDROID: ${{ needs.e2e-run-android.result }}
IOS: ${{ needs.e2e-run-ios.result }}
run: |
if [ "$SHARDS_RESULT" != "success" ]; then
echo "::error title=E2E preflight failed::Shard preflight did not succeed (result=$SHARDS_RESULT)."
exit 1
fi
if [ "$SHOULD_RUN" != "true" ]; then
echo "### E2E skipped — 0 impacted flows (no source touched)" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
{
echo "### E2E ran shards \`$SHARDS\`"
echo "- Android: $ANDROID"
echo "- iOS: $IOS"
} >> "$GITHUB_STEP_SUMMARY"
if [ "$ANDROID" = "success" ] && [ "$IOS" = "success" ]; then
exit 0
fi
echo "::error title=E2E failed::One or more Maestro shards failed (android=$ANDROID ios=$IOS)."
exit 1