11name : Tests
2+
23on :
34 pull_request :
45 branches :
78 branches :
89 - main
910
11+ # Auto-cancel stale runs on the same PR/branch
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+ cancel-in-progress : true
15+
1016env :
1117 REPO_ID : Qwen/Qwen2-0.5B-Instruct-GGUF
1218 MODEL_FILE : qwen2-0_5b-instruct-q8_0.gguf
1319
1420jobs :
15- download-model :
16- runs-on : ubuntu-latest
17- steps :
18- - name : Set up Python
19- uses : actions/setup-python@v5
20- with :
21- python-version : " 3.9"
22- - name : Install huggingface-hub
23- run : pip install huggingface-hub
24- - name : Download model
25- run : huggingface-cli download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }}
26- - name : Cache model
27- uses : actions/cache@v4
28- with :
29- path : ~/.cache/huggingface/hub
30- key : ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
31-
32- build-linux :
33- needs : download-model
34- runs-on : ubuntu-latest
21+ # Combined job for Linux, Windows, and macOS using a matrix strategy
22+ build-and-test :
23+ runs-on : ${{ matrix.os }}
3524 strategy :
25+ # Don't cancel other jobs in the matrix if one fails
26+ fail-fast : false
3627 matrix :
37- python-version : ["3.9", "3.10", "3.11", "3.12"]
38- steps :
39- - uses : actions/checkout@v4
40- with :
41- submodules : " recursive"
42-
43- - name : Set up Python ${{ matrix.python-version }}
44- uses : actions/setup-python@v5
45- with :
46- python-version : ${{ matrix.python-version }}
47- cache : ' pip'
48- - name : Restore model cache
49- uses : actions/cache@v4
50- with :
51- path : ~/.cache/huggingface/hub
52- key : ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
53- - name : Install dependencies (Linux/MacOS)
54- run : |
55- python -m pip install --upgrade pip
56- python -m pip install uv
57- python -m uv pip install -e .[all] --verbose
58- shell : bash
59- - name : Test with pytest
60- run : |
61- python -m pytest
28+ os : [ubuntu-latest, windows-latest, macos-13]
29+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13"]
6230
63- build-windows :
64- needs : download-model
65- runs-on : windows-latest
66- strategy :
67- matrix :
68- python-version : ["3.9", "3.10", "3.11", "3.12"]
6931 steps :
70- - uses : actions/checkout@v4
32+ - name : Checkout repository
33+ uses : actions/checkout@v4
7134 with :
7235 submodules : " recursive"
73-
36+
7437 - name : Set up Python ${{ matrix.python-version }}
7538 uses : actions/setup-python@v5
7639 with :
7740 python-version : ${{ matrix.python-version }}
41+ # Use setup-python's built-in pip caching
7842 cache : ' pip'
7943
80- - name : Restore model cache
44+ - name : Cache HuggingFace model
45+ # Give this step an id to reference its output below
46+ id : model-cache
8147 uses : actions/cache@v4
8248 with :
8349 path : ~/.cache/huggingface/hub
8450 key : ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
8551
86- - name : Install dependencies (Windows)
52+ - name : Download model if not cached
53+ # Only run this step if the cache was not found
54+ if : steps.model-cache.outputs.cache-hit != 'true'
55+ run : |
56+ pip install huggingface-hub
57+ huggingface-cli download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }}
58+ shell : bash
59+
60+ - name : Install dependencies
8761 run : |
8862 python -m pip install --upgrade pip
8963 python -m pip install uv
9064 python -m uv pip install -e .[all] --verbose
91- shell : cmd
92-
93- - name : Test with pytest
94- run : |
95- python -m pytest
96-
97- build-macos :
98- needs : download-model
99- runs-on : macos-13
100- strategy :
101- matrix :
102- python-version : ["3.9", "3.10", "3.11", "3.12"]
103- steps :
104- - uses : actions/checkout@v4
105- with :
106- submodules : " recursive"
107-
108- - name : Set up Python ${{ matrix.python-version }}
109- uses : actions/setup-python@v5
110- with :
111- python-version : ${{ matrix.python-version }}
112- cache : ' pip'
113-
114- - name : System Info
115- run : |
116- uname -a
117- sysctl -n machdep.cpu.brand_string
118- python3 -c "import platform; print(platform.machine(), platform.architecture())"
65+ # FIX: Simplified shell to bash for all OSes
66+ shell : bash
11967
120- - name : Restore model cache
121- uses : actions/cache@v4
122- with :
123- path : ~/.cache/huggingface/hub
124- key : ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
125-
126- - name : Install dependencies (Linux/MacOS)
127- run : |
128- python3 -m pip install --upgrade pip
129- python3 -m pip install uv
130- python3 -m uv pip install -e .[all] --verbose
131- CMAKE_ARGS="-DLLAMA_METAL=off" python3 -m uv pip install .[all] --verbose
68+ - name : Install dependencies (macOS non-Metal)
69+ # Apply special compilation flags for the non-Metal macOS build
70+ if : runner.os == 'macOS'
71+ run : CMAKE_ARGS="-DLLAMA_METAL=off" python3 -m uv pip install .[all] --verbose
13272 shell : bash
13373
13474 - name : Test with pytest
135- run : |
136- python3 -m pytest
75+ run : python -m pytest
76+ # FIX: Simplified shell to bash for all OSes
77+ shell : bash
13778
79+ # Dedicated job for macOS with Metal support
13880 build-macos-metal :
139- needs : download-model
14081 runs-on : macos-13
14182 steps :
142- - uses : actions/checkout@v4
83+ - name : Checkout repository
84+ uses : actions/checkout@v4
14385 with :
14486 submodules : " recursive"
145-
87+
14688 - name : Set up Python 3.9
14789 uses : actions/setup-python@v5
14890 with :
14991 python-version : " 3.9"
92+ cache : ' pip'
15093
15194 - name : System Info
15295 run : |
15396 uname -a
15497 sysctl -n machdep.cpu.brand_string
15598 python3 -c "import platform; print(platform.machine(), platform.architecture())"
99+ shell : bash
156100
157- - name : Restore model cache
101+ - name : Cache HuggingFace model
102+ id : model-cache
158103 uses : actions/cache@v4
159104 with :
160105 path : ~/.cache/huggingface/hub
161- key : ${{ runner.os }}-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
106+ # Use a distinct key to avoid cache conflicts
107+ key : ${{ runner.os }}-metal-model-${{ env.REPO_ID }}-${{ env.MODEL_FILE }}
162108
163- - name : Install dependencies
109+ - name : Download model if not cached
110+ if : steps.model-cache.outputs.cache-hit != 'true'
111+ run : |
112+ pip install huggingface-hub
113+ huggingface-cli download ${{ env.REPO_ID }} ${{ env.MODEL_FILE }}
114+ shell : bash
115+
116+ - name : Install dependencies (macOS Metal)
164117 run : |
165118 python3 -m pip install --upgrade pip
166119 CMAKE_ARGS="-DLLAMA_METAL=on" python3 -m pip install .[all] --verbose
167120 shell : bash
168121
169122 - name : Test with pytest
170- run : |
171- python3 -m pytest
123+ run : python3 -m pytest
124+ shell : bash
0 commit comments