Skip to content

Commit f3887a0

Browse files
Merge branch 'main' into feat/max-error-rate
2 parents 9872af4 + f1f8ca8 commit f3887a0

File tree

283 files changed

+29469
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+29469
-154
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Cleanup Dev
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
cleanup-ui-pr-preview:
9+
permissions:
10+
contents: write
11+
id-token: 'write'
12+
issues: write
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out gh-pages branch
17+
uses: actions/checkout@v3
18+
with:
19+
ref: gh-pages
20+
fetch-depth: 1
21+
22+
- name: Check if preview directory exists
23+
id: check-preview
24+
run: |
25+
if [ -d "ui/pr/${{ github.event.pull_request.number }}" ]; then
26+
echo "preview_exists=true" >> $GITHUB_OUTPUT
27+
echo "Preview directory exists for PR #${{ github.event.pull_request.number }}"
28+
else
29+
echo "preview_exists=false" >> $GITHUB_OUTPUT
30+
echo "No preview directory found for PR #${{ github.event.pull_request.number }}"
31+
fi
32+
33+
- name: Create an empty directory for cleanup
34+
if: steps.check-preview.outputs.preview_exists == 'true'
35+
run: mkdir -p empty
36+
37+
- name: Remove GitHub Pages Build
38+
if: steps.check-preview.outputs.preview_exists == 'true'
39+
uses: peaceiris/actions-gh-pages@v3
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
publish_dir: ./empty
43+
destination_dir: ui/pr/${{ github.event.pull_request.number }}
44+
keep_files: false
45+
user_name: ${{ github.actor }}
46+
user_email: ${{ github.actor }}@users.noreply.github.com
47+
publish_branch: gh-pages
48+
commit_message: 'chore: Clean up preview for PR #${{ github.event.pull_request.number }}'
49+
50+
- name: Log Cleanup Completion
51+
run: echo "Cleanup completed for PR \#${{ github.event.pull_request.number }}"
52+
53+
update-preview-comment:
54+
needs: [cleanup-ui-pr-preview]
55+
name: Update PR Comment
56+
permissions:
57+
pull-requests: write
58+
issues: write
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Update PR comment to reflect cleanup
62+
uses: peter-evans/find-comment@v2
63+
id: find-comment
64+
with:
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
issue-number: ${{ github.event.pull_request.number }}
67+
body-includes: '<!-- pr-preview-comment -->'
68+
69+
- name: Update PR comment to reflect cleanup
70+
if: steps.find-comment.outputs.comment-id != ''
71+
uses: peter-evans/create-or-update-comment@v3
72+
with:
73+
token: ${{ secrets.GITHUB_TOKEN }}
74+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
75+
issue-number: ${{ github.event.pull_request.number }}
76+
edit-mode: replace
77+
body: |
78+
<!-- pr-preview-comment -->
79+
🧹 The live preview for this PR has been removed.
80+
81+
- name: Log comment update status
82+
run: |
83+
if [ "${{ steps.find-comment.outputs.comment-id }}" != "" ]; then
84+
echo "Updated existing preview comment"
85+
else
86+
echo "No preview comment found to update"
87+
fi

.github/workflows/development.yml

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ jobs:
2121
- name: Run quality checks
2222
run: tox -e quality
2323

24+
ui-quality-checks:
25+
permissions:
26+
contents: "read"
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Node.js 22
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '22'
36+
37+
- name: Install dependencies
38+
run: npm ci
39+
40+
- name: Run quality and typing checks
41+
run: npm run lint
42+
2443
type-checks:
2544
runs-on: ubuntu-latest
2645
strategy:
@@ -37,6 +56,25 @@ jobs:
3756
- name: Run quality checks
3857
run: tox -e types
3958

59+
ui-type-checks:
60+
permissions:
61+
contents: "read"
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Check out code
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Node.js 22
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: '22'
71+
72+
- name: Install dependencies
73+
run: npm ci
74+
75+
- name: Run quality and typing checks
76+
run: npm run type-check
77+
4078
precommit-checks:
4179
runs-on: ubuntu-latest
4280
strategy:
@@ -51,7 +89,26 @@ jobs:
5189
- name: Install dependencies
5290
run: pip install pre-commit
5391
- name: Run pre-commit checks
54-
run: pre-commit run --all-files
92+
run: SKIP=ruff-format pre-commit run --all-files
93+
94+
ui-precommit-checks:
95+
permissions:
96+
contents: "read"
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Check out code
100+
uses: actions/checkout@v4
101+
102+
- name: Set up Node.js 22
103+
uses: actions/setup-node@v4
104+
with:
105+
node-version: '22'
106+
107+
- name: Install dependencies
108+
run: npm ci
109+
110+
- name: Run pre-commit checks
111+
run: npx husky run pre-commit
55112

56113
unit-tests:
57114
runs-on: ubuntu-latest
@@ -69,6 +126,25 @@ jobs:
69126
- name: Run unit tests
70127
run: tox -e test-unit -- -m "smoke or sanity"
71128

129+
ui-unit-tests:
130+
permissions:
131+
contents: "read"
132+
runs-on: ubuntu-latest
133+
steps:
134+
- name: Check out code
135+
uses: actions/checkout@v4
136+
137+
- name: Set up Node.js 22
138+
uses: actions/setup-node@v4
139+
with:
140+
node-version: '22'
141+
142+
- name: Install dependencies
143+
run: npm ci
144+
145+
- name: Run unit tests
146+
run: npm run test:unit
147+
72148
integration-tests:
73149
runs-on: ubuntu-latest
74150
strategy:
@@ -85,7 +161,28 @@ jobs:
85161
- name: Run integration tests
86162
run: tox -e test-integration -- -m smoke
87163

164+
ui-integration-tests:
165+
permissions:
166+
contents: "read"
167+
runs-on: ubuntu-latest
168+
steps:
169+
- name: Check out code
170+
uses: actions/checkout@v4
171+
172+
- name: Set up Node.js 22
173+
uses: actions/setup-node@v4
174+
with:
175+
node-version: '22'
176+
177+
- name: Install dependencies
178+
run: npm ci
179+
180+
- name: Run integration tests
181+
run: npm run test:integration
182+
88183
build:
184+
# Only build if the PR branch is local
185+
if: github.event.pull_request.head.repo.full_name == github.repository
89186
runs-on: ubuntu-latest
90187
strategy:
91188
matrix:
@@ -135,3 +232,129 @@ jobs:
135232
They will be retained for **up to 30 days**.
136233
`
137234
})
235+
236+
ui-pr-preview:
237+
needs: [ui-quality-checks, ui-precommit-checks, ui-unit-tests, ui-integration-tests]
238+
permissions:
239+
contents: write
240+
pull-requests: write
241+
issues: write
242+
runs-on: ubuntu-latest
243+
steps:
244+
- name: Check out code
245+
uses: actions/checkout@v3
246+
with:
247+
fetch-depth: 0
248+
249+
- name: Check if UI-related files changed
250+
id: check-changes
251+
run: |
252+
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
253+
CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
254+
SHOULD_BUILD=false
255+
256+
if echo "$CHANGED_FILES" | grep -q "^src/ui/"; then
257+
echo "UI source files changed"
258+
SHOULD_BUILD=true
259+
fi
260+
261+
echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
262+
echo "Should build: $SHOULD_BUILD"
263+
264+
- name: Install dependencies
265+
if: steps.check-changes.outputs.should_build == 'true'
266+
run: npm ci
267+
268+
- name: Build app to root
269+
if: steps.check-changes.outputs.should_build == 'true'
270+
id: build
271+
run: |
272+
# Export vars to ensure they are loaded before build
273+
export $(grep -v '^#' .env.development | xargs)
274+
275+
PR_NUMBER=${{ github.event.pull_request.number }}
276+
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
277+
278+
# Set asset prefix and base path with PR number
279+
ASSET_PREFIX=https://neuralmagic.github.io/guidellm/ui/pr/${PR_NUMBER}
280+
USE_MOCK_DATA=true
281+
BASE_PATH=/ui/pr/${PR_NUMBER}
282+
GIT_SHA=${{ github.sha }}
283+
export ASSET_PREFIX=${ASSET_PREFIX}
284+
export BASE_PATH=${BASE_PATH}
285+
export GIT_SHA=${GIT_SHA}
286+
export USE_MOCK_DATA=${USE_MOCK_DATA}
287+
npm run build
288+
289+
- name: Deploy to GitHub Pages
290+
if: steps.check-changes.outputs.should_build == 'true'
291+
uses: peaceiris/actions-gh-pages@v3
292+
with:
293+
github_token: ${{ secrets.GITHUB_TOKEN }}
294+
publish_dir: ./src/ui/out
295+
destination_dir: ui/pr/${{ steps.build.outputs.pr_number }}
296+
keep_files: false
297+
user_name: ${{ github.actor }}
298+
user_email: ${{ github.actor }}@users.noreply.github.com
299+
publish_branch: gh-pages
300+
commit_message: 'build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
301+
302+
- name: Set deployment url
303+
if: steps.check-changes.outputs.should_build == 'true'
304+
id: deploy
305+
run: |
306+
DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
307+
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
308+
309+
- name: Find PR comment
310+
if: steps.check-changes.outputs.should_build == 'true'
311+
uses: peter-evans/find-comment@v2
312+
id: find-comment
313+
with:
314+
token: ${{ secrets.GITHUB_TOKEN }}
315+
issue-number: ${{ github.event.pull_request.number }}
316+
body-includes: '<!-- pr-preview-comment -->'
317+
318+
- name: Post Deployment URL to PR
319+
if: steps.check-changes.outputs.should_build == 'true'
320+
uses: peter-evans/create-or-update-comment@v3
321+
with:
322+
token: ${{ secrets.GITHUB_TOKEN }}
323+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
324+
issue-number: ${{ github.event.pull_request.number }}
325+
edit-mode: replace
326+
body: |
327+
<!-- pr-preview-comment -->
328+
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
329+
*Last updated: ${{ github.sha }}*
330+
331+
- name: Skip build notification
332+
if: steps.check-changes.outputs.should_build == 'false'
333+
run: echo "Skipping UI preview build - no relevant files changed"
334+
335+
build-and-push-container:
336+
# Only build if the PR branch is local
337+
if: github.event.pull_request.head.repo.full_name == github.repository
338+
runs-on: ubuntu-latest
339+
permissions:
340+
packages: write
341+
steps:
342+
- name: Checkout
343+
uses: actions/checkout@v4
344+
- name: Buildah build
345+
id: build-image
346+
uses: redhat-actions/buildah-build@v2
347+
with:
348+
image: ${{ github.event.repository.name }}
349+
tags: "pr-${{ github.event.number }}"
350+
containerfiles: |
351+
./deploy/Containerfile
352+
- name: Push To ghcr.io
353+
id: push-to-ghcr
354+
uses: redhat-actions/push-to-registry@v2
355+
with:
356+
image: ${{ steps.build-image.outputs.image }}
357+
tags: ${{ steps.build-image.outputs.tags }}
358+
username: ${{ github.actor }}
359+
password: ${{ github.token }}
360+
registry: ghcr.io/${{ github.repository_owner }}

0 commit comments

Comments
 (0)