mlx-swift-examples prep for mlx-swift-lm 3.x release #44
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test | |
| on: pull_request | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| if: github.repository == 'ml-explore/mlx-swift-examples' | |
| runs-on: ubuntu-22.04 | |
| 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) | |
| mac_build_and_test: | |
| needs: lint | |
| if: github.repository == 'ml-explore/mlx-swift-examples' | |
| runs-on: [self-hosted, macos] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Verify MetalToolchain installed | |
| shell: bash | |
| env: | |
| # workaround for CI failure | |
| DEVELOPER_DIR: /Applications/Xcode-latest.app | |
| run: xcodebuild -showComponent MetalToolchain | |
| - name: Build Package (Xcode, macOS) | |
| shell: sh | |
| env: | |
| # workaround for CI failure | |
| DEVELOPER_DIR: /Applications/Xcode-latest.app | |
| run: | | |
| xcodebuild -version | |
| xcrun --show-sdk-build-version | |
| swift --version | |
| rm -rf ~/Library/Developer/Xcode/DerivedData/* | |
| xcodebuild build-for-testing -scheme mlx-libraries-Package -destination 'platform=macOS' | |
| - name: Build tools (Xcode, macOS) | |
| shell: sh | |
| env: | |
| # workaround for CI failure | |
| DEVELOPER_DIR: /Applications/Xcode-latest.app | |
| run: | | |
| xcodebuild -version | |
| xcrun --show-sdk-build-version | |
| swift --version | |
| find . -name Package.resolved -exec rm {} \; | |
| xcodebuild -scheme llm-tool | |
| xcodebuild -scheme image-tool | |
| xcodebuild -scheme mnist-tool |