11name : Development
22
33on :
4- pull_request_target :
4+ pull_request :
55 types : [opened, synchronize, reopened]
66
77jobs :
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
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
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