|
| 1 | +name: Downstream Integration Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test-swiftlm-umbrella: |
| 9 | + name: Test with SwiftLM (Umbrella Repo) |
| 10 | + runs-on: macos-15 |
| 11 | + timeout-minutes: 40 |
| 12 | + steps: |
| 13 | + - name: Checkout PR branch (mlx-swift) |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + fetch-depth: 0 |
| 17 | + path: mlx-swift-pr |
| 18 | + |
| 19 | + - name: Checkout SwiftLM (Parent Repo) |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + repository: SharpAI/SwiftLM |
| 23 | + path: SwiftLM |
| 24 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + submodules: recursive |
| 26 | + |
| 27 | + - name: Install Metal Toolchain |
| 28 | + run: xcodebuild -downloadComponent MetalToolchain || true |
| 29 | + |
| 30 | + - name: Resolve Dependencies (to populate SPM cache) |
| 31 | + run: swift package resolve |
| 32 | + working-directory: SwiftLM |
| 33 | + |
| 34 | + - name: Override mlx-swift dependency with PR checkout |
| 35 | + # SPM `package edit` puts a local editable copy of the package in |
| 36 | + # .build/checkouts; we then replace its contents with our PR branch. |
| 37 | + run: | |
| 38 | + swift package edit mlx-swift --path $GITHUB_WORKSPACE/mlx-swift-pr |
| 39 | + working-directory: SwiftLM |
| 40 | + |
| 41 | + - name: Install MLX Metal library |
| 42 | + run: | |
| 43 | + python3 -m venv /tmp/mlx_venv |
| 44 | + /tmp/mlx_venv/bin/pip install --quiet mlx |
| 45 | + METALLIB=$(echo /tmp/mlx_venv/lib/python*/site-packages/mlx/lib/mlx.metallib) |
| 46 | + # Make it available system-wide for all subsequent steps |
| 47 | + sudo cp "$METALLIB" /usr/local/lib/mlx.metallib || true |
| 48 | + echo "MLX_METAL_LIB=$METALLIB" >> $GITHUB_ENV |
| 49 | +
|
| 50 | + - name: Build SwiftLM |
| 51 | + run: swift build --build-tests |
| 52 | + working-directory: SwiftLM |
| 53 | + |
| 54 | + - name: Copy Metal library to build outputs |
| 55 | + run: | |
| 56 | + METALLIB="$MLX_METAL_LIB" |
| 57 | + # Copy to all locations the test runner and linked bundles may search |
| 58 | + find SwiftLM/.build -type d \( -name "debug" -o -name "release" \) -exec cp "$METALLIB" {}/ \; 2>/dev/null || true |
| 59 | + find SwiftLM/.build -name "*.xctest" -exec cp "$METALLIB" {}/Contents/MacOS/ \; 2>/dev/null || true |
| 60 | + find SwiftLM/.build -name "*Tests" -type f -exec sh -c 'cp "'"$METALLIB"'" "$(dirname ${1})"/' _ {} \; 2>/dev/null || true |
| 61 | +
|
| 62 | + - name: Run SwiftLM Integration Tests |
| 63 | + run: swift test --parallel --skip-build |
| 64 | + working-directory: SwiftLM |
0 commit comments