Skip to content

Commit

Permalink
first attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepitre committed Jan 9, 2025
1 parent afc956c commit d707172
Showing 1 changed file with 66 additions and 15 deletions.
81 changes: 66 additions & 15 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,77 @@
name: Swift
name: CI

on:
push:
pull_request:
branches:
- main
pull_request:
push:
branches:
- main

jobs:
build:
name: Swift Build and Test
build-and-test:
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
os: [macos-latest]
runs-on: ${{ matrix.os }}
platform: [macOS, iOS, tvOS, watchOS, visionOS]
swift: [5.10, 6.0] # Only run both versions on macOS
exclude:
- platform: iOS
swift: 6.0
- platform: tvOS
swift: 6.0
- platform: watchOS
swift: 6.0
- platform: visionOS
swift: 6.0
steps:
- uses: swift-actions/setup-swift@v2
- name: Get swift version
run: swift --version
- uses: actions/checkout@v4
- name: Build
run: swift build
- name: Run tests
run: swift test
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v2
with:
xcode-version: '16' # Required for visionOS support

- name: Set Swift version
if: ${{ matrix.platform == 'macOS' }}
run: |
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
swiftenv install ${{ matrix.swift }} || true
swiftenv global ${{ matrix.swift }}
swift --version
- name: Cache SPM dependencies
uses: actions/cache@v3
with:
path: |
~/.swiftpm
.build
key: ${{ runner.os }}-spm-${{ matrix.platform }}-${{ matrix.swift }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-${{ matrix.platform }}-${{ matrix.swift }}-
- name: Build and test for ${{ matrix.platform }} on Swift ${{ matrix.swift }}
run: |
set -o pipefail
case "${{ matrix.platform }}" in
macOS)
destination='platform=macOS'
;;
iOS)
destination='platform=iOS Simulator,name=iPhone 14'
;;
tvOS)
destination='platform=tvOS Simulator,name=Apple TV'
;;
watchOS)
destination='platform=watchOS Simulator,name=Apple Watch Series 8 (45mm)'
;;
visionOS)
destination='platform=visionOS Simulator,name=Vision Pro'
;;
esac
xcodebuild -scheme YourSchemeName \
-destination "$destination" \
clean build test | xcpretty

0 comments on commit d707172

Please sign in to comment.