Skip to content

Commit af5dfc8

Browse files
committed
feat(CI): Update workflow
1 parent 75cd4ea commit af5dfc8

File tree

4 files changed

+180
-70
lines changed

4 files changed

+180
-70
lines changed

.github/workflows/ci.yml

+84-12
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,100 @@ on:
77
pull_request:
88
branches:
99
- '*'
10+
workflow_dispatch:
1011

1112
concurrency:
1213
group: ci-${{ github.ref }}
1314
cancel-in-progress: true
1415

1516
jobs:
16-
library-swift-latest:
17-
name: Library
17+
test-library:
18+
name: test-library
1819
if: |
1920
!contains(github.event.head_commit.message, '[ci skip]') &&
2021
!contains(github.event.head_commit.message, '[ci skip test]') &&
2122
!contains(github.event.head_commit.message, '[ci skip library-swift-latest]')
22-
runs-on: macos-13
23-
timeout-minutes: 30
23+
runs-on: macos-14
2424
strategy:
2525
matrix:
26-
config:
27-
- debug
28-
- release
26+
scheme: [Interception]
27+
command: [test]
28+
platform: [iOS, macOS, tvOS, watchOS, macCatalyst]
29+
xcode: [15.4, '16.0']
30+
config: [Debug, Release]
2931
steps:
30-
- uses: actions/checkout@v4
31-
- name: Select Xcode 15.2
32-
run: sudo xcode-select -s /Applications/Xcode_15.2.app
33-
- name: Run test
34-
run: make test
32+
- uses: actions/checkout@v4
33+
with:
34+
submodules: true
35+
- name: Select Xcode ${{ matrix.xcode }}
36+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
37+
- name: Cache derived data
38+
uses: actions/cache@v3
39+
with:
40+
path: |
41+
~/.derivedData
42+
key: |
43+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
44+
restore-keys: |
45+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
46+
- name: Set IgnoreFileSystemDeviceInodeChanges flag
47+
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
48+
- name: Update mtime for incremental builds
49+
uses: chetan/git-restore-mtime-action@v2
50+
- name: test-library (${{ matrix.config }})
51+
uses: capturecontext/[email protected]
52+
with:
53+
command: xcodebuild
54+
subcommand: ${{ matrix.command }}
55+
platform: ${{ matrix.platform }}
56+
scheme: ${{ matrix.scheme }}
57+
config: ${{ matrix.config }}
58+
- name: test-library-macros (${{ matrix.config }})
59+
uses: capturecontext/[email protected]
60+
with:
61+
command: xcodebuild-macros
62+
subcommand: ${{ matrix.command }}
63+
platform: ${{ matrix.platform }}
64+
scheme: ${{ matrix.scheme }}
65+
config: ${{ matrix.config }}
66+
test-library-macros-plugin:
67+
name: test-library-macros-plugin
68+
if: |
69+
!contains(github.event.head_commit.message, '[ci skip]') &&
70+
!contains(github.event.head_commit.message, '[ci skip test]') &&
71+
!contains(github.event.head_commit.message, '[ci skip library-swift-latest]')
72+
runs-on: macos-14
73+
strategy:
74+
matrix:
75+
scheme: [Interception]
76+
command: [test]
77+
platform: [macOS]
78+
xcode: ['16.0']
79+
config: [Debug]
80+
steps:
81+
- uses: actions/checkout@v4
82+
with:
83+
submodules: true
84+
- name: Select Xcode ${{ matrix.xcode }}
85+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
86+
- name: Cache derived data
87+
uses: actions/cache@v3
88+
with:
89+
path: |
90+
~/.derivedData
91+
key: |
92+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
93+
restore-keys: |
94+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
95+
- name: Set IgnoreFileSystemDeviceInodeChanges flag
96+
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
97+
- name: Update mtime for incremental builds
98+
uses: chetan/git-restore-mtime-action@v2
99+
- name: test-library-macros-plugin (${{ matrix.config }})
100+
uses: capturecontext/[email protected]
101+
with:
102+
command: xcodebuild-macros-plugin
103+
subcommand: ${{ matrix.command }}
104+
platform: ${{ matrix.platform }}
105+
scheme: ${{ matrix.scheme }}
106+
config: ${{ matrix.config }}

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "swift-package-action"]
2+
path = swift-package-action
3+
url = [email protected]:capturecontext/swift-package-action.git

Makefile

+92-58
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,105 @@
1-
CONFIG = debug
2-
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17.2,iPhone \d\+ Pro [^M])
3-
PLATFORM_MACOS = macOS
4-
PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
5-
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS 17,TV)
6-
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS 10,Watch)
1+
default:
2+
$(error Missing command)
3+
@exit 1
74

8-
default: test-all
5+
%:
6+
$(error Unknown command: $@)
7+
@exit 1
8+
9+
TEST_RUNNER_CI ?= $(CI)
10+
MAKEFILE_PATH ?= "./swift-package-action/Makefile"
11+
12+
SCHEME ?= Interception
13+
PLATFORM ?= iOS
14+
CONFIG ?= Debug
15+
16+
DERIVED_DATA="./DerivedData"
17+
18+
BOLD=\033[1m
19+
RESET=\033[0m
920

1021
test-all:
11-
$(MAKE) test
22+
$(MAKE) test-library
23+
$(MAKE) test-library-macros
1224
$(MAKE) test-docs
1325

14-
test:
15-
$(MAKE) CONFIG=debug test-library
16-
$(MAKE) CONFIG=debug test-library-macros
17-
$(MAKE) test-macros
18-
1926
test-library:
20-
for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_WATCHOS)"; do \
21-
echo "\nTesting library on $$platform\n" && \
22-
(xcodebuild test \
23-
-skipMacroValidation \
24-
-configuration $(CONFIG) \
25-
-workspace .github/package.xcworkspace \
26-
-scheme InterceptionTests \
27-
-destination platform="$$platform" | xcpretty && exit 0 \
28-
) \
29-
|| exit 1; \
30-
done;
27+
@make loop-platforms \
28+
-f $(MAKEFILE_PATH) \
29+
PLATFORMS="iOS,macOS,macCatalyst,watchOS,tvOS" \
30+
GOAL="xcodebuild" \
31+
COMMAND=test \
32+
SCHEME=$(SCHEME) \
33+
CONFIG=$(CONFIG) \
34+
DERIVED_DATA=$(DERIVED_DATA)
3135

3236
test-library-macros:
33-
for platform in "$(PLATFORM_IOS)" "$(PLATFORM_MACOS)" "$(PLATFORM_MAC_CATALYST)" "$(PLATFORM_TVOS)" "$(PLATFORM_WATCHOS)"; do \
34-
echo "\nTesting library-macros on $$platform\n" && \
35-
(xcodebuild test \
36-
-skipMacroValidation \
37-
-configuration $(CONFIG) \
38-
-workspace .github/package.xcworkspace \
39-
-scheme InterceptionMacrosTests \
40-
-destination platform="$$platform" | xcpretty && exit 0 \
37+
@for platform in "iOS" "macOS" "macCatalyst" "watchOS" "tvOS"; do \
38+
echo "\n$(BOLD)Testing library macros on $$platform$(RESET)\n" && \
39+
( \
40+
make xcodebuild-macros \
41+
COMMAND=test \
42+
DERIVED_DATA=$(DERIVED_DATA) \
43+
CONFIG=$(CONFIG) \
44+
SCHEME="(SCHEME) \
45+
PLATFORM="$$platform" \
4146
) \
42-
|| exit 1; \
4347
done;
48+
$(MAKE) xcodebuild-macros-plugin COMMAND=test PLATFORM=macOS
49+
50+
xcodebuild:
51+
@make xcodebuild \
52+
-f $(MAKEFILE_PATH) \
53+
COMMAND=$(COMMAND) \
54+
DERIVED_DATA=$(DERIVED_DATA) \
55+
CONFIG=$(CONFIG) \
56+
SCHEME=$(SCHEME) \
57+
PLATFORM=$(PLATFORM)
58+
59+
xcodebuild-macros:
60+
@make xcodebuild-macros \
61+
-f $(MAKEFILE_PATH) \
62+
COMMAND=$(COMMAND) \
63+
DERIVED_DATA=$(DERIVED_DATA) \
64+
CONFIG=$(CONFIG) \
65+
SCHEME="$(SCHEME)" \
66+
PLATFORM=$(PLATFORM)
67+
68+
xcodebuild-macros-plugin:
69+
@make xcodebuild-macros-plugin \
70+
-f $(MAKEFILE_PATH) \
71+
COMMAND=$(COMMAND) \
72+
DERIVED_DATA=$(DERIVED_DATA) \
73+
CONFIG=$(CONFIG) \
74+
SCHEME="$(SCHEME)" \
75+
PLATFORM=$(PLATFORM)
76+
77+
build-for-library-evolution:
78+
@make build-for-library-evolution \
79+
-f $(MAKEFILE_PATH) \
80+
SCHEME="$(SCHEME)"
4481

45-
test-macros:
46-
echo "\nTesting macros\n" && \
47-
(xcodebuild test \
48-
-skipMacroValidation \
49-
-configuration $(CONFIG) \
50-
-workspace .github/package.xcworkspace \
51-
-scheme InterceptionMacrosPluginTests \
52-
-destination platform=macOS | xcpretty && exit 0 \
53-
) \
54-
|| exit 1;
55-
56-
DOC_WARNINGS = $(shell xcodebuild clean docbuild \
57-
-scheme Interception \
58-
-destination platform="$(PLATFORM_IOS)" \
59-
-quiet \
60-
2>&1 \
61-
| grep "couldn't be resolved to known documentation" \
62-
| sed 's|$(PWD)|.|g' \
63-
| tr '\n' '\1')
6482
test-docs:
65-
@test "$(DOC_WARNINGS)" = "" \
66-
|| (echo "xcodebuild docbuild failed:\n\n$(DOC_WARNINGS)" | tr '\1' '\n' \
67-
&& exit 1)
83+
@make test-docs \
84+
-f $(MAKEFILE_PATH) \
85+
SCHEME="$(SCHEME)" \
86+
PLATFORM=$(PLATFORM)
87+
88+
test-example:
89+
@make test-example \
90+
-f $(MAKEFILE_PATH) \
91+
DERIVED_DATA=$(DERIVED_DATA) \
92+
SCHEME="$(SCHEME)" \
93+
PLATFORM=$(PLATFORM)
94+
95+
test-integration:
96+
@make test-integration \
97+
-f $(MAKEFILE_PATH) \
98+
SCHEME="Integration" \
99+
PLATFORM=$(PLATFORM)
100+
101+
benchmark:
102+
@make benchmark -f $(MAKEFILE_PATH)
68103

69-
define udid_for
70-
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
71-
endef
104+
format:
105+
@make format -f $(MAKEFILE_PATH)

swift-package-action

Submodule swift-package-action added at 030a9fe

0 commit comments

Comments
 (0)