Repository navigation
249 lines (225 loc) · 8.48 KB
/
Copy pathbuild-pr.yml
File metadata and controls
249 lines (225 loc) · 8.48 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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 test 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
pull-requests: read
runs-on: ubuntu-latest
outputs:
shards: ${{ steps.select.outputs.shards }}
ios_shards: ${{ steps.ios.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 E2E shard coverage
id: full
run: bash .github/scripts/assert-e2e-shards.sh
# Read labels live rather than from the event payload: the payload is frozen
# at push time (a label added afterwards, or a re-run, would never see it),
# and `contains()` over an array is an exact element match — it would miss
# the decorated label name ("💎 release").
- name: Detect release label
id: label
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' | grep -qi 'release'; then
echo "release=true" >>"$GITHUB_OUTPUT"
else
echo "release=false" >>"$GITHUB_OUTPUT"
fi
- name: Select impacted shards
id: select
env:
IS_RELEASE_LANE: ${{ github.event.pull_request.base.ref == 'master' || steps.label.outputs.release == 'true' }}
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
- name: Group iOS shards
id: ios
if: steps.select.outputs.should_run == 'true'
env:
SHARDS: ${{ steps.select.outputs.shards }}
run: echo "shards=$(node .github/scripts/group-ios-shards.js)" >> "$GITHUB_OUTPUT"
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/e2e-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/e2e-ios.yml
needs: [e2e-build-ios, e2e-shards]
secrets: inherit
strategy:
matrix:
job: ${{ fromJSON(needs.e2e-shards.outputs.ios_shards) }}
fail-fast: false
with:
shard: ${{ matrix.job.shards }}
device-profile: ${{ matrix.job.deviceProfile }}
e2e-replays:
name: E2E Replays
if: ${{ always() && github.repository == 'RocketChat/Rocket.Chat.ReactNative' && needs.e2e-shards.outputs.should_run == 'true' }}
needs: [e2e-shards, e2e-run-android, e2e-run-ios]
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Download Recorded Agent Replays
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: e2e-replays-*
path: .e2e/replays
- name: Comment Recorded Agent Replays on the PR
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
RUN_ID: ${{ github.run_id }}
run: bash .github/scripts/comment-e2e-replays.sh .e2e/replays
# 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 tests (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 E2E shards failed (android=$ANDROID ios=$IOS)."
exit 1