Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
14 changes: 14 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ jobs:
swift build
enable_windows_docker: false

tests_macos:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of test_with_docker? I would imagine that repos usually define one job that tests all the platforms. I would maybe rename test_with_docker to Test in that case and then we just have test_without_docker left to test Windows without Docker (and could probably rename to test_windows_without_docker.

name: Test
uses: ./.github/workflows/swift_package_test.yml
with:
enable_linux_checks: false
enable_windows_checks: false
# macOS
enable_macos_checks: true
macos_build_command: |
mkdir MyPackage
cd MyPackage
xcrun swift package init --type library
xcrun swift build

soundness:
name: Soundness
uses: ./.github/workflows/soundness.yml
Expand Down
68 changes: 67 additions & 1 deletion .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
name: Swift Linux Matrix
name: Swift Matrix

on:
workflow_call:
inputs:
macos_xcode_versions:
type: string
description: "Exclude Xcode version list (JSON)"
default: "[\"15.4\", \"16.0\", \"16.1\", \"16.2\"]"
macos_exclude_xcode_versions:
type: string
description: "Exclude Xcode version list (JSON)"
default: "[{\"xcode_version\": \"\"}]"
macos_versions:
type: string
description: "macOS version list (JSON)"
default: "[\"sequoia\"]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally would have probably chosen the release version number (eg. 15 for Sequioa) instead of the marketing name but don’t have strong opinions here. Also just checking: We don’t want to add minor-version fidelity here (eg. the ability to select 15.4 instead of 15.0 or something like that)?

Finally, I think this assumes that we also have a self-hosted runner for this arch + macOS version combination, right? Maybe worth pointing that out in a comment, eg. something like This requires a self-hosted macOS runner with this version to be set up.

If we don’t have near-term plans to support multiple OSs and arches, I would probably remove the option to not give users a false sense that they can test all macOS + arch + Xcode versions.

macos_archs:
type: string
description: "macOS arch list (JSON)"
default: "[\"ARM64\"]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as with the macOS version, I would add a comment like: This requires a self-hosted macOS runner with this architecture to be set up.

linux_swift_versions:
type: string
description: "Include Linux Swift version list (JSON)"
Expand Down Expand Up @@ -35,6 +51,14 @@ on:
type: string
description: "Linux command to execute before building the Swift package"
default: ""
macos_pre_build_command:
type: string
description: "macOS command to execute before building the Swift package"
default: ""
macos_build_command:
type: string
description: "macOS command to build and test the package"
default: "xcrun swift test"
linux_build_command:
type: string
description: "Linux command to build and test the package"
Expand All @@ -50,6 +74,9 @@ on:
Note that Powershell does not automatically exit if a subcommand fails. The Invoke-Program utility is available to propagate non-zero exit codes.
It is strongly encouraged to run all command using `Invoke-Program` unless you want to continue on error eg. `Invoke-Program git apply patch.diff` instead of `git apply patch.diff`.
default: "swift test"
macos_env_vars:
description: "Newline separated list of environment variables"
type: string
linux_env_vars:
description: "Newline separated list of environment variables"
type: string
Expand All @@ -60,6 +87,10 @@ on:
type: boolean
description: "Boolean to enable linux testing. Defaults to true"
default: true
enable_macos_checks:
type: boolean
description: "Boolean to enable linux testing. Defaults to false"
default: false
enable_windows_checks:
type: boolean
description: "Boolean to enable windows testing. Defaults to true"
Expand All @@ -74,6 +105,41 @@ on:
default: false

jobs:
macos-build:
name: macOS (Xcode ${{ matrix.xcode_version }} - ${{ matrix.os_version }} - ${{ matrix.arch }})
if: ${{ inputs.enable_macos_checks }}
runs-on: [self-hosted, macos, "${{ matrix.os_version }}", "${{ matrix.arch }}"]
strategy:
fail-fast: false
matrix:
xcode_version: ${{ fromJson(inputs.macos_xcode_versions) }}
os_version: ${{ fromJson(inputs.macos_versions) }}
arch: ${{ fromJson(inputs.macos_archs) }}
exclude:
- ${{ fromJson(inputs.macos_exclude_xcode_versions) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Provide token
if: ${{ inputs.needs_token }}
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Set environment variables
if: ${{ inputs.macos_env_vars }}
run: |
for i in "${{ inputs.macos_env_vars }}"
do
printf "%s\n" $i >> $GITHUB_ENV
done
- name: Select Xcode
run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app" >> $GITHUB_ENV
- name: Swift version
run: xcrun swift --version
- name: Pre-build
run: ${{ inputs.macos_pre_build_command }}
- name: Build / Test
run: ${{ inputs.macos_build_command }}

linux-build:
name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
if: ${{ inputs.enable_linux_checks }}
Expand Down
Loading