forked from ml-explore/mlx-swift-lm
-
Notifications
You must be signed in to change notification settings - Fork 9
81 lines (69 loc) · 3.03 KB
/
Copy pathdownstream_integration.yml
File metadata and controls
81 lines (69 loc) · 3.03 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
name: Downstream Integration Test
on:
pull_request:
branches: [ main ]
jobs:
test-swiftlm-umbrella:
name: Test with SwiftLM (Umbrella Repo)
runs-on: macos-15
timeout-minutes: 40
steps:
- name: Checkout PR branch (mlx-swift-lm)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout SwiftLM (Parent Repo)
uses: actions/checkout@v4
with:
repository: SharpAI/SwiftLM
path: SwiftLM
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
- name: Point SwiftLM to this PR's mlx-swift-lm
# SwiftLM uses `.package(path: "./mlx-swift-lm")` so we replace that
# directory with the current PR checkout directly.
run: |
# Remove the pinned subdir and copy our PR checkout instead of symlinking to avoid git submodule errors
rm -rf SwiftLM/mlx-swift-lm
# Copy everything except SwiftLM itself if we are in the root
mkdir -p SwiftLM/mlx-swift-lm
find . -mindepth 1 -maxdepth 1 ! -name "SwiftLM" -exec cp -r {} SwiftLM/mlx-swift-lm/ \;
- name: Update mlx-swift submodule to latest main
# SwiftLM's mlx-swift submodule pin may lag behind main.
# Pull latest so new APIs are available for the build.
run: |
cd SwiftLM/mlx-swift
git fetch origin main
git checkout origin/main
- name: Install Metal Toolchain
run: xcodebuild -downloadComponent MetalToolchain || true
- name: Cache Swift packages
uses: actions/cache@v4
with:
path: SwiftLM/.build
key: ${{ runner.os }}-swiftlm-spm-${{ hashFiles('SwiftLM/Package.resolved') }}
restore-keys: ${{ runner.os }}-swiftlm-spm-
- name: Resolve Dependencies
run: swift package resolve
working-directory: SwiftLM
- name: Install MLX Metal library
run: |
python3 -m venv /tmp/mlx_venv
/tmp/mlx_venv/bin/pip install --quiet mlx
METALLIB=$(echo /tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib)
# Make it available system-wide for all subsequent steps
sudo cp "$METALLIB" /usr/local/lib/mlx.metallib || true
echo "MLX_METAL_LIB=$METALLIB" >> $GITHUB_ENV
- name: Build SwiftLM
run: swift build --build-tests
working-directory: SwiftLM
- name: Copy Metal library to build outputs
run: |
METALLIB="$MLX_METAL_LIB"
# Copy to all locations the test runner and linked bundles may search
find SwiftLM/.build -type d \( -name "debug" -o -name "release" \) -exec cp "$METALLIB" {}/ \; 2>/dev/null || true
find SwiftLM/.build -name "*.xctest" -exec cp "$METALLIB" {}/Contents/MacOS/ \; 2>/dev/null || true
find SwiftLM/.build -name "*Tests" -type f -exec sh -c 'cp "'"$METALLIB"'" "$(dirname ${1})/"' _ {} \; 2>/dev/null || true
- name: Run SwiftLM Integration Tests
run: swift test --parallel --skip-build
working-directory: SwiftLM