Skip to content

Commit af9059c

Browse files
authored
fix(ci): Refactor Apple jobs (#3631)
* Copy stuff from RNM and refactor * Disable ccache * gitignore ccache * fix * fix * fix * fix * fix * fix * fix
1 parent fd17528 commit af9059c

11 files changed

+144
-120
lines changed

.ado/Brewfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew "xcbeautify"
2+
brew "ccache"

.ado/azure-pipelines.yml

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -79,43 +79,36 @@ jobs:
7979

8080
- template: templates/setup-repo-min-build.yml
8181

82-
- template: templates/apple-ensure-valid-cocoapods.yml
82+
- template: templates/apple-tools-setup.yml
8383

8484
- script: |
85+
set -eox pipefail
8586
yarn bundle:macos
8687
workingDirectory: apps/fluent-tester
8788
displayName: 'yarn bundle macos'
8889
8990
- bash: |
90-
echo "pod install $(platform)"
91-
pod install
92-
workingDirectory: apps/fluent-tester/$(platform)
93-
displayName: 'pod install $(platform)'
94-
95-
- bash: |
96-
sudo xcode-select --switch '$(xcode_path)'
97-
displayName: Switch Xcode version $(xcode_version)
98-
failOnStderr: true
99-
100-
- script: |
101-
brew install xcbeautify
102-
displayName: 'Install xcbeautify'
103-
104-
- bash: |
105-
echo "yarn $(platform)"
106-
yarn $(platform)
107-
workingDirectory: apps/fluent-tester
108-
displayName: 'yarn $(platform)'
91+
set -eox pipefail
92+
pod install --verbose
93+
workingDirectory: apps/fluent-tester/macos
94+
displayName: 'pod install'
95+
96+
- task: CmdLine@2
97+
displayName: Build macOS
98+
inputs:
99+
script: |
100+
set -eox pipefail
101+
./.ado/scripts/xcodebuild.sh apps/fluent-tester/macos/FluentTester.xcworkspace macosx ReactTestApp build
102+
env:
103+
CCACHE_DISABLE: 1
109104

110105
- template: templates/e2e-testing-macos.yml
111106

112107
- job: iOSPR
113108
displayName: iOS PR
114109
pool:
115-
vmImage: macos-13-arm64
116-
variables:
117-
platform: 'ios'
118-
timeoutInMinutes: 120 # how long to run the job before automatically cancelling
110+
vmImage: $(VmImageApple)
111+
timeoutInMinutes: 60 # how long to run the job before automatically cancelling
119112
cancelTimeoutInMinutes: 5 # how much time to give 'run always even if cancelled tasks' before killing them
120113

121114
steps:
@@ -124,47 +117,28 @@ jobs:
124117

125118
- template: templates/setup-repo-min-build.yml
126119

127-
- template: templates/apple-ensure-valid-cocoapods.yml
120+
- template: templates/apple-tools-setup.yml
128121

129122
- script: |
123+
set -eox pipefail
130124
yarn bundle:ios
131125
workingDirectory: apps/fluent-tester
132126
displayName: 'yarn bundle ios'
133127
134128
- bash: |
135-
echo "pod install $(platform)"
136-
pod install
137-
workingDirectory: apps/fluent-tester/$(platform)
138-
displayName: 'pod install $(platform)'
139-
140-
- bash: |
141-
sudo xcode-select --switch '$(xcode_path)'
142-
displayName: Switch Xcode version $(xcode_version)
143-
failOnStderr: true
144-
145-
- script: |
146-
brew install xcbeautify
147-
displayName: 'Install xcbeautify'
148-
149-
- script: |
150-
xcrun simctl list
151-
displayName: 'List Simulators'
152-
153-
- script: |
154-
xcrun --sdk iphonesimulator --show-sdk-version
155-
displayName: 'Determine iOS SDK version'
156-
157-
# - script: |
158-
# NEW_DEVICE=$(xcrun simctl create "Test Phone" "$(ios_simulator)" iOS$(ios_version))
159-
# echo "🤖 Created ${NEW_DEVICE}"
160-
# xcrun simctl boot ${NEW_DEVICE}
161-
# displayName: 'Boot Simulator'
162-
163-
- bash: |
164-
echo "yarn $(platform)"
165-
yarn $(platform) --simulator "$(ios_simulator)" --no-packager
166-
workingDirectory: apps/fluent-tester
167-
displayName: 'yarn $(platform)'
129+
set -eox pipefail
130+
pod install --verbose
131+
workingDirectory: apps/fluent-tester/ios
132+
displayName: 'pod install'
133+
134+
- task: CmdLine@2
135+
displayName: Build iOS
136+
inputs:
137+
script: |
138+
set -eox pipefail
139+
./.ado/scripts/xcodebuild.sh apps/fluent-tester/ios/FluentTester.xcworkspace iphonesimulator ReactTestApp build
140+
env:
141+
CCACHE_DISABLE: 1
168142

169143
# Disable iOS E2E tests as they fail on macOS-13 images
170144
# - template: templates/e2e-testing-ios.yml

.ado/scripts/xcodebuild.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
workspace=$1
5+
sdk=$2
6+
scheme=$3
7+
action=$4
8+
9+
shift 4
10+
11+
12+
if [[ $sdk == iphoneos || $sdk == iphonesimulator ]]; then
13+
if [[ $action == 'test' || $action == 'test-without-building' ]]; then
14+
device=$(xcrun simctl list devices iPhone available)
15+
re='iPhone [0-9]+ \(([-0-9A-Fa-f]+)\)'
16+
[[ $device =~ $re ]] || exit 1
17+
shift || true
18+
destination="-destination \"platform=iOS Simulator,id=${BASH_REMATCH[1]}\""
19+
else
20+
destination='-destination "generic/platform=iOS Simulator"'
21+
fi
22+
elif [[ $sdk == macosx ]]; then
23+
destination=''
24+
elif [[ $sdk == xros || $sdk == xrsimulator ]]; then
25+
if [[ $action == 'test' || $action == 'test-without-building' ]]; then
26+
device=$(xcrun simctl list devices visionOS available)
27+
re='Apple Vision Pro \(([-0-9A-Fa-f]+)\)'
28+
[[ $device =~ $re ]] || exit 1
29+
shift || true
30+
destination="-destination \"platform=visionOS Simulator,id=${BASH_REMATCH[1]}\""
31+
else
32+
destination='-destination "generic/platform=visionOS Simulator"'
33+
fi
34+
else
35+
echo "Cannot detect sdk: $sdk"
36+
exit 1
37+
fi
38+
39+
build_cmd=$(
40+
echo xcodebuild \
41+
-workspace "$workspace" \
42+
-scheme "$scheme" \
43+
-sdk "$sdk" \
44+
"$destination" \
45+
-derivedDataPath $(dirname $workspace)/build \
46+
CODE_SIGNING_ALLOWED=NO \
47+
COMPILER_INDEX_STORE_ENABLE=NO \
48+
"$action" \
49+
"$@" \
50+
51+
)
52+
53+
if [[ "$CCACHE_DISABLE" != "1" ]]; then
54+
if ! command -v ccache 1> /dev/null; then
55+
brew install ccache
56+
fi
57+
58+
CCACHE_HOME=$(dirname $(dirname $(which ccache)))/opt/ccache
59+
60+
export CCACHE_DIR="$(git rev-parse --show-toplevel)/.ccache"
61+
62+
export CC="${CCACHE_HOME}/libexec/clang"
63+
export CXX="${CCACHE_HOME}/libexec/clang++"
64+
export CMAKE_C_COMPILER_LAUNCHER=$(which ccache)
65+
export CMAKE_CXX_COMPILER_LAUNCHER=$(which ccache)
66+
67+
ccache --zero-stats 1> /dev/null
68+
fi
69+
if ! command -v xcbeautify 1> /dev/null; then
70+
brew install xcbeautify
71+
fi
72+
73+
eval "$build_cmd" | xcbeautify --report junit
74+
75+
if [[ "$CCACHE_DISABLE" != "1" ]]; then
76+
ccache --show-stats --verbose
77+
fi

.ado/templates/apple-ensure-valid-cocoapods.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.ado/templates/apple-tools-setup.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
steps:
2+
- task: NodeTool@0
3+
inputs:
4+
versionSpec: '18.x'
5+
6+
- task: CmdLine@2
7+
displayName: 'brew bundle'
8+
inputs:
9+
script: |
10+
brew bundle --file .ado/Brewfile
11+
cat .ado/Brewfile.lock.json
12+
13+
# Cocoapods 1.15.0 doesn't work with React Native
14+
- task: CmdLine@2
15+
displayName: Install Cocoapods 1.15.2 if needed
16+
inputs:
17+
script: |
18+
POD_VERSION=$(pod --version)
19+
if [ $POD_VERSION = 1.15.0 ]; then
20+
gem install cocoapods -v 1.15.2
21+
fi
22+
23+
- bash: |
24+
sudo xcode-select --switch $(xcode_version)
25+
displayName: Use $(xcode_friendly_name)
26+
failOnStderr: true

.ado/variables/vars.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
variables:
22
- name: VmImageApple
3-
value: macos-13
4-
- name: xcode_version
3+
value: macos-latest-internal
4+
- name: xcode_friendly_name
55
value: 'Xcode 15.2'
6-
- name: xcode_path
6+
- name: xcode_version
77
value: '/Applications/Xcode_15.2.app'
8-
- name: ios_version
9-
value: '17.2.0'
10-
- name: ios_simulator
11-
value: 'iPhone 15 (17.2.0)'

.ado/xcconfig/publish_overrides.xcconfig

Lines changed: 0 additions & 23 deletions
This file was deleted.

.ado/xcconfig/publish_overrides_ios_device.xcconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.

.ado/xcconfig/publish_overrides_ios_simulator.xcconfig

Lines changed: 0 additions & 4 deletions
This file was deleted.

.ado/xcconfig/publish_staticanalysis.xcconfig

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)