Skip to content

Commit 8dc1e90

Browse files
committed
Initial macOS CI, start with swift testing
1 parent f716099 commit 8dc1e90

File tree

2 files changed

+328
-0
lines changed

2 files changed

+328
-0
lines changed

.github/workflows/macos_tests.yaml

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,320 @@
1+
name: macOS tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
xcode_15_4_enabled:
7+
type: boolean
8+
description: "⚠️ Jobs with this version of Xcode are deprecated."
9+
default: false
10+
xcode_15_4_test_arguments_override:
11+
type: string
12+
description: "⚠️ Deprecated."
13+
default: ""
14+
xcode_16_0_enabled:
15+
type: boolean
16+
description: "Boolean to enable the Xcode version 16.0 jobs. Defaults to false."
17+
default: false
18+
xcode_16_0_build_arguments_override:
19+
type: string
20+
description: "The arguments passed to swift build in the macOS 5.10 Swift version matrix job."
21+
default: ""
22+
xcode_16_0_test_arguments_override:
23+
type: string
24+
description: "The arguments passed to swift test in the macOS 5.10 Swift version matrix job."
25+
default: ""
26+
xcode_16_0_setup_command:
27+
type: string
28+
description: "The command(s) to be executed before all other work."
29+
default: ""
30+
xcode_16_1_enabled:
31+
type: boolean
32+
description: "Boolean to enable the Xcode version 16.1 jobs. Defaults to false."
33+
default: false
34+
xcode_16_1_build_arguments_override:
35+
type: string
36+
description: "The arguments passed to swift build in the Xcode version 16.1 job."
37+
default: ""
38+
xcode_16_1_test_arguments_override:
39+
type: string
40+
description: "The arguments passed to swift test in the Xcode version 16.1 job."
41+
default: ""
42+
xcode_16_1_setup_command:
43+
type: string
44+
description: "The command(s) to be executed before all other work."
45+
default: ""
46+
xcode_16_2_enabled:
47+
type: boolean
48+
description: "Boolean to enable the Xcode version 16.2 jobs. Defaults to true."
49+
default: true
50+
xcode_16_2_build_arguments_override:
51+
type: string
52+
description: "The arguments passed to swift build in the Xcode version 16.2 job."
53+
default: ""
54+
xcode_16_2_test_arguments_override:
55+
type: string
56+
description: "The arguments passed to swift test in the Xcode version 16.2 job."
57+
default: ""
58+
xcode_16_2_setup_command:
59+
type: string
60+
description: "The command(s) to be executed before all other work."
61+
default: ""
62+
xcode_16_3_enabled:
63+
type: boolean
64+
description: "Boolean to enable the Xcode version 16.3 jobs. Defaults to true."
65+
default: true
66+
xcode_16_3_build_arguments_override:
67+
type: string
68+
description: "The arguments passed to swift build in the Xcode version 16.3 job."
69+
default: ""
70+
xcode_16_3_test_arguments_override:
71+
type: string
72+
description: "The arguments passed to swift test in the Xcode version 16.3 job."
73+
default: ""
74+
xcode_16_3_setup_command:
75+
type: string
76+
description: "The command(s) to be executed before all other work."
77+
default: ""
78+
xcode_26_beta_enabled:
79+
type: boolean
80+
description: "Boolean to enable the Xcode version 26 beta 1 jobs. Defaults to true."
81+
default: true
82+
xcode_26_beta_1_build_arguments_override:
83+
type: string
84+
description: "The arguments passed to swift build in the Xcode version 26 beta 1 job."
85+
default: ""
86+
xcode_26_beta_1_test_arguments_override:
87+
type: string
88+
description: "The arguments passed to swift test in the Xcode version 26 beta 1 job."
89+
default: ""
90+
xcode_26_beta_1_setup_command:
91+
type: string
92+
description: "The command(s) to be executed before all other work."
93+
default: ""
94+
95+
build_scheme:
96+
type: string
97+
description: "The build scheme used in the Xcode builds."
98+
swift_test_enabled:
99+
type: boolean
100+
description: "Boolean to enable test execution with `swift test`. Defaults to true."
101+
default: true
102+
macos_xcode_build_enabled:
103+
type: boolean
104+
description: "Boolean to enable the Xcode build targeting macOS. Defaults to true."
105+
default: true
106+
macos_xcode_test_enabled:
107+
type: boolean
108+
description: "Boolean to enable the Xcode test targeting macOS. Defaults to false."
109+
default: false
110+
ios_xcode_build_enabled:
111+
type: boolean
112+
description: "Boolean to enable the Xcode build targeting iOS. Defaults to true."
113+
default: true
114+
ios_xcode_test_enabled:
115+
type: boolean
116+
description: "Boolean to enable the Xcode test targeting iOS. Defaults to false."
117+
default: false
118+
watchos_xcode_build_enabled:
119+
type: boolean
120+
description: "Boolean to enable the Xcode build targeting watchOS. Defaults to true."
121+
default: true
122+
watchos_xcode_test_enabled:
123+
type: boolean
124+
description: "Boolean to enable the Xcode test targeting watchOS. Defaults to false."
125+
default: false
126+
tvos_xcode_build_enabled:
127+
type: boolean
128+
description: "Boolean to enable the Xcode build targeting tvOS. Defaults to true."
129+
default: true
130+
tvos_xcode_test_enabled:
131+
type: boolean
132+
description: "Boolean to enable the Xcode test targeting tvOS. Defaults to false."
133+
default: false
134+
visionos_xcode_build_enabled:
135+
type: boolean
136+
description: "Boolean to enable the Xcode build targeting visionOS. Defaults to true."
137+
default: true
138+
visionos_xcode_test_enabled:
139+
type: boolean
140+
description: "Boolean to enable the Xcode test targeting visionOS. Defaults to false."
141+
default: false
142+
143+
runner_pool:
144+
type: string
145+
description: "The runner pool which will be requested."
146+
default: "nightly"
147+
148+
jobs:
149+
construct-matrix:
150+
name: Construct Darwin matrix
151+
runs-on: ubuntu-latest
152+
outputs:
153+
darwin-matrix: '${{ steps.generate-matrix.outputs.darwin-matrix }}'
154+
steps:
155+
- name: Checkout repository
156+
uses: actions/checkout@v4
157+
with:
158+
persist-credentials: false
159+
- id: generate-matrix
160+
run: |
161+
cat >> "$GITHUB_OUTPUT" << EOM
162+
darwin-matrix=$(
163+
runner_pool="${MATRIX_RUNNER_POOL:="nightly"}"
164+
xcode_15_4_enabled="${MATRIX_MACOS_15_4_ENABLED:=true}"
165+
xcode_15_4_build_arguments_override="${MATRIX_MACOS_15_4_BUILD_ARGUMENTS_OVERRIDE:=""}"
166+
xcode_15_4_test_arguments_override="${MATRIX_MACOS_15_4_TEST_ARGUMENTS_OVERRIDE:=""}"
167+
xcode_15_4_setup_command="${MATRIX_MACOS_15_4_SETUP_COMMAND:=""}"
168+
xcode_16_0_enabled="${MATRIX_MACOS_16_0_ENABLED:=true}"
169+
xcode_16_0_build_arguments_override="${MATRIX_MACOS_16_0_BUILD_ARGUMENTS_OVERRIDE:=""}"
170+
xcode_16_0_test_arguments_override="${MATRIX_MACOS_16_0_TEST_ARGUMENTS_OVERRIDE:=""}"
171+
xcode_16_0_setup_command="${MATRIX_MACOS_16_0_SETUP_COMMAND:=""}"
172+
xcode_16_1_enabled="${MATRIX_MACOS_16_1_ENABLED:=true}"
173+
xcode_16_1_build_arguments_override="${MATRIX_MACOS_16_1_BUILD_ARGUMENTS_OVERRIDE:=""}"
174+
xcode_16_1_test_arguments_override="${MATRIX_MACOS_16_1_TEST_ARGUMENTS_OVERRIDE:=""}"
175+
xcode_16_1_setup_command="${MATRIX_MACOS_16_1_SETUP_COMMAND:=""}"
176+
xcode_16_2_enabled="${MATRIX_MACOS_16_2_ENABLED:=true}"
177+
xcode_16_2_build_arguments_override="${MATRIX_MACOS_16_2_BUILD_ARGUMENTS_OVERRIDE:=""}"
178+
xcode_16_2_test_arguments_override="${MATRIX_MACOS_16_2_TEST_ARGUMENTS_OVERRIDE:=""}"
179+
xcode_16_2_setup_command="${MATRIX_MACOS_16_2_SETUP_COMMAND:=""}"
180+
xcode_16_3_enabled="${MATRIX_MACOS_16_3_ENABLED:=true}"
181+
xcode_16_3_build_arguments_override="${MATRIX_MACOS_16_3_BUILD_ARGUMENTS_OVERRIDE:=""}"
182+
xcode_16_3_test_arguments_override="${MATRIX_MACOS_16_3_TEST_ARGUMENTS_OVERRIDE:=""}"
183+
xcode_16_3_setup_command="${MATRIX_MACOS_16_3_SETUP_COMMAND:=""}"
184+
xcode_26_beta_1_enabled="${MATRIX_MACOS_26_BETA_1_ENABLED:=true}"
185+
xcode_26_beta_1_build_arguments_override="${MATRIX_MACOS_26_BETA_1_BUILD_ARGUMENTS_OVERRIDE:=""}"
186+
xcode_26_beta_1_test_arguments_override="${MATRIX_MACOS_26_BETA_1_TEST_ARGUMENTS_OVERRIDE:=""}"
187+
xcode_26_beta_1_setup_command="${MATRIX_MACOS_26_BETA_1_SETUP_COMMAND:=""}"
188+
189+
# Create matrix from inputs
190+
matrix='{"config": []}'
191+
192+
if [[ "$xcode_15_4_enabled" == "true" ]]; then
193+
matrix=$(echo "$matrix" | jq -c \
194+
--arg setup_command "$xcode_15_4_setup_command" \
195+
--arg build_arguments_override "$xcode_15_4_build_arguments_override" \
196+
--arg test_arguments_override "$xcode_15_4_test_arguments_override" \
197+
--arg runner_pool "$runner_pool" \
198+
'.config[.config| length] |= . + { "name": "Xcode 15.4", "xcode_version": "15.4", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
199+
fi
200+
201+
if [[ "$xcode_16_0_enabled" == "true" ]]; then
202+
matrix=$(echo "$matrix" | jq -c \
203+
--arg setup_command "$xcode_16_0_setup_command" \
204+
--arg build_arguments_override "$xcode_16_0_build_arguments_override" \
205+
--arg test_arguments_override "$xcode_16_0_test_arguments_override" \
206+
--arg runner_pool "$runner_pool" \
207+
'.config[.config| length] |= . + { "name": "Xcode 16.0", "xcode_version": "16.0", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
208+
fi
209+
210+
if [[ "$xcode_16_1_enabled" == "true" ]]; then
211+
matrix=$(echo "$matrix" | jq -c \
212+
--arg setup_command "$xcode_16_1_setup_command" \
213+
--arg build_arguments_override "$xcode_16_1_build_arguments_override" \
214+
--arg test_arguments_override "$xcode_16_1_test_arguments_override" \
215+
--arg runner_pool "$runner_pool" \
216+
'.config[.config| length] |= . + { "name": "Xcode 16.1", "xcode_version": "16.1", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
217+
fi
218+
219+
if [[ "$xcode_16_2_enabled" == "true" ]]; then
220+
matrix=$(echo "$matrix" | jq -c \
221+
--arg setup_command "$xcode_16_2_setup_command" \
222+
--arg build_arguments_override "$xcode_16_2_build_arguments_override" \
223+
--arg test_arguments_override "$xcode_16_2_test_arguments_override" \
224+
--arg runner_pool "$runner_pool" \
225+
'.config[.config| length] |= . + { "name": "Xcode 16.2", "xcode_version": "16.2", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
226+
fi
227+
228+
if [[ "$xcode_16_3_enabled" == "true" ]]; then
229+
matrix=$(echo "$matrix" | jq -c \
230+
--arg setup_command "$xcode_16_3_setup_command" \
231+
--arg build_arguments_override "$xcode_16_3_build_arguments_override" \
232+
--arg test_arguments_override "$xcode_16_3_test_arguments_override" \
233+
--arg runner_pool "$runner_pool" \
234+
'.config[.config| length] |= . + { "name": "Xcode 16.3", "xcode_version": "16.3", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
235+
fi
236+
237+
if [[ "$xcode_26_beta_1_enabled" == "true" ]]; then
238+
matrix=$(echo "$matrix" | jq -c \
239+
--arg setup_command "$xcode_26_beta_1_setup_command" \
240+
--arg build_arguments_override "$xcode_26_beta_1_build_arguments_override" \
241+
--arg test_arguments_override "$xcode_26_beta_1_test_arguments_override" \
242+
--arg runner_pool "$runner_pool" \
243+
'.config[.config| length] |= . + { "name": "Xcode 26 beta 1", "xcode_version": "26.b1", "setup_command": $setup_command, "build_arguments_override": $build_arguments_override, "test_arguments_override": $test_arguments_override, "os": "sequoia", "arch": "ARM64", "pool": $runner_pool }')
244+
fi
245+
246+
echo "$matrix" | jq -c
247+
)"
248+
EOM
249+
env:
250+
MATRIX_RUNNER_POOL: ${{ inputs.runner_pool }}
251+
MATRIX_MACOS_15_4_ENABLED: ${{ inputs.xcode_15_4_enabled }}
252+
MATRIX_MACOS_15_4_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_15_4_build_arguments_override }}
253+
MATRIX_MACOS_15_4_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_15_4_test_arguments_override }}
254+
MATRIX_MACOS_15_4_SETUP_COMMAND: ${{ inputs.xcode_15_4_setup_command }}
255+
MATRIX_MACOS_16_0_ENABLED: ${{ inputs.xcode_16_0_enabled }}
256+
MATRIX_MACOS_16_0_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_0_build_arguments_override }}
257+
MATRIX_MACOS_16_0_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_0_test_arguments_override }}
258+
MATRIX_MACOS_16_0_SETUP_COMMAND: ${{ inputs.xcode_16_0_setup_command }}
259+
MATRIX_MACOS_16_1_ENABLED: ${{ inputs.xcode_16_1_enabled }}
260+
MATRIX_MACOS_16_1_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_1_build_arguments_override }}
261+
MATRIX_MACOS_16_1_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_1_test_arguments_override }}
262+
MATRIX_MACOS_16_1_SETUP_COMMAND: ${{ inputs.xcode_16_1_setup_command }}
263+
MATRIX_MACOS_16_2_ENABLED: ${{ inputs.xcode_16_2_enabled }}
264+
MATRIX_MACOS_16_2_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_2_build_arguments_override }}
265+
MATRIX_MACOS_16_2_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_2_test_arguments_override }}
266+
MATRIX_MACOS_16_2_SETUP_COMMAND: ${{ inputs.xcode_16_2_setup_command }}
267+
MATRIX_MACOS_16_3_ENABLED: ${{ inputs.xcode_16_3_enabled }}
268+
MATRIX_MACOS_16_3_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_3_build_arguments_override }}
269+
MATRIX_MACOS_16_3_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_3_test_arguments_override }}
270+
MATRIX_MACOS_16_3_SETUP_COMMAND: ${{ inputs.xcode_16_3_setup_command }}
271+
MATRIX_MACOS_26_BETA_1_ENABLED: ${{ inputs.xcode_26_beta_1_enabled }}
272+
MATRIX_MACOS_26_BETA_1_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_26_beta_1_build_arguments_override }}
273+
MATRIX_MACOS_26_BETA_1_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_26_beta_1_test_arguments_override }}
274+
MATRIX_MACOS_26_BETA_1_SETUP_COMMAND: ${{ inputs.xcode_26_beta_1_setup_command }}
275+
276+
darwin-job:
277+
name: ${{ matrix.config.name }}
278+
needs: construct-matrix
279+
runs-on: [self-hosted, macos, "${{ matrix.config.os }}", "${{ matrix.config.arch }}", "${{ matrix.config.pool }}"]
280+
timeout-minutes: 30
281+
strategy:
282+
fail-fast: false
283+
matrix: ${{ fromJson(needs.construct-matrix.outputs.darwin-matrix) }}
284+
steps:
285+
- name: Checkout repository
286+
uses: actions/checkout@v4
287+
with:
288+
persist-credentials: false
289+
submodules: true
290+
- name: Setup command
291+
run: |
292+
if [ -n "${{ matrix.config.setup_command }}" ]; then
293+
bash -c "${{ matrix.config.setup_command }}"
294+
fi
295+
- name: Swift build
296+
run: |
297+
if [ -n "${{ matrix.config.build_arguments_override }}" ]; then
298+
swift build ${{ matrix.config.build_arguments_override }}
299+
else
300+
swift build --build-tests
301+
fi
302+
- name: Swift test
303+
if: 'inputs.swift_test_enabled'
304+
run: |
305+
if [ -n "${{ matrix.config.test_arguments_override }}" ]; then
306+
swift test ${{ matrix.config.test_arguments_override }}
307+
else
308+
swift test
309+
fi
310+
# see `xcodebuild -list` for schemes, `simctl list` for destinations
311+
- name: macOS build
312+
if: '!cancelled() && inputs.macos_xcode_build_enabled'
313+
run: /usr/bin/xcodebuild -quiet -scheme ${BUILD_SCHEME} -destination "generic/platform=macos" build
314+
- name: macOS test
315+
if: '!cancelled() && inputs.macos_xcode_test_enabled'
316+
run: /usr/bin/xcodebuild -quiet -scheme ${BUILD_SCHEME} -destination "name=My Mac" test
317+
env:
318+
XCODE_VERSION: ${{ matrix.config.xcode_version }}
319+
DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.config.xcode_version }}.app"
320+
BUILD_SCHEME: ${{ inputs.build_scheme }}

.github/workflows/pull_request.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ jobs:
3939
- name: Gradle compile JMH benchmarks
4040
run: ./gradlew compileJmh --info
4141

42+
macos-tests:
43+
name: macOS tests
44+
# Workaround https://github.com/nektos/act/issues/1875
45+
uses: swiftlang/swift-java/.github/workflows/macos_tests.yml@main
46+
with:
47+
runner_pool: general
48+
build_scheme: SwiftJava-Package
49+
4250
test-swift:
4351
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
4452
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)