Repository navigation
196 lines (176 loc) · 8.08 KB
/
Copy pathstudio-api-smoke.yml
File metadata and controls
196 lines (176 loc) · 8.08 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
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
# HTTP-level integration tests for the FastAPI surface (tests/studio/studio_api_smoke.py).
name: Unsloth API CI
on:
pull_request:
paths:
# Only what the test boots: backend, installer and CLI. The install is --no-torch and the
# frontend is never served.
- 'studio/backend/**'
- 'studio/setup.sh'
- 'studio/install_*.py'
- 'studio/node_prebuilt_pins.json'
- 'studio/prebuilt_core.py'
- 'studio/install_manifest.py'
- 'unsloth_cli/**'
- 'install.sh'
- 'pyproject.toml'
# Named, not globbed: the rest of tests/studio is Playwright drivers.
- 'tests/studio/studio_api_smoke.py'
# Reached by the installers this workflow triggers on.
- 'studio/nvidia_probe.py'
- '.github/workflows/studio-api-smoke.yml'
- '.github/scripts/retry-with-apt-lock.sh'
- '.github/scripts/boot-studio-api-only.sh'
- '.github/scripts/wait-for-health.sh'
- '.github/scripts/hf-download-with-retry.sh'
# The install step in this workflow is `uses:` on that composite action.
- '.github/actions/install-unsloth-local/action.yml'
- '.github/actions/frontend-dist-restore/action.yml'
- '.github/actions/frontend-dist-save/action.yml'
- '.github/actions/uv-cache-restore/action.yml'
- '.github/actions/uv-cache-save/action.yml'
push:
branches: [main]
paths:
- 'studio/backend/**'
- 'studio/setup.sh'
- 'studio/install_*.py'
- 'studio/node_prebuilt_pins.json'
- 'studio/prebuilt_core.py'
- 'studio/install_manifest.py'
- 'unsloth_cli/**'
- 'install.sh'
- 'pyproject.toml'
- 'tests/studio/studio_api_smoke.py'
- 'studio/nvidia_probe.py'
- '.github/workflows/studio-api-smoke.yml'
- '.github/scripts/retry-with-apt-lock.sh'
- '.github/scripts/boot-studio-api-only.sh'
- '.github/scripts/wait-for-health.sh'
- '.github/scripts/hf-download-with-retry.sh'
- '.github/actions/install-unsloth-local/action.yml'
- '.github/actions/frontend-dist-restore/action.yml'
- '.github/actions/frontend-dist-save/action.yml'
- '.github/actions/uv-cache-restore/action.yml'
- '.github/actions/uv-cache-save/action.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
# Latest-only on a PR branch. On main, cancel-in-progress is false so a RUNNING run is
# never killed, and a newer push replaces only the PENDING one: a merge burst runs the
# commit already executing plus the tip. See studio-backend-ci.yml for the trade.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
api-smoke:
name: Unsloth API & Auth Tests
runs-on: ubuntu-latest
# Sized for the apt step's bounded worst case (13m) plus the smoke.
timeout-minutes: 20
env:
GGUF_REPO: unsloth/gemma-3-270m-it-GGUF
GGUF_VARIANT: UD-Q4_K_XL
GGUF_FILE: gemma-3-270m-it-UD-Q4_K_XL.gguf
STUDIO_PORT: '18893'
HF_HOME: ${{ github.workspace }}/hf-cache
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Linux deps
# Bounded and retried: a hung apt step is reported as `cancelled` with no reason.
# update + install retry as one unit; two long attempts, since slow mirrors are common.
timeout-minutes: 15
env:
RETRY_ATTEMPTS: '2'
RETRY_ATTEMPT_TIMEOUT: '360'
run: |
bash .github/scripts/retry-with-apt-lock.sh sudo sh -c \
'apt-get install -y --no-install-recommends libcurl4-openssl-dev libssl-dev jq || { apt-get update && apt-get install -y --no-install-recommends libcurl4-openssl-dev libssl-dev jq; }'
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: '3.12'
# Cross-OS key: the hf-cache tree is byte-identical on every OS.
- name: Restore HF_HOME for ${{ env.GGUF_REPO }}
id: cache-hf
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
continue-on-error: true
with:
path: hf-cache
key: hf-${{ env.GGUF_REPO }}-${{ env.GGUF_VARIANT }}-v3
enableCrossOsArchive: true
- name: Prime HF_HOME with the GGUF
id: prime-hf
if: steps.cache-hf.outputs.cache-hit != 'true' || steps.cache-hf.outcome != 'success'
env:
# Withheld on PR: this step runs checked-out PR code; public GGUF still downloads.
HF_TOKEN: ${{ github.event_name != 'pull_request' && secrets.HF_TOKEN || '' }}
run: |
python -m pip install --upgrade huggingface_hub
mkdir -p hf-cache
bash .github/scripts/hf-download-with-retry.sh "$GGUF_REPO" "$GGUF_FILE"
bash .github/scripts/hf-download-with-retry.sh ggml-org/models tinyllamas/stories260K.gguf
- name: Save HF_HOME for ${{ env.GGUF_REPO }}
# Save on main only: PR-scoped caches only serve that PR and evict main's shared copies
# from the near-full repo cache budget.
if: always() && github.ref == 'refs/heads/main' && steps.prime-hf.outcome == 'success' && hashFiles('hf-cache/**/*.gguf') != ''
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: hf-cache
key: hf-${{ env.GGUF_REPO }}-${{ env.GGUF_VARIANT }}-v3
enableCrossOsArchive: true
- name: Install Unsloth (--local, --no-torch)
uses: ./.github/actions/install-unsloth-local
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
# Withheld on PR: this step runs checked-out PR code; public GGUF still downloads.
hf-token: ${{ github.event_name != 'pull_request' && secrets.HF_TOKEN || '' }}
- name: Install pyjwt for the JWT-expiry forge test
run: pip install 'pyjwt>=2.6'
- name: Reset auth + boot Unsloth (API-only)
run: |
# Wipe (not reset-password): the boot below must re-seed a fresh .bootstrap_password.
bash .github/scripts/boot-studio-api-only.sh --port "$STUDIO_PORT"
- name: Wait for /api/health
run: |
bash .github/scripts/wait-for-health.sh --port "$STUDIO_PORT"
- name: Pass bootstrap password + rotated targets to the test
# Pre-mint the rotated passwords the test uses, masked.
run: |
OLD=$(cat ~/.unsloth/studio/auth/.bootstrap_password)
NEW="ApiSmoke-$(python -c 'import secrets; print(secrets.token_urlsafe(16))')"
NEW2="ApiSmoke-$(python -c 'import secrets; print(secrets.token_urlsafe(16))')"
echo "::add-mask::$OLD"
echo "::add-mask::$NEW"
echo "::add-mask::$NEW2"
echo "STUDIO_OLD_PW=$OLD" >> "$GITHUB_ENV"
echo "STUDIO_NEW_PW=$NEW" >> "$GITHUB_ENV"
echo "STUDIO_NEW2_PW=$NEW2" >> "$GITHUB_ENV"
- name: Run Unsloth API & Auth tests
# Not named test_*: Backend CI's pytest walk would collect it without BASE_URL.
env:
BASE_URL: http://127.0.0.1:18893
STUDIO_AUTH_DIR: /home/runner/.unsloth/studio/auth
run: python tests/studio/studio_api_smoke.py
- name: Stop Unsloth
if: always()
run: |
kill "${STUDIO_PID}" 2>/dev/null || true
# Wait for it to actually exit (was a flat `sleep 2`); SIGKILL after 10 s.
for _ in $(seq 1 100); do kill -0 "${STUDIO_PID}" 2>/dev/null || break; sleep 0.1; done
kill -9 "${STUDIO_PID}" 2>/dev/null || true
- name: Upload API smoke logs
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: studio-api-smoke-log
path: |
logs/install.log
logs/studio.log
retention-days: 7