Skip to content

build

build #184

Workflow file for this run

name: build
on:
push:
paths-ignore:
- '**/*.md' # .md files anywhere in the repo
- '**/LICENSE' # LICENSE files anywhere in the repo
- '**/.gitignore' # .gitignore files anywhere in the repo
- '**/*.png' # .png image files anywhere in the repo
- '**/*.pdf' # .pdf files anywhere in the repo
- '**/*.cursorrules' # .cursorrules files anywhere in the repo
pull_request:
paths-ignore:
- '**/*.md' # .md files anywhere in the repo
- '**/LICENSE' # LICENSE files anywhere in the repo
- '**/.gitignore' # .gitignore files anywhere in the repo
- '**/*.png' # .png image files anywhere in the repo
- '**/*.pdf' # .pdf files anywhere in the repo
- '**/*.cursorrules' # .cursorrules files anywhere in the repo
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs at 8 AM Singapore time (00:00 UTC) every day
env:
SCHEME: "XLKit-CI"
jobs:
macOS:
name: macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@main
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
- name: Unit Tests
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
- name: Test Runner
run: swift run XLKitTestRunner help
- name: Test Image Embedding
run: swift run XLKitTestRunner embed
macOS-swift6:
name: macOS (Swift 6)
runs-on: macos-latest
steps:
- uses: actions/checkout@main
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Set Package to Swift 6.0
run: swift package tools-version --set "6.0"
- name: Build
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
- name: Unit Tests
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=macOS" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
- name: Test Runner
run: swift run XLKitTestRunner help
- name: Test Image Embedding
run: swift run XLKitTestRunner embed
iOS:
name: iOS
runs-on: macos-latest
steps:
- uses: actions/checkout@main
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Boostrap Platforms
# Workaround for Xcode/GitHub runner issues finding simulators.
# see https://github.com/actions/runner-images/issues/12758#issuecomment-3206748945
run: xcrun simctl list
- name: Download Platform
# Workaround for Xcode/GitHub runner issues finding simulators.
# see https://github.com/actions/runner-images/issues/12758#issuecomment-3206748945
run: xcodebuild -downloadPlatform iOS
- name: Build
run: xcodebuild build -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "generic/platform=iOS Simulator,name=Any iOS Device" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}
- name: Prepare Destination Device Name
id: destnameprep
# As of GitHub's updates to the macOS-15 runner summer 2025, randomly Xcode may not list any simulators.
# No idea why. Seems like a bug or runner config issue. So to prevent false-positive job failures, we'll skip
# the unit tests if no devices are found, but mark the unit test step as cancelled. The job is still marked as
# passed (green), but the Unit Tests step will show cancelled. This is the best we can do, as there appears to
# be no way to "cancel" an individual job programmatically.
continue-on-error: true
shell: bash
run: |
xcodebuild -showdestinations -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" > destinations.txt
SIMPLATFORM="iOS"
SIMDEVICE="iPhone\s\d{2}\s"
REGEX="m/\{\splatform:(.*\sSimulator),.*OS:(\d{1,2}\.\d),.*name:([a-zA-Z0-9\(\)\s]*)\s\}/g"
SIMPATFORMLIST=$(cat destinations.txt | perl -nle 'if ('$REGEX') { ($plat, $os, $name) = ($1, $2, $3); if ($plat =~ /'$SIMPLATFORM'/ and $name =~ /'$SIMDEVICE'/) { print "- ${name} (${plat}) (${os})"; } }')
if [[ -z $SIMPATFORMLIST ]]; then echo "Error: no matching simulators available."; exit 1; fi
echo "Available $SIMPLATFORM simulators:"
echo "$SIMPATFORMLIST"
DESTNAME=$(cat destinations.txt | perl -nle 'if ('$REGEX') { ($plat, $os, $name) = ($1, $2, $3); if ($plat =~ /'$SIMPLATFORM'/ and $name =~ /'$SIMDEVICE'/) { print $name; } }' | sort -rV | head -n 1)
if [[ -z $DESTNAME ]]; then echo "Error: no matching simulators available."; exit 1; fi
echo "Using device name \"$DESTNAME\""
echo "DESTNAME=$DESTNAME" >> "$GITHUB_ENV"
- name: Unit Tests
if: steps.destnameprep.outcome != 'failure'
run: xcodebuild test -workspace ".swiftpm/xcode/package.xcworkspace" -scheme "$SCHEME" -destination "platform=iOS Simulator,name=$DESTNAME" | xcbeautify --renderer github-actions && exit ${PIPESTATUS[0]}