-
Notifications
You must be signed in to change notification settings - Fork 199
204 lines (176 loc) · 6.27 KB
/
pull_request.yml
File metadata and controls
204 lines (176 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Build and Test
on: pull_request
permissions:
contents: read
jobs:
lint:
if: github.repository == 'ml-explore/mlx-swift'
runs-on: ubuntu-latest
container:
image: swift:6.2-rhel-ubi9
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
activate-environment: true
- name: Setup pre-commit
shell: sh
run: |
uv pip install pre-commit
- name: Get swift-format tag
id: swift-format
shell: sh
run: |
cd /tmp
LATEST_TAG=$(curl -s https://api.github.com/repos/swiftlang/swift-format/releases/latest | \
grep '"tag_name":' | \
sed -E 's/.*"([^"]+)".*/\1/')
echo "swift-format $LATEST_TAG"
echo "SWIFT_FORMAT_VERSION=$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Cache swift-format build
uses: actions/cache@v4
id: cache-swift-format
with:
path: /tmp/swift-format/.build
key: ${{ runner.os }}-swift-format-build-${{ steps.swift-format.outputs.SWIFT_FORMAT_VERSION }}
- name: Build swift-format
if: steps.cache-swift-format.outputs.cache-hit != 'true'
shell: sh
run: |
cd /tmp
git clone --branch ${{ steps.swift-format.outputs.SWIFT_FORMAT_VERSION }} --depth 1 https://github.com/swiftlang/swift-format.git
cd swift-format
swift build -c release
- name: Link swift-format to /usr/local/bin
shell: sh
run: |
cd /tmp/swift-format
ln -s "$(swift build --show-bin-path -c release)/swift-format" /usr/local/bin/swift-format
- name: Configure safe directory for git
shell: sh
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Run style checks
shell: sh
run: |
pre-commit run --all || (echo "Style checks failed, please install pre-commit and run pre-commit run --all and push the change"; echo ""; git --no-pager diff; exit 1)
docs:
needs: lint
if: github.repository == 'ml-explore/mlx-swift'
runs-on: [self-hosted, macos]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Verify documentation
run: scripts/verify-docs.sh
mac_build_and_test:
needs: lint
if: github.repository == 'ml-explore/mlx-swift'
runs-on: [self-hosted, macos]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Verify MetalToolchain installed
shell: bash
run: xcodebuild -showComponent MetalToolchain
- name: Setup cmake
shell: sh
run: |
brew install cmake ninja
- name: Build SwiftPM (Xcode, macOS)
shell: sh
run: |
xcodebuild -version
xcrun --show-sdk-build-version
swift --version
rm -rf ~/Library/Developer/Xcode/DerivedData/*
xcodebuild build-for-testing -scheme mlx-swift-Package -destination 'platform=macOS'
- name: Run Tests SwiftPM (Xcode, macOS)
shell: sh
run: |
xcrun xctest ~/Library/Developer/Xcode/DerivedData/mlx-swift-*/Build/Products/Debug/CmlxTests.xctest
xcrun xctest ~/Library/Developer/Xcode/DerivedData/mlx-swift-*/Build/Products/Debug/MLXTests.xctest
- name: Build xcodeproj (Xcode, macOS)
shell: sh
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData/*
cd xcode
xcodebuild build-for-testing -scheme MLX -destination 'platform=macOS'
- name: Run Tests xcodeproj (Xcode, macOS)
working-directory: xcode
run: ../.github/scripts/run-xcode-tests.sh
- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
~/Library/Developer/Xcode/DerivedData/**/Logs/Test/*.xcresult
/Users/runner/Library/Developer/Xcode/DerivedData/**/Logs/Test/*.xcresult
~/Library/Logs/DiagnosticReports/*
retention-days: 7
- name: Build (cmake)
shell: sh
run: |
rm -rf build
mkdir build
cd build
cmake .. -G Ninja
ninja
linux_build_cmake_container:
name: Linux Container CMake Swift Build (${{ matrix.container }} ${{ matrix.arch }})
needs: lint
strategy:
fail-fast: false
matrix:
include:
# See https://github.com/swiftlang/swift-docker/tree/main/
- host: ubuntu-22.04
arch: x86_64
container: swift:bookworm
- host: ubuntu-22.04
arch: x86_64
container: swift:fedora39
- host: ubuntu-22.04-arm
arch: aarch64
container: swift:bookworm
- host: ubuntu-22.04-arm
arch: aarch64
container: swift:fedora39
runs-on: ${{ matrix.host }}
container:
image: ${{ matrix.container }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Linux Container CMake Swift Build - No Release
run: |
bash .github/scripts/setup+build-linux-container-cmake.sh
linux_build_cmake_cuda:
name: Linux CUDA CMake Swift Build (cuda-12.9, swift-6.2.3-RELEASE, ubuntu-24.04, x86_64)
needs: lint
runs-on: "gpu-t4-4-core"
env:
# Note 12/18/2025: the CI machine does not meet CUDA 13's driver requirement.
# Compatibility matrix:
# https://docs.nvidia.com/deeplearning/cudnn/backend/latest/reference/support-matrix.html
TOOLKIT_VERSION: "cuda-12.9"
SWIFT_VERSION: "swift-6.2.3-RELEASE"
# pub rsa4096 2024-09-16 [SC] [expires: 2026-09-16]
# 52BB7E3DE28A71BE22EC05FFEF80A866B47A981F
# uid [ unknown] Swift 6.x Release Signing Key <swift-infrastructure@forums.swift.org>
SWIFT_SIGNING_KEY: "52BB7E3DE28A71BE22EC05FFEF80A866B47A981F"
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Linux CUDA Setup
run: |
bash .github/scripts/setup-linux-cuda.sh
- name: Linux CUDA CMake Swift Build - No Release
run: |
bash .github/scripts/build-linux-cuda-cmake.sh