-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathaction.yml
More file actions
290 lines (248 loc) · 10.9 KB
/
Copy pathaction.yml
File metadata and controls
290 lines (248 loc) · 10.9 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Apple road test (selected RN app & AppleApp)
description: Package the given RN app as XCFramework, build the corresponding AppleApp variant, and optionally run Detox E2E
inputs:
variant:
description: 'AppleApp yarn command variant to run (vanilla or expo<version>)'
required: true
rn-project-path:
description: 'Path to the RN project to build'
required: true
run-e2e:
description: 'Run Detox E2E after packaging (uses Debug build instead of Release road-test build)'
required: false
default: 'false'
e2e-artifact-name:
description: 'Name prefix for Detox artifacts uploaded on failure'
required: false
default: 'detox-appleapp'
restore-turbo-cache:
description: 'Whether to restore the Turbo cache during setup'
required: false
default: 'true'
skip-setup:
description: 'Skip yarn install/build when the caller already prepared the monorepo (e.g. Expo preview workflow)'
required: false
default: 'false'
runs:
using: composite
steps:
- name: '::group:: Setup & prepare iOS'
run: echo "::group::Setup & prepare iOS"
shell: bash
- name: Setup
if: inputs.skip-setup != 'true'
uses: ./.github/actions/setup
with:
restore-turbo-cache: ${{ inputs.restore-turbo-cache }}
- name: Prepare iOS environment
uses: ./.github/actions/prepare-ios
- name: '::endgroup:: Setup & prepare iOS'
run: echo "::endgroup::"
shell: bash
- name: '::group:: ccache & iOS build caches'
run: echo "::group::ccache & iOS build caches"
shell: bash
- name: Configure ccache environment
run: |
echo "USE_CCACHE=1" >> "$GITHUB_ENV"
echo "CCACHE_DIR=${{ github.workspace }}/.ios_ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=${{ github.workspace }}" >> "$GITHUB_ENV"
echo "CCACHE_COMPRESS=1" >> "$GITHUB_ENV"
shell: bash
- name: Install ccache
run: brew install ccache
shell: bash
- name: Install applesimutils
if: inputs.run-e2e == 'true'
run: |
brew tap wix/brew
brew trust --formula wix/brew/applesimutils
brew install applesimutils
shell: bash
- name: Enable ccache
run: echo "$(brew --prefix)/opt/ccache/libexec" >> $GITHUB_PATH
shell: bash
- name: Restore AppleApp ccache
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
.ios_ccache
key: ${{ runner.os }}-rnapp-appleapp-${{ inputs.variant }}-ios-ccache-${{ hashFiles(format('{0}/ios/Podfile.lock', inputs.rn-project-path), format('{0}/ios/*.xcodeproj/project.pbxproj', inputs.rn-project-path), 'apps/AppleApp/Brownfield Apple App.xcodeproj/project.pbxproj') }}
restore-keys: |
${{ runner.os }}-rnapp-appleapp-${{ inputs.variant }}-ios-ccache-
- name: '::endgroup:: ccache & iOS build caches'
run: echo "::endgroup::"
shell: bash
- name: '::group:: RN app — pods & package iOS XCFramework'
run: |
echo "::group::RN app — pods & package iOS XCFramework"
echo "variant=${{ inputs.variant }} rn-project=${{ inputs.rn-project-path }}"
shell: bash
- name: Restore Pods cache (RN ${{ inputs.variant }} app)
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
${{ inputs.rn-project-path }}/ios/Pods
key: ${{ runner.os }}-rnapp-${{ inputs.variant }}-ios-pods-${{ hashFiles(format('{0}/ios/Podfile.lock', inputs.rn-project-path)) }}
restore-keys: |
${{ runner.os }}-rnapp-${{ inputs.variant }}-ios-pods-
- name: Brownfield codegen (RN ${{ inputs.variant }} app)
if: inputs.variant == 'vanilla' && inputs.run-e2e == 'true'
run: yarn codegen
working-directory: ${{ inputs.rn-project-path }}
shell: bash
# RN 0.84+ defaults to prebuilt RNCore during pod install. For the Detox packaging
# step we build RN from source so native deps (e.g. react-native-screens) link against
# the same headers as the Debug simulator XCFramework. Road-test builds without E2E
# keep the default prebuilt path for faster CI.
- name: Install pods (RN ${{ inputs.variant }} app, E2E)
if: inputs.variant == 'vanilla' && inputs.run-e2e == 'true'
env:
RCT_USE_PREBUILT_RNCORE: '0'
run: |
cd ${{ inputs.rn-project-path }}/ios
pod install
shell: bash
- name: Apply Brownfield Debug pod settings (E2E)
if: inputs.variant == 'vanilla' && inputs.run-e2e == 'true'
run: |
source scripts/ci-local-ios-e2e-common.sh
ci_local_e2e_apply_brownfield_debug_pod_settings "${{ github.workspace }}/${{ inputs.rn-project-path }}/ios"
shell: bash
- name: Install pods (RN ${{ inputs.variant }} app)
if: inputs.variant == 'vanilla' && inputs.run-e2e != 'true'
run: |
cd ${{ inputs.rn-project-path }}/ios
pod install
shell: bash
- name: Restore DerivedData cache (RN ${{ inputs.variant }} app)
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ inputs.rn-project-path }}/ios/build
key: ${{ runner.os }}-ios-rnapp-${{ inputs.variant }}-derived-data-${{ hashFiles(format('{0}/ios/Podfile.lock', inputs.rn-project-path), format('{0}/ios/*.xcodeproj/project.pbxproj', inputs.rn-project-path)) }}
restore-keys: |
${{ runner.os }}-ios-rnapp-${{ inputs.variant }}-derived-data-
- name: Package iOS framework with the Brownfield CLI
run: |
cd ${{ inputs.rn-project-path }}
yarn run brownfield:package:ios
shell: bash
- name: '::endgroup:: RN app — pods & package iOS XCFramework'
run: echo "::endgroup::"
shell: bash
- name: '::group:: AppleApp — Release road test build'
if: inputs.run-e2e != 'true'
run: echo "::group::AppleApp — Release road test build"
shell: bash
- name: Build Brownfield iOS native app (${{ inputs.variant }})
if: inputs.run-e2e != 'true'
run: |
yarn run build:example:ios-consumer:${{ inputs.variant }}
shell: bash
- name: '::endgroup:: AppleApp — Release road test build'
if: inputs.run-e2e != 'true'
run: echo "::endgroup::"
shell: bash
- name: '::group:: AppleApp — Detox E2E'
if: inputs.run-e2e == 'true'
run: echo "::group::AppleApp — Detox E2E"
shell: bash
- name: Resolve AppleApp E2E settings
if: inputs.run-e2e == 'true'
run: |
node <<'NODE'
const { getAppleAppDetoxVariant } = require('./apps/brownfield-example-shared-tests/detox-appleapp-variants.cjs');
const variant = getAppleAppDetoxVariant(process.env.APPLEAPP_VARIANT);
const append = (key, value) => {
const fs = require('node:fs');
fs.appendFileSync(process.env.GITHUB_ENV, `${key}=${value}\n`);
};
append('APPLEAPP_XCFRAMEWORK_APP', variant.xcframeworkApp);
append('APPLEAPP_E2E_CONFIGURATION', variant.configuration);
append('APPLEAPP_E2E_BUILD_SCRIPT', variant.e2eBuildScript);
append('APPLEAPP_E2E_TEST_SCRIPT', variant.e2eTestScript);
NODE
env:
APPLEAPP_VARIANT: ${{ inputs.variant }}
shell: bash
- name: Copy XCFrameworks into AppleApp
if: inputs.run-e2e == 'true'
run: node prepareXCFrameworks.js --appName "$APPLEAPP_XCFRAMEWORK_APP"
working-directory: apps/AppleApp
shell: bash
- name: Restore Detox build cache (AppleApp)
if: inputs.run-e2e == 'true'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: apps/AppleApp/build
key: ${{ runner.os }}-e2e-appleapp-${{ inputs.variant }}-build-${{ hashFiles(format('{0}/ios/Podfile.lock', inputs.rn-project-path), 'apps/AppleApp/Brownfield Apple App.xcodeproj/project.pbxproj', 'apps/brownfield-example-shared-tests/e2e/**') }}
restore-keys: |
${{ runner.os }}-e2e-appleapp-${{ inputs.variant }}-build-
- name: Install Detox iOS artifacts
if: inputs.run-e2e == 'true'
run: node node_modules/detox/scripts/postinstall.js
working-directory: apps/AppleApp
shell: bash
- name: Detox build (AppleApp ${{ inputs.variant }})
if: inputs.run-e2e == 'true'
run: yarn "$APPLEAPP_E2E_BUILD_SCRIPT"
working-directory: apps/AppleApp
shell: bash
- name: Verify embedded JS bundle in BrownfieldLib (E2E)
if: inputs.run-e2e == 'true'
run: |
echo "::group::Verify embedded JS bundle"
set -euo pipefail
PRODUCTS_DIR="apps/AppleApp/build/Build/Products/${APPLEAPP_E2E_CONFIGURATION}-iphonesimulator"
APP_PATH="$(find "$PRODUCTS_DIR" -maxdepth 1 -name '*.app' -print -quit)"
if [[ -z "$APP_PATH" ]]; then
echo "error: no .app under $PRODUCTS_DIR" >&2
exit 1
fi
EXECUTABLE_PATH="$APP_PATH/$(basename "$APP_PATH" .app)"
if [[ ! -f "$EXECUTABLE_PATH" ]]; then
echo "error: $EXECUTABLE_PATH missing — host app target produced an invalid .app (no bundle executable)." >&2
echo "Check AppleApp target membership for BrownfieldAppleApp.swift and related sources." >&2
exit 1
fi
BUNDLE_PATH="$APP_PATH/Frameworks/BrownfieldLib.framework/main.jsbundle"
if [[ ! -f "$BUNDLE_PATH" ]]; then
echo "error: $BUNDLE_PATH missing — E2E needs the packaged ${APPLEAPP_XCFRAMEWORK_APP} bundle, not Metro." >&2
echo "Re-run: yarn brownfield:package:ios (${APPLEAPP_XCFRAMEWORK_APP}) && node prepareXCFrameworks.js --appName ${APPLEAPP_XCFRAMEWORK_APP}" >&2
exit 1
fi
echo "App executable OK: $EXECUTABLE_PATH ($(wc -c < "$EXECUTABLE_PATH") bytes)"
echo "Embedded bundle OK: $BUNDLE_PATH ($(wc -c < "$BUNDLE_PATH") bytes)"
echo "::endgroup::"
shell: bash
- name: Detox test (AppleApp ${{ inputs.variant }})
if: inputs.run-e2e == 'true'
run: |
echo "::group::Detox test"
rm -rf e2e-artifacts
yarn "$APPLEAPP_E2E_TEST_SCRIPT"
echo "::endgroup::"
working-directory: apps/AppleApp
shell: bash
- name: Upload Detox recordings on failure
if: failure() && inputs.run-e2e == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ inputs.e2e-artifact-name }}-${{ inputs.variant }}-ios-recordings
path: apps/AppleApp/e2e-artifacts
if-no-files-found: warn
retention-days: 5
- name: '::endgroup:: AppleApp — Detox E2E'
if: always() && inputs.run-e2e == 'true'
run: echo "::endgroup::"
shell: bash
- name: '::group:: Summary'
run: echo "::group::Summary"
shell: bash
- name: Log ccache stats
uses: ./.github/actions/ccache-summary
with:
name: RN ${{ inputs.variant }} app & AppleApp
- name: '::endgroup:: Summary'
run: echo "::endgroup::"
shell: bash