Skip to content

Commit 42540f0

Browse files
Parallelize Darwin CI build (project-chip#32583)
* CI: Split up Darwin build into separate parallel jobs Overall this results in some wasted work, but should reduce the elapsed time for the workflow to complete, as well as making logs more granular in case of failures. * Bump minimum iOS target to 14.0 We were already using a 14.0 API but the CI build was not catching it due to that particular configuration not using -Werror. Also fix narrowing conversions when building on watchos. * Add back "darwin" meta-job as aggregation point * Address review comments
1 parent 27a478f commit 42540f0

File tree

6 files changed

+88
-78
lines changed

6 files changed

+88
-78
lines changed

.github/workflows/darwin.yaml

+82-71
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,25 @@ concurrency:
2626

2727
env:
2828
CHIP_NO_LOG_TIMESTAMPS: true
29-
30-
jobs:
31-
darwin:
32-
name: Build Darwin
3329

30+
jobs:
31+
framework:
32+
name: Build framework
3433
if: github.actor != 'restyled-io[bot]'
3534
runs-on: macos-latest
36-
35+
strategy:
36+
matrix:
37+
options: # We don't need a full matrix
38+
- flavor: macos-release-availability
39+
arguments: -sdk macosx -configuration Release OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new'
40+
- flavor: ios-release
41+
arguments: -sdk iphoneos -configuration Release OTHER_CFLAGS='${inherited} -Werror -Wconversion' GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
42+
- flavor: ios-debug
43+
arguments: -sdk iphoneos -configuration Debug OTHER_CFLAGS='${inherited} -Werror -Wconversion' GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
44+
- flavor: tvos-debug
45+
arguments: -sdk appletvos -configuration Debug OTHER_CFLAGS='${inherited} -Werror -Wconversion' GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
46+
- flavor: watchos-debug
47+
arguments: -sdk watchos -configuration Debug OTHER_CFLAGS='${inherited} -Werror -Wconversion' GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
3748
steps:
3849
- name: Checkout
3950
uses: actions/checkout@v4
@@ -43,57 +54,41 @@ jobs:
4354
uses: ./.github/actions/checkout-submodules-and-bootstrap
4455
with:
4556
platform: darwin
57+
bootstrap-log-name: bootstrap-logs-framework-${{ matrix.options.flavor }}
4658
- name: Block zap-cli from being used
47-
# xcodebuild is NOT expected to require zap-cli
48-
run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli)) && mv $D/zap-cli $D/zap-cli.moved'
49-
- name: Validate zap-cli is NOT available
50-
# run_in_build_env.sh is used to ensure PATH is set to something that would otherwise find zap-cli
51-
run: scripts/run_in_build_env.sh '(zap-cli --version && exit 1) || exit 0'
52-
- name: Run watchOS Build Debug
53-
working-directory: src/darwin/Framework
54-
# Disable availability annotations, since we are not building a system
55-
# Matter.framework.
56-
run: xcodebuild -target "Matter" -sdk watchos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
57-
- name: Run tvOS Build Debug
58-
working-directory: src/darwin/Framework
59-
# Disable availability annotations, since we are not building a system
60-
# Matter.framework.
61-
run: xcodebuild -target "Matter" -sdk appletvos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
62-
- name: Run iOS Build Debug
63-
working-directory: src/darwin/Framework
64-
# Disable availability annotations, since we are not building a system
65-
# Matter.framework.
66-
run: xcodebuild -target "Matter" -sdk iphoneos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
67-
- name: Run iOS Build Release
68-
working-directory: src/darwin/Framework
69-
# Disable availability annotations, since we are not building a system
70-
# Matter.framework.
71-
run: xcodebuild -target "Matter" -sdk iphoneos -configuration Release GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
72-
- name: Clean Build
73-
run: xcodebuild clean
74-
working-directory: src/darwin/Framework
75-
- name: Delete Defaults
76-
run: defaults delete com.apple.dt.xctest.tool
77-
continue-on-error: true
78-
- name: Run macOS Build
79-
# Enable -Werror by hand here, because the Xcode config can't
80-
# enable it for various reasons. Keep whatever Xcode settings
81-
# for OTHER_CFLAGS exist by using ${inherited}.
82-
#
83-
# Enable -Wconversion by hand as well, because it seems to not be
84-
# enabled by default in the Xcode config.
85-
#
86-
# Disable availability annotations, since we are not building a system
87-
# Matter.framework.
88-
run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion' GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
89-
working-directory: src/darwin/Framework
90-
- name: Clean Build
91-
run: xcodebuild clean
59+
run: |
60+
# Framework builds are NOT expected to require zap-cli
61+
scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli)) && mv $D/zap-cli $D/zap-cli.moved'
62+
# run_in_build_env.sh is used to ensure PATH is set to something that would otherwise find zap-cli
63+
scripts/run_in_build_env.sh '(zap-cli --version && exit 1) || exit 0'
64+
- name: Build
9265
working-directory: src/darwin/Framework
93-
- name: Make zap-cli work again
94-
run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli.moved)) && mv $D/zap-cli.moved $D/zap-cli'
95-
- name: Validate zap-cli is again available
96-
run: scripts/run_in_build_env.sh 'zap-cli --version'
66+
run: xcodebuild -target "Matter" ${{ matrix.options.arguments }}
67+
68+
tests:
69+
name: Run framework tests
70+
if: github.actor != 'restyled-io[bot]'
71+
runs-on: macos-latest
72+
strategy:
73+
matrix:
74+
options: # We don't need a full matrix
75+
- flavor: asan
76+
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
77+
- flavor: asan-global-storage
78+
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
79+
defines: MTR_PER_CONTROLLER_STORAGE_ENABLED=0
80+
- flavor: tsan
81+
arguments: -enableThreadSanitizer YES
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
- name: Setup Environment
86+
run: brew install python@3.9
87+
- name: Checkout submodules & Bootstrap
88+
uses: ./.github/actions/checkout-submodules-and-bootstrap
89+
with:
90+
platform: darwin
91+
bootstrap-log-name: bootstrap-logs-framework-${{ matrix.options.flavor }}
9792
- name: Build example All Clusters Server
9893
run: |
9994
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug chip_config_network_layer_ble=false
@@ -103,40 +98,56 @@ jobs:
10398
- name: Build example OTA Requestor
10499
run: |
105100
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug/ota-requestor-app chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0
106-
- name: Delete Defaults
107-
run: defaults delete com.apple.dt.xctest.tool
108-
continue-on-error: true
109101
- name: Run Framework Tests
110102
# For now disable unguarded-availability-new warnings because we
111103
# internally use APIs that we are annotating as only available on
112104
# new enough versions. Maybe we should change out deployment
113105
# target versions instead?
106+
working-directory: src/darwin/Framework
114107
run: |
115108
mkdir -p /tmp/darwin/framework-tests
116109
../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
117110
../../../out/debug/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) &
118-
# Disable BLE (CHIP_IS_BLE=NO) because the app does not have the permission to use it and that may crash the CI.
119111
120-
TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1 xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion' CHIP_IS_BLE=NO GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'> >(tee /tmp/darwin/framework-tests/darwin-tests-asan.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-asan-err.log >&2)
121-
# And the same thing, but with MTR_PER_CONTROLLER_STORAGE_ENABLED turned off, so we test that it does not break for now.
122-
TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1 xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion' CHIP_IS_BLE=NO GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1 MTR_PER_CONTROLLER_STORAGE_ENABLED=0' > >(tee /tmp/darwin/framework-tests/darwin-tests-asan-controller-storage.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-asan-controller-storage-err.log >&2)
123-
# And the same thing, but with MTR_NO_AVAILABILITY not turned on. This requires -Wno-unguarded-availability-new to avoid availability errors.
124-
TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1 xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new' CHIP_IS_BLE=NO GCC_PREPROCESSOR_DEFINITIONS='${inherited}' > >(tee /tmp/darwin/framework-tests/darwin-tests-asan-with-availability-annotations.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-asan-with-availability-annotations-err.log >&2)
112+
export TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1
125113
126-
xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableThreadSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion' CHIP_IS_BLE=NO GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1' > >(tee /tmp/darwin/framework-tests/darwin-tests-tsan.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-tsan-err.log >&2)
127-
working-directory: src/darwin/Framework
128-
- name: Build Matter TV Casting Bridge
129-
run: |
130-
xcodebuild -target "MatterTvCastingBridge" -sdk iphoneos
131-
working-directory: examples/tv-casting-app/darwin/MatterTvCastingBridge
114+
# Disable BLE (CHIP_IS_BLE=NO) because the app does not have the permission to use it and that may crash the CI.
115+
xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx ${{ matrix.options.arguments }} \
116+
OTHER_CFLAGS='${inherited} -Werror -Wconversion' CHIP_IS_BLE=NO GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1 ${{ matrix.options.defines }}' \
117+
> >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2)
132118
- name: Collect crash logs
133119
run: |
134120
mkdir -p /tmp/darwin/framework-tests
135121
find ~/Library/Developer/Xcode/DerivedData /Library/Logs/DiagnosticReports -name '*.ips' -print0 | xargs -0 -J % cp % /tmp/darwin/framework-tests
136122
- name: Uploading log files
137123
uses: actions/upload-artifact@v4
138-
if: ${{ failure() && !env.ACT }}
124+
if: failure() && !env.ACT
139125
with:
140-
name: darwin-framework-test-logs
126+
name: darwin-framework-test-logs-${{ matrix.options.flavor }}
141127
path: /tmp/darwin/framework-tests
142128
retention-days: 5
129+
130+
tv-casting-bridge:
131+
name: Build TV Casting Bridge example
132+
if: github.actor != 'restyled-io[bot]'
133+
runs-on: macos-latest
134+
steps:
135+
- name: Checkout
136+
uses: actions/checkout@v4
137+
- name: Setup Environment
138+
run: brew install python@3.9
139+
- name: Checkout submodules & Bootstrap
140+
uses: ./.github/actions/checkout-submodules-and-bootstrap
141+
with:
142+
platform: darwin
143+
- name: Build
144+
working-directory: examples/tv-casting-app/darwin/MatterTvCastingBridge
145+
run: xcodebuild -target "MatterTvCastingBridge" -sdk iphoneos
146+
147+
darwin:
148+
name: Build Darwin # Matches the previous monolithic build that's marked "required" for PRs
149+
needs: [ framework, tests ]
150+
runs-on: macos-latest
151+
steps:
152+
- name: Done
153+
run: 'true' # nothing to do

build/config/mac/mac_sdk.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (current_os == "mac") {
3434
deployment_target = "11.0"
3535
}
3636
} else {
37-
deployment_target = "13.4"
37+
deployment_target = "14.0"
3838
}
3939

4040
declare_args() {

examples/tv-casting-app/darwin/MatterTvCastingBridge/chip_xcode_build_connector.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ find_in_ancestors() {
145145
fi
146146

147147
# there are environments where these bits are unwanted, unnecessary, or impossible
148-
[[ -n $CHIP_NO_SUBMODULES ]] || git submodule update --init
148+
[[ -n $CHIP_NO_SUBMODULES ]] || scripts/checkout_submodules.py --shallow --platform darwin
149149
if [[ -z $CHIP_NO_ACTIVATE ]]; then
150150
# first run bootstrap/activate in an external env to build everything
151151
env -i PW_ENVSETUP_NO_BANNER=1 PW_ENVSETUP_QUIET=1 bash -c '. scripts/activate.sh'

src/darwin/Framework/CHIP/MTRDeviceControllerXPCConnection.mm

+1-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ - (void)handleReportWithController:(id)controller
195195
if (!controllerDictionary) {
196196
return;
197197
}
198-
NSNumber * nodeIdKey = [NSNumber numberWithUnsignedInteger:nodeId];
199-
NSMutableArray * nodeArray = controllerDictionary[nodeIdKey];
198+
NSMutableArray * nodeArray = controllerDictionary[@(nodeId)];
200199
if (!nodeArray) {
201200
return;
202201
}

src/darwin/Framework/CHIP/ServerEndpoint/MTRAccessGrant.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ - (BOOL)isEqual:(id)object
112112

113113
- (NSUInteger)hash
114114
{
115-
return _subjectID.unsignedLongLongValue ^ _grantedPrivilege ^ _authenticationMode;
115+
return _subjectID.unsignedIntegerValue ^ _grantedPrivilege ^ _authenticationMode;
116116
}
117117

118118
- (NSString *)description

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,7 @@
22542254
);
22552255
INFOPLIST_FILE = CHIP/Info.plist;
22562256
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2257-
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
2257+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
22582258
LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib";
22592259
OTHER_CFLAGS = "-fmacro-prefix-map=$(SRCROOT)/CHIP/=";
22602260
OTHER_LDFLAGS = "";
@@ -2421,7 +2421,7 @@
24212421
);
24222422
INFOPLIST_FILE = CHIP/Info.plist;
24232423
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2424-
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
2424+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
24252425
LIBRARY_SEARCH_PATHS = "$(TEMP_DIR)/out/lib";
24262426
OTHER_CFLAGS = "-fmacro-prefix-map=$(SRCROOT)/CHIP/=";
24272427
OTHER_LDFLAGS = "";

0 commit comments

Comments
 (0)