Skip to content

WIP: Initial macOS CI, start with swift testing #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
320 changes: 320 additions & 0 deletions .github/workflows/macos_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
name: macOS tests

on:
workflow_call:
inputs:
xcode_15_4_enabled:
type: boolean
description: "⚠️ Jobs with this version of Xcode are deprecated."
default: false
xcode_15_4_test_arguments_override:
type: string
description: "⚠️ Deprecated."
default: ""
xcode_16_0_enabled:
type: boolean
description: "Boolean to enable the Xcode version 16.0 jobs. Defaults to false."
default: false
xcode_16_0_build_arguments_override:
type: string
description: "The arguments passed to swift build in the macOS 5.10 Swift version matrix job."
default: ""
xcode_16_0_test_arguments_override:
type: string
description: "The arguments passed to swift test in the macOS 5.10 Swift version matrix job."
default: ""
xcode_16_0_setup_command:
type: string
description: "The command(s) to be executed before all other work."
default: ""
xcode_16_1_enabled:
type: boolean
description: "Boolean to enable the Xcode version 16.1 jobs. Defaults to false."
default: false
xcode_16_1_build_arguments_override:
type: string
description: "The arguments passed to swift build in the Xcode version 16.1 job."
default: ""
xcode_16_1_test_arguments_override:
type: string
description: "The arguments passed to swift test in the Xcode version 16.1 job."
default: ""
xcode_16_1_setup_command:
type: string
description: "The command(s) to be executed before all other work."
default: ""
xcode_16_2_enabled:
type: boolean
description: "Boolean to enable the Xcode version 16.2 jobs. Defaults to true."
default: true
xcode_16_2_build_arguments_override:
type: string
description: "The arguments passed to swift build in the Xcode version 16.2 job."
default: ""
xcode_16_2_test_arguments_override:
type: string
description: "The arguments passed to swift test in the Xcode version 16.2 job."
default: ""
xcode_16_2_setup_command:
type: string
description: "The command(s) to be executed before all other work."
default: ""
xcode_16_3_enabled:
type: boolean
description: "Boolean to enable the Xcode version 16.3 jobs. Defaults to true."
default: true
xcode_16_3_build_arguments_override:
type: string
description: "The arguments passed to swift build in the Xcode version 16.3 job."
default: ""
xcode_16_3_test_arguments_override:
type: string
description: "The arguments passed to swift test in the Xcode version 16.3 job."
default: ""
xcode_16_3_setup_command:
type: string
description: "The command(s) to be executed before all other work."
default: ""
xcode_26_beta_enabled:
type: boolean
description: "Boolean to enable the Xcode version 26 beta 1 jobs. Defaults to true."
default: true
xcode_26_beta_1_build_arguments_override:
type: string
description: "The arguments passed to swift build in the Xcode version 26 beta 1 job."
default: ""
xcode_26_beta_1_test_arguments_override:
type: string
description: "The arguments passed to swift test in the Xcode version 26 beta 1 job."
default: ""
xcode_26_beta_1_setup_command:
type: string
description: "The command(s) to be executed before all other work."
default: ""

build_scheme:
type: string
description: "The build scheme used in the Xcode builds."
swift_test_enabled:
type: boolean
description: "Boolean to enable test execution with `swift test`. Defaults to true."
default: true
macos_xcode_build_enabled:
type: boolean
description: "Boolean to enable the Xcode build targeting macOS. Defaults to true."
default: true
macos_xcode_test_enabled:
type: boolean
description: "Boolean to enable the Xcode test targeting macOS. Defaults to false."
default: false
ios_xcode_build_enabled:
type: boolean
description: "Boolean to enable the Xcode build targeting iOS. Defaults to true."
default: true
ios_xcode_test_enabled:
type: boolean
description: "Boolean to enable the Xcode test targeting iOS. Defaults to false."
default: false
watchos_xcode_build_enabled:
type: boolean
description: "Boolean to enable the Xcode build targeting watchOS. Defaults to true."
default: true
watchos_xcode_test_enabled:
type: boolean
description: "Boolean to enable the Xcode test targeting watchOS. Defaults to false."
default: false
tvos_xcode_build_enabled:
type: boolean
description: "Boolean to enable the Xcode build targeting tvOS. Defaults to true."
default: true
tvos_xcode_test_enabled:
type: boolean
description: "Boolean to enable the Xcode test targeting tvOS. Defaults to false."
default: false
visionos_xcode_build_enabled:
type: boolean
description: "Boolean to enable the Xcode build targeting visionOS. Defaults to true."
default: true
visionos_xcode_test_enabled:
type: boolean
description: "Boolean to enable the Xcode test targeting visionOS. Defaults to false."
default: false

runner_pool:
type: string
description: "The runner pool which will be requested."
default: "nightly"

jobs:
construct-matrix:
name: Construct Darwin matrix
runs-on: ubuntu-latest
outputs:
darwin-matrix: '${{ steps.generate-matrix.outputs.darwin-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- id: generate-matrix
run: |
cat >> "$GITHUB_OUTPUT" << EOM
darwin-matrix=$(
runner_pool="${MATRIX_RUNNER_POOL:="nightly"}"
xcode_15_4_enabled="${MATRIX_MACOS_15_4_ENABLED:=true}"
xcode_15_4_build_arguments_override="${MATRIX_MACOS_15_4_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_15_4_test_arguments_override="${MATRIX_MACOS_15_4_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_15_4_setup_command="${MATRIX_MACOS_15_4_SETUP_COMMAND:=""}"
xcode_16_0_enabled="${MATRIX_MACOS_16_0_ENABLED:=true}"
xcode_16_0_build_arguments_override="${MATRIX_MACOS_16_0_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_16_0_test_arguments_override="${MATRIX_MACOS_16_0_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_16_0_setup_command="${MATRIX_MACOS_16_0_SETUP_COMMAND:=""}"
xcode_16_1_enabled="${MATRIX_MACOS_16_1_ENABLED:=true}"
xcode_16_1_build_arguments_override="${MATRIX_MACOS_16_1_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_16_1_test_arguments_override="${MATRIX_MACOS_16_1_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_16_1_setup_command="${MATRIX_MACOS_16_1_SETUP_COMMAND:=""}"
xcode_16_2_enabled="${MATRIX_MACOS_16_2_ENABLED:=true}"
xcode_16_2_build_arguments_override="${MATRIX_MACOS_16_2_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_16_2_test_arguments_override="${MATRIX_MACOS_16_2_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_16_2_setup_command="${MATRIX_MACOS_16_2_SETUP_COMMAND:=""}"
xcode_16_3_enabled="${MATRIX_MACOS_16_3_ENABLED:=true}"
xcode_16_3_build_arguments_override="${MATRIX_MACOS_16_3_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_16_3_test_arguments_override="${MATRIX_MACOS_16_3_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_16_3_setup_command="${MATRIX_MACOS_16_3_SETUP_COMMAND:=""}"
xcode_26_beta_1_enabled="${MATRIX_MACOS_26_BETA_1_ENABLED:=true}"
xcode_26_beta_1_build_arguments_override="${MATRIX_MACOS_26_BETA_1_BUILD_ARGUMENTS_OVERRIDE:=""}"
xcode_26_beta_1_test_arguments_override="${MATRIX_MACOS_26_BETA_1_TEST_ARGUMENTS_OVERRIDE:=""}"
xcode_26_beta_1_setup_command="${MATRIX_MACOS_26_BETA_1_SETUP_COMMAND:=""}"

# Create matrix from inputs
matrix='{"config": []}'

if [[ "$xcode_15_4_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_15_4_setup_command" \
--arg build_arguments_override "$xcode_15_4_build_arguments_override" \
--arg test_arguments_override "$xcode_15_4_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

if [[ "$xcode_16_0_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_16_0_setup_command" \
--arg build_arguments_override "$xcode_16_0_build_arguments_override" \
--arg test_arguments_override "$xcode_16_0_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

if [[ "$xcode_16_1_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_16_1_setup_command" \
--arg build_arguments_override "$xcode_16_1_build_arguments_override" \
--arg test_arguments_override "$xcode_16_1_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

if [[ "$xcode_16_2_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_16_2_setup_command" \
--arg build_arguments_override "$xcode_16_2_build_arguments_override" \
--arg test_arguments_override "$xcode_16_2_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

if [[ "$xcode_16_3_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_16_3_setup_command" \
--arg build_arguments_override "$xcode_16_3_build_arguments_override" \
--arg test_arguments_override "$xcode_16_3_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

if [[ "$xcode_26_beta_1_enabled" == "true" ]]; then
matrix=$(echo "$matrix" | jq -c \
--arg setup_command "$xcode_26_beta_1_setup_command" \
--arg build_arguments_override "$xcode_26_beta_1_build_arguments_override" \
--arg test_arguments_override "$xcode_26_beta_1_test_arguments_override" \
--arg runner_pool "$runner_pool" \
'.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 }')
fi

echo "$matrix" | jq -c
)"
EOM
env:
MATRIX_RUNNER_POOL: ${{ inputs.runner_pool }}
MATRIX_MACOS_15_4_ENABLED: ${{ inputs.xcode_15_4_enabled }}
MATRIX_MACOS_15_4_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_15_4_build_arguments_override }}
MATRIX_MACOS_15_4_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_15_4_test_arguments_override }}
MATRIX_MACOS_15_4_SETUP_COMMAND: ${{ inputs.xcode_15_4_setup_command }}
MATRIX_MACOS_16_0_ENABLED: ${{ inputs.xcode_16_0_enabled }}
MATRIX_MACOS_16_0_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_0_build_arguments_override }}
MATRIX_MACOS_16_0_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_0_test_arguments_override }}
MATRIX_MACOS_16_0_SETUP_COMMAND: ${{ inputs.xcode_16_0_setup_command }}
MATRIX_MACOS_16_1_ENABLED: ${{ inputs.xcode_16_1_enabled }}
MATRIX_MACOS_16_1_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_1_build_arguments_override }}
MATRIX_MACOS_16_1_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_1_test_arguments_override }}
MATRIX_MACOS_16_1_SETUP_COMMAND: ${{ inputs.xcode_16_1_setup_command }}
MATRIX_MACOS_16_2_ENABLED: ${{ inputs.xcode_16_2_enabled }}
MATRIX_MACOS_16_2_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_2_build_arguments_override }}
MATRIX_MACOS_16_2_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_2_test_arguments_override }}
MATRIX_MACOS_16_2_SETUP_COMMAND: ${{ inputs.xcode_16_2_setup_command }}
MATRIX_MACOS_16_3_ENABLED: ${{ inputs.xcode_16_3_enabled }}
MATRIX_MACOS_16_3_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_3_build_arguments_override }}
MATRIX_MACOS_16_3_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_16_3_test_arguments_override }}
MATRIX_MACOS_16_3_SETUP_COMMAND: ${{ inputs.xcode_16_3_setup_command }}
MATRIX_MACOS_26_BETA_1_ENABLED: ${{ inputs.xcode_26_beta_1_enabled }}
MATRIX_MACOS_26_BETA_1_BUILD_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_26_beta_1_build_arguments_override }}
MATRIX_MACOS_26_BETA_1_TEST_ARGUMENTS_OVERRIDE: ${{ inputs.xcode_26_beta_1_test_arguments_override }}
MATRIX_MACOS_26_BETA_1_SETUP_COMMAND: ${{ inputs.xcode_26_beta_1_setup_command }}

darwin-job:
name: ${{ matrix.config.name }}
needs: construct-matrix
runs-on: [self-hosted, macos, "${{ matrix.config.os }}", "${{ matrix.config.arch }}", "${{ matrix.config.pool }}"]
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.construct-matrix.outputs.darwin-matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
- name: Setup command
run: |
if [ -n "${{ matrix.config.setup_command }}" ]; then
bash -c "${{ matrix.config.setup_command }}"
fi
- name: Swift build
run: |
if [ -n "${{ matrix.config.build_arguments_override }}" ]; then
swift build ${{ matrix.config.build_arguments_override }}
else
swift build --build-tests
fi
- name: Swift test
if: 'inputs.swift_test_enabled'
run: |
if [ -n "${{ matrix.config.test_arguments_override }}" ]; then
swift test ${{ matrix.config.test_arguments_override }}
else
swift test
fi
# see `xcodebuild -list` for schemes, `simctl list` for destinations
- name: macOS build
if: '!cancelled() && inputs.macos_xcode_build_enabled'
run: /usr/bin/xcodebuild -quiet -scheme ${BUILD_SCHEME} -destination "generic/platform=macos" build
- name: macOS test
if: '!cancelled() && inputs.macos_xcode_test_enabled'
run: /usr/bin/xcodebuild -quiet -scheme ${BUILD_SCHEME} -destination "name=My Mac" test
env:
XCODE_VERSION: ${{ matrix.config.xcode_version }}
DEVELOPER_DIR: "/Applications/Xcode_${{ matrix.config.xcode_version }}.app"
BUILD_SCHEME: ${{ inputs.build_scheme }}
19 changes: 19 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ jobs:
- name: Gradle compile JMH benchmarks
run: ./gradlew compileJmh --info

# macos-tests:
# name: macOS tests
# # Workaround https://github.com/nektos/act/issues/1875
# uses: swiftlang/swift-java/.github/workflows/macos_tests.yml@wip-macos-ci
# with:
# build_scheme: SwiftJava-Package

macos-tests-selfhosted:
name: Swift tests (macOS Sequoia ARM64)
runs-on: [self-hosted, macos, sequoia, ARM64]
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and Test
run: swift test
timeout-minutes: 20

test-swift:
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
runs-on: ubuntu-latest
Expand Down
Loading