Skip to content

Commit 7ea1071

Browse files
committed
implement ui build pipeline and complete workflows
1 parent 2672132 commit 7ea1071

File tree

11 files changed

+828
-12
lines changed

11 files changed

+828
-12
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: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Development
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types: [opened, synchronize, reopened]
66

77
jobs:
@@ -33,6 +33,11 @@ jobs:
3333
with:
3434
ref: "${{ github.event.pull_request.merge_commit_sha }}"
3535

36+
- name: Set up Node.js 22
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '22'
40+
3641
- name: Install dependencies
3742
run: npm ci
3843

@@ -67,6 +72,11 @@ jobs:
6772
with:
6873
ref: "${{ github.event.pull_request.merge_commit_sha }}"
6974

75+
- name: Set up Node.js 22
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: '22'
79+
7080
- name: Install dependencies
7181
run: npm ci
7282

@@ -91,7 +101,7 @@ jobs:
91101
- name: Run pre-commit checks
92102
run: SKIP=ruff-format pre-commit run --all-files
93103

94-
ui-precommit-check:
104+
ui-precommit-checks:
95105
permissions:
96106
contents: "read"
97107
runs-on: ubuntu-latest
@@ -101,6 +111,11 @@ jobs:
101111
with:
102112
ref: "${{ github.event.pull_request.merge_commit_sha }}"
103113

114+
- name: Set up Node.js 22
115+
uses: actions/setup-node@v4
116+
with:
117+
node-version: '22'
118+
104119
- name: Install dependencies
105120
run: npm ci
106121

@@ -133,6 +148,11 @@ jobs:
133148
- name: Check out code
134149
uses: actions/checkout@v3
135150

151+
- name: Set up Node.js 22
152+
uses: actions/setup-node@v4
153+
with:
154+
node-version: '22'
155+
136156
- name: Install dependencies
137157
run: npm ci
138158

@@ -167,6 +187,11 @@ jobs:
167187
with:
168188
ref: "${{ github.event.pull_request.merge_commit_sha }}"
169189

190+
- name: Set up Node.js 22
191+
uses: actions/setup-node@v4
192+
with:
193+
node-version: '22'
194+
170195
- name: Install dependencies
171196
run: npm ci
172197

@@ -224,3 +249,102 @@ jobs:
224249
They will be retained for **up to 30 days**.
225250
`
226251
})
252+
253+
ui-pr-preview:
254+
needs: [ui-quality-checks, ui-precommit-checks, ui-unit-tests, ui-integration-tests]
255+
permissions:
256+
contents: write
257+
pull-requests: write
258+
issues: write
259+
runs-on: ubuntu-latest
260+
steps:
261+
- name: Check out code
262+
uses: actions/checkout@v3
263+
with:
264+
fetch-depth: 0
265+
266+
- name: Check if UI-related files changed
267+
id: check-changes
268+
run: |
269+
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
270+
CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
271+
SHOULD_BUILD=false
272+
273+
if echo "$CHANGED_FILES" | grep -q "^src/ui/"; then
274+
echo "UI source files changed"
275+
SHOULD_BUILD=true
276+
fi
277+
278+
echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
279+
echo "Should build: $SHOULD_BUILD"
280+
281+
- name: Install dependencies
282+
if: steps.check-changes.outputs.should_build == 'true'
283+
run: npm ci
284+
285+
- name: Build app to root
286+
if: steps.check-changes.outputs.should_build == 'true'
287+
id: build
288+
run: |
289+
# Export vars to ensure they are loaded before build
290+
export $(grep -v '^#' .env.development | xargs)
291+
292+
PR_NUMBER=${{ github.event.pull_request.number }}
293+
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
294+
295+
# Set asset prefix and base path with PR number
296+
ASSET_PREFIX=https://neuralmagic.github.io/guidellm/ui/pr/${PR_NUMBER}
297+
USE_MOCK_DATA=true
298+
BASE_PATH=/ui/pr/${PR_NUMBER}
299+
GIT_SHA=${{ github.sha }}
300+
export ASSET_PREFIX=${ASSET_PREFIX}
301+
export BASE_PATH=${BASE_PATH}
302+
export GIT_SHA=${GIT_SHA}
303+
export USE_MOCK_DATA=${USE_MOCK_DATA}
304+
npm run build
305+
306+
- name: Deploy to GitHub Pages
307+
if: steps.check-changes.outputs.should_build == 'true'
308+
uses: peaceiris/actions-gh-pages@v3
309+
with:
310+
github_token: ${{ secrets.GITHUB_TOKEN }}
311+
publish_dir: ./src/ui/out
312+
destination_dir: ui/pr/${{ steps.build.outputs.pr_number }}
313+
keep_files: false
314+
user_name: ${{ github.actor }}
315+
user_email: ${{ github.actor }}@users.noreply.github.com
316+
publish_branch: gh-pages
317+
commit_message: 'build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
318+
319+
- name: Set deployment url
320+
if: steps.check-changes.outputs.should_build == 'true'
321+
id: deploy
322+
run: |
323+
DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
324+
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
325+
326+
- name: Find PR comment
327+
if: steps.check-changes.outputs.should_build == 'true'
328+
uses: peter-evans/find-comment@v2
329+
id: find-comment
330+
with:
331+
token: ${{ secrets.GITHUB_TOKEN }}
332+
issue-number: ${{ github.event.pull_request.number }}
333+
body-includes: '<!-- pr-preview-comment -->'
334+
335+
- name: Post Deployment URL to PR
336+
if: steps.check-changes.outputs.should_build == 'true'
337+
uses: peter-evans/create-or-update-comment@v3
338+
with:
339+
token: ${{ secrets.GITHUB_TOKEN }}
340+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
341+
issue-number: ${{ github.event.pull_request.number }}
342+
edit-mode: replace
343+
body: |
344+
<!-- pr-preview-comment -->
345+
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
346+
*Last updated: ${{ github.sha }}*
347+
348+
- name: Skip build notification
349+
if: steps.check-changes.outputs.should_build == 'false'
350+
run: echo "Skipping UI preview build - no relevant files changed"

0 commit comments

Comments
 (0)