Repository navigation
148 lines (145 loc) · 6.75 KB
/
Copy pathtest-ios-spm-newapp.yml
File metadata and controls
148 lines (145 loc) · 6.75 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
name: Test iOS SwiftPM - New App
permissions:
contents: read
on:
workflow_call:
jobs:
test:
runs-on: macos-15-large
strategy:
fail-fast: false
matrix:
flavor: [Debug, Release]
env:
APP_IOS_DIR: private/helloworld/ios
XCODE_PROJECT: HelloWorld.xcodeproj
XCODE_SCHEME: HelloWorld
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup xcode
uses: ./.github/actions/setup-xcode
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Run yarn install
uses: ./.github/actions/yarn-install
- name: Set Hermes prebuilt version
shell: bash
run: node ./scripts/releases/use-hermes-prebuilt.js
- name: Run yarn install again, with the correct hermes version
uses: ./.github/actions/yarn-install
- name: Ensure CocoaPods (`spm add --deintegrate` shells out to `pod`)
shell: bash
run: pod --version || sudo gem install cocoapods --no-document
# Both flavors are needed by every matrix cell, not just the one it builds:
# `spm add` stages both flavor framework trees and lets a per-configuration
# build setting pick one at build time, so it validates the debug/ and
# release/ artifact slots together (and `--download skip` refuses an
# incomplete slot). Please don't "optimise" this down to one flavor.
- name: Download ReactCore (Debug)
uses: ./.github/actions/download-artifact
with:
name: ReactCoreDebug.xcframework.tar.gz
path: /tmp/rc-debug
- name: Download ReactCore (Release)
uses: ./.github/actions/download-artifact
with:
name: ReactCoreRelease.xcframework.tar.gz
path: /tmp/rc-release
- name: Download ReactNativeDependencies (Debug)
uses: ./.github/actions/download-artifact
with:
name: ReactNativeDependenciesDebug.xcframework.tar.gz
path: /tmp/deps-debug
- name: Download ReactNativeDependencies (Release)
uses: ./.github/actions/download-artifact
with:
name: ReactNativeDependenciesRelease.xcframework.tar.gz
path: /tmp/deps-release
- name: Download React Native package
uses: ./.github/actions/download-artifact
with:
name: react-native-package
path: /tmp/react-native-tmp
# Reinstalls private/helloworld in place against the packaged react-native
# (published through the local proxy), so the app under test is what a user
# would get from npm rather than the workspace source.
- name: Prepare the HelloWorld application
shell: bash
run: node ./scripts/e2e/init-project-e2e.js --useHelloWorld --pathToLocalReactNative "/tmp/react-native-tmp/$(cat /tmp/react-native-tmp/react-native-package-version)"
# The ordinary `spm download`, pointed at the XCFrameworks this run just
# built rather than at the published nightly (RN_CORE_TARBALL_PATH /
# RN_DEPS_TARBALL_PATH are overrides download-spm-artifacts.js already
# supports). It fills both flavor slots per call and skips any slot that
# already validates, so it runs twice: the first pass fills both slots
# from the Release tarballs, then debug/ is dropped and refilled from the
# Debug tarballs while release/ is left alone. hermes-engine is fetched
# from Maven by the command itself.
- name: Download XCFrameworks built in this run (Debug + Release)
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: |
RN_CORE_TARBALL_PATH=/tmp/rc-release/ReactCoreRelease.xcframework.tar.gz \
RN_DEPS_TARBALL_PATH=/tmp/deps-release/ReactNativeDependenciesRelease.xcframework.tar.gz \
npx react-native spm download --artifacts /tmp/spm-artifacts
rm -rf /tmp/spm-artifacts/debug
RN_CORE_TARBALL_PATH=/tmp/rc-debug/ReactCoreDebug.xcframework.tar.gz \
RN_DEPS_TARBALL_PATH=/tmp/deps-debug/ReactNativeDependenciesDebug.xcframework.tar.gz \
npx react-native spm download --artifacts /tmp/spm-artifacts
- name: Scaffold Package.swift manifests for community dependencies
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: npx react-native spm scaffold || true
- name: Convert the app to SwiftPM
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: npx react-native spm add --deintegrate --artifacts /tmp/spm-artifacts --download skip
- name: Assert the app is on SwiftPM
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: |
if [[ ! -f "$XCODE_PROJECT/.spm-injected.json" ]]; then
echo "::error::spm add did not inject SwiftPM: $XCODE_PROJECT/.spm-injected.json is missing"
exit 1
fi
if [[ -f Podfile ]] && grep -q 'use_react_native!' Podfile; then
echo "::error::spm add --deintegrate left use_react_native! in the Podfile"
exit 1
fi
echo "SwiftPM injected in place; Podfile de-integrated."
- name: Build ${{ env.XCODE_SCHEME }} (${{ matrix.flavor }})
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: |
xcodebuild \
-project "$XCODE_PROJECT" \
-scheme "$XCODE_SCHEME" \
-configuration "${{ matrix.flavor }}" \
-sdk iphonesimulator \
-destination 'generic/platform=iOS Simulator' \
-derivedDataPath build/spm-e2e-dd \
build
- name: Check the embedded React.framework flavor
shell: bash
working-directory: ${{ env.APP_IOS_DIR }}
run: |
PRODUCTS="build/spm-e2e-dd/Build/Products/${{ matrix.flavor }}-iphonesimulator"
if [[ ! -d "$PRODUCTS" ]]; then
echo "Skipping flavor check: no build products directory."
exit 0
fi
BINARY=$(find "$PRODUCTS" -maxdepth 4 -path '*.app/Frameworks/React.framework/React' -type f 2>/dev/null | head -1 || true)
if [[ -z "$BINARY" ]] || ! command -v nm >/dev/null; then
echo "Skipping flavor check: no embedded React.framework binary or no nm."
exit 0
fi
COUNT=$(nm "$BINARY" | grep -c getDebugProps || true)
echo "getDebugProps symbols in $BINARY: $COUNT"
if [[ "${{ matrix.flavor }}" == 'Debug' && "$COUNT" -eq 0 ]]; then
echo "::error::Debug build embeds a Release React.framework (expected getDebugProps symbols, found none)"
exit 1
fi
if [[ "${{ matrix.flavor }}" == 'Release' && "$COUNT" -ne 0 ]]; then
echo "::error::Release build embeds a Debug React.framework ($COUNT getDebugProps symbols, expected none)"
exit 1
fi