Skip to content
Merged
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
78 changes: 29 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,14 @@ jobs:

# Swift 6.4's default build system compiles MLX's Metal shaders,
# and the Xcode 27 runner image doesn't include the Metal toolchain.
- name: Identify Xcode build
if: matrix.swift == '6.4'
id: xcode
run: echo "build=$(xcodebuild -version | awk '/Build version/ { print $3 }')" >> "$GITHUB_OUTPUT"

- name: Restore Metal toolchain download
if: matrix.swift == '6.4'
id: metal-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/metal-toolchain
key: ${{ runner.os }}-${{ runner.arch }}-metal-${{ steps.xcode.outputs.build }}

- name: Download Metal toolchain
if: matrix.swift == '6.4' && steps.metal-cache.outputs.cache-hit != 'true'
run: xcodebuild -downloadComponent MetalToolchain -exportPath "$HOME/.cache/metal-toolchain"

- name: Save Metal toolchain download
if: matrix.swift == '6.4' && steps.metal-cache.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/metal-toolchain
key: ${{ steps.metal-cache.outputs.cache-primary-key }}

# Downloading it takes seconds, less than restoring it from an 835 MB cache.
- name: Install Metal toolchain
if: matrix.swift == '6.4'
run: |
xcrun --kill-cache
if ! xcrun metal --version >/dev/null 2>&1; then
for bundle in "$HOME/.cache/metal-toolchain/"*.exportedBundle; do
xcodebuild -downloadComponent MetalToolchain -exportPath "$RUNNER_TEMP/metal-toolchain"
for bundle in "$RUNNER_TEMP/metal-toolchain/"*.exportedBundle; do
xcodebuild -importComponent MetalToolchain -importPath "$bundle"
done
xcrun --kill-cache
Expand All @@ -98,16 +76,20 @@ jobs:
# Only pushes to main save caches.
# A pull request's run can read main's caches but not another pull request's,
# and its saved caches would evict main's from the 10 GB repository limit.
# The cache leaves out .build/repositories, about 30 percent of its size.
# SwiftPM doesn't read those Git repositories while the checkouts match Package.resolved,
# and it fetches the ones it needs when a pin changes.
# On macOS, SwiftPM keeps its shared cache in ~/Library/Caches, which isn't cached.
- name: Restore Swift Package Manager cache
id: spm-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: ${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-spm-${{ hashFiles('Package.swift', 'Package.resolved') }}
.build/*
!.build/repositories
key: ${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-build-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-spm-
${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-build-

- name: Lint
run: swift format lint --strict --recursive .
Expand All @@ -119,20 +101,22 @@ jobs:
if: matrix.swift == '6.4'
run: rm -rf .build/out/Intermediates.noindex/XCBuildData/*.xcbuilddata

# Nothing in these jobs reads the index store.
# The Linux jobs keep it because test discovery on Linux reads it.
- name: Build
run: swift build --build-tests --traits MLX,Llama,CoreML${{ matrix.traits != '' && format(',{0}', matrix.traits) || '' }}
run: swift build --build-tests --disable-index-store --traits MLX,Llama,CoreML${{ matrix.traits != '' && format(',{0}', matrix.traits) || '' }}

- name: Save Swift Package Manager cache
if: steps.spm-cache.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
.build/*
!.build/repositories
key: ${{ steps.spm-cache.outputs.cache-primary-key }}

- name: Test
run: swift test --skip-build --traits MLX,Llama,CoreML${{ matrix.traits != '' && format(',{0}', matrix.traits) || '' }}
run: swift test --skip-build --disable-index-store --traits MLX,Llama,CoreML${{ matrix.traits != '' && format(',{0}', matrix.traits) || '' }}

build-watchos:
permissions:
Expand Down Expand Up @@ -200,16 +184,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Cache only .build. SwiftPM's shared cache, ~/.cache/org.swift.swiftpm,
# repeats the Git repositories in .build/repositories.
- name: Restore Swift Package Manager cache
id: spm-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: ${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-spm-${{ hashFiles('Package.swift', 'Package.resolved') }}
path: .build
key: ${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-build-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-spm-
${{ runner.os }}-swift-${{ matrix.swift }}-${{ matrix.traits == '' && 'ahc-off' || 'ahc-on' }}-build-

- name: Lint
run: swift format lint --strict --recursive .
Expand All @@ -221,9 +205,7 @@ jobs:
if: steps.spm-cache.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
path: .build
key: ${{ steps.spm-cache.outputs.cache-primary-key }}

- name: Test
Expand All @@ -246,16 +228,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

# Cache only .build. SwiftPM's shared cache, ~/.cache/org.swift.swiftpm,
# repeats the Git repositories in .build/repositories.
- name: Restore Swift Package Manager cache
id: spm-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
key: ${{ runner.os }}-swift-${{ matrix.swift }}-wasi-spm-${{ hashFiles('Package.swift', 'Package.resolved') }}
path: .build
key: ${{ runner.os }}-swift-${{ matrix.swift }}-wasi-build-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift-${{ matrix.swift }}-wasi-spm-
${{ runner.os }}-swift-${{ matrix.swift }}-wasi-build-

- name: Install Swift SDK for WASI
run: |
Expand All @@ -273,7 +255,5 @@ jobs:
if: steps.spm-cache.outputs.cache-hit != 'true' && github.event_name == 'push'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cache/org.swift.swiftpm
.build
path: .build
key: ${{ steps.spm-cache.outputs.cache-primary-key }}
Loading