-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (166 loc) · 7.2 KB
/
ci.yml
File metadata and controls
196 lines (166 loc) · 7.2 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
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
build-test:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install CMake
run: brew install cmake
- name: Setup Python for HuggingFace
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install HuggingFace CLI
run: pip install huggingface_hub
- name: Download test model from HuggingFace
run: |
mkdir -p models
huggingface-cli download mlx-community/Qwen1.5-0.5B-Chat-4bit --local-dir models/Qwen1.5-0.5B-Chat-4bit
echo "Model files:"
ls -la models/Qwen1.5-0.5B-Chat-4bit/
- name: Build native stub library
run: |
cmake -S native -B native/build -DCMAKE_BUILD_TYPE=Release
cmake --build native/build --target mlxsharp --config Release
mkdir -p src/MLXSharp.Native/runtimes/osx-arm64/native
cp native/build/libmlxsharp.dylib src/MLXSharp.Native/runtimes/osx-arm64/native/
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Show .NET info
run: dotnet --info
- name: Restore dependencies
run: dotnet restore MLXSharp.sln
- name: Build
run: dotnet build MLXSharp.sln --configuration Release --no-restore
- name: Copy native library to test output
run: |
TEST_OUTPUT="src/MLXSharp.Tests/bin/Release/net9.0"
mkdir -p "$TEST_OUTPUT/runtimes/osx-arm64/native"
cp src/MLXSharp.Native/runtimes/osx-arm64/native/libmlxsharp.dylib "$TEST_OUTPUT/runtimes/osx-arm64/native/"
ls -la "$TEST_OUTPUT/runtimes/osx-arm64/native/"
- name: Run tests
run: dotnet test MLXSharp.sln --configuration Release --no-build --logger "trx;LogFileName=TestResults.trx" --results-directory artifacts/test-results
env:
MLXSHARP_MODEL_PATH: ${{ github.workspace }}/models/Qwen1.5-0.5B-Chat-4bit
- name: Prepare artifact folders
run: |
mkdir -p artifacts/test-results
mkdir -p artifacts/packages
mkdir -p artifacts/native
cp src/MLXSharp.Native/runtimes/osx-arm64/native/libmlxsharp.dylib artifacts/native/
- name: Pack MLXSharp library
run: dotnet pack src/MLXSharp/MLXSharp.csproj --configuration Release --no-build --output artifacts/packages
- name: Pack MLXSharp.SemanticKernel library
run: dotnet pack src/MLXSharp.SemanticKernel/MLXSharp.SemanticKernel.csproj --configuration Release --no-build --output artifacts/packages
- name: Verify package contains native libraries
run: |
echo "Checking package contents..."
if unzip -l artifacts/packages/*.nupkg | grep -q "runtimes/osx-arm64/native/libmlxsharp.dylib"; then
echo "✓ Native library found in package"
else
echo "✗ ERROR: Native library NOT found in package!"
echo "Package contents:"
unzip -l artifacts/packages/*.nupkg
exit 1
fi
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: native-libs
path: artifacts/native
- name: Upload packages artifact
uses: actions/upload-artifact@v4
with:
name: packages
path: artifacts/packages
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: artifacts/test-results
release:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: build-test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from Directory.Build.props
id: version
run: |
VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
# - name: Check if tag exists
# id: check_tag
# run: |
# if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.version.outputs.version }}"; then
# echo "exists=true" >> $GITHUB_OUTPUT
# echo "Tag v${{ steps.version.outputs.version }} already exists"
# else
# echo "exists=false" >> $GITHUB_OUTPUT
# echo "Tag v${{ steps.version.outputs.version }} does not exist"
# fi
# - name: Download package artifacts
# if: steps.check_tag.outputs.exists == 'false'
# uses: actions/download-artifact@v4
# with:
# name: packages
# path: artifacts/packages
# - name: Publish to NuGet
# if: steps.check_tag.outputs.exists == 'false'
# run: |
# for package in artifacts/packages/*.nupkg; do
# echo "Publishing $package..."
# dotnet nuget push "$package" \
# --api-key ${{ secrets.NUGET_API_KEY }} \
# --source https://api.nuget.org/v3/index.json \
# --skip-duplicate || true
# done
# - name: Create Git tag
# if: steps.check_tag.outputs.exists == 'false'
# run: |
# git config user.name "github-actions[bot]"
# git config user.email "github-actions[bot]@users.noreply.github.com"
# git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
# git push origin "v${{ steps.version.outputs.version }}"
# - name: Generate release notes
# if: steps.check_tag.outputs.exists == 'false'
# id: release_notes
# run: |
# PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
# if [ -z "$PREVIOUS_TAG" ]; then
# COMMITS=$(git log --pretty=format:"- %s (%h)" --reverse)
# else
# COMMITS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --reverse)
# fi
# echo "## What's Changed" > release_notes.md
# echo "" >> release_notes.md
# echo "$COMMITS" >> release_notes.md
# echo "" >> release_notes.md
# echo "## NuGet Packages" >> release_notes.md
# echo "- [MLXSharp v${{ steps.version.outputs.version }}](https://www.nuget.org/packages/MLXSharp/${{ steps.version.outputs.version }})" >> release_notes.md
# echo "- [MLXSharp.SemanticKernel v${{ steps.version.outputs.version }}](https://www.nuget.org/packages/MLXSharp.SemanticKernel/${{ steps.version.outputs.version }})" >> release_notes.md
# cat release_notes.md
# - name: Create GitHub Release
# if: steps.check_tag.outputs.exists == 'false'
# uses: softprops/action-gh-release@v1
# with:
# tag_name: v${{ steps.version.outputs.version }}
# name: Release v${{ steps.version.outputs.version }}
# body_path: release_notes.md
# files: artifacts/packages/*
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}