Skip to content
Open
Changes from 4 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
71 changes: 58 additions & 13 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,85 @@ permissions:
contents: read

jobs:
mac_build_and_test:
lint:
if: github.repository == 'ml-explore/mlx-swift'
runs-on: [self-hosted, macos]
runs-on: ubuntu-latest
container:
image: swift:6.2-rhel-ubi9
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Verify MetalToolchain installed
shell: bash
run: xcodebuild -showComponent MetalToolchain


- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
activate-environment: true

- name: Setup swift-format
- name: Setup pre-commit
shell: sh
run: |
uv pip install pre-commit
brew install swift-format

- name: Clone 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"
git clone --branch $LATEST_TAG --depth 1 https://github.com/swiftlang/swift-format.git
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-${{ needs.lint.outputs.SWIFT_FORMAT_VERSION }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an older version of the other PR, before it used steps.swift-format.outputs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right, let my sync this up

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, forgot to push!


- name: Build swift-format
if: steps.cache-swift-format.outputs.cache-hit != 'true'
shell: sh
run: |
cd /tmp/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: Setup cmake
- name: Configure safe directory for git
shell: sh
run: |
brew install cmake ninja
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'
runs-on: [self-hosted, macos]
steps:
- uses: actions/checkout@v5
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 (Xcode, macOS)
shell: sh
run: |
Expand Down