Implement UI build pipeline #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: UI-Development | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
jobs: | |
quality-check: | |
permissions: | |
contents: "read" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ui | |
- name: Run quality and typing checks | |
run: make quality | |
working-directory: ui | |
precommit-check: | |
permissions: | |
contents: "read" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ui | |
- name: Run pre-commit checks | |
run: npx husky run pre-commit | |
working-directory: ui | |
unit-tests: | |
permissions: | |
contents: "read" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ui | |
- name: Run unit tests | |
run: make test-unit | |
working-directory: ui | |
integration-tests: | |
permissions: | |
contents: "read" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ui | |
- name: Run integration tests | |
run: make test-integration | |
working-directory: ui | |
publish-gh-pages: | |
needs: [quality-check, precommit-check, unit-tests, integration-tests] | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: npm ci | |
working-directory: ui | |
- name: Build app to root | |
id: build | |
run: | | |
# Export vars to ensure they are loaded before build | |
export $(grep -v '^#' .env.development | xargs) | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT | |
# Set asset prefix and base path with PR number | |
ASSET_PREFIX=https://neuralmagic.github.io/guidellm/ui/pr/${PR_NUMBER} | |
USE_MOCK_DATA=true | |
BASE_PATH=/ui/pr/${PR_NUMBER} | |
GIT_SHA=${{ github.sha }} | |
export ASSET_PREFIX=${ASSET_PREFIX} | |
export BASE_PATH=${BASE_PATH} | |
export GIT_SHA=${GIT_SHA} | |
export USE_MOCK_DATA=${USE_MOCK_DATA} | |
npm run build | |
working-directory: ui | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./out | |
destination_dir: ui/pr/${{ steps.build.outputs.pr_number }} | |
keep_files: false | |
user_name: ${{ github.actor }} | |
user_email: ${{ github.actor }}@users.noreply.github.com | |
publish_branch: gh-pages | |
- name: Set deployment url | |
id: deploy | |
run: | | |
DEPLOY_URL=https://neuralmagic.github.io/guidellm/pr/${{ steps.build.outputs.pr_number }} | |
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT | |
- name: Post Deployment URL to PR | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }}) |