feat(frontend): add skipped state to verify plugin UI (#244) #126
This file contains 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: Build and Publish | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
- unlabeled | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "The tag to build the image with. Format *.*.*((beta|rc)*)?" | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker-metadata: | |
name: Generate docker metadata | |
runs-on: ubuntu-latest | |
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'require-build')) || (github.event_name != 'pull_request' && !cancelled()) }} | |
outputs: | |
tags: ${{steps.meta.outputs.tags}} | |
labels: ${{steps.meta.outputs.labels}} | |
annotations: ${{steps.meta.outputs.annotations}} | |
platforms: | | |
linux/amd64 | |
${{(startsWith(github.ref, 'refs/tags/') && 'linux/arm64') || ''}} | |
permissions: | |
contents: read | |
steps: | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
github-token: ${{ github.token }} | |
images: "{0}/{1}" | |
tags: | | |
type=raw,value=branch-{{branch}},enable=${{ !startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/pull/') }} | |
type=sha,prefix=sha-,format=long,suffix=-dev,enable=${{ !startsWith(github.ref, 'refs/tags/') }} | |
type=sha,prefix=sha-,format=long,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
type=ref,event=pr | |
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{version}} | |
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}}.{{minor}} | |
type=pep440,value=${{inputs.tag || github.ref_name}},pattern={{major}} | |
build-backend: | |
name: Build and Push Backend Image | |
runs-on: ubuntu-latest | |
needs: docker-metadata | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }} | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Build and push backend | |
uses: docker/build-push-action@v6 | |
with: | |
context: backend | |
platforms: ${{needs.docker-metadata.outputs.platforms}} | |
push: true | |
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'backend')}} | |
labels: ${{needs.docker-metadata.outputs.labels}} | |
annotations: ${{needs.docker-metadata.outputs.annotations}} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-frontend: | |
name: Build and Push Frontend Image | |
runs-on: ubuntu-latest | |
needs: docker-metadata | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.RELEASE_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.RELEASE_DOCKERHUB_TOKEN }} | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Build and push frontend | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./frontend/Dockerfile | |
platforms: ${{needs.docker-metadata.outputs.platforms}} | |
push: true | |
tags: ${{format(needs.docker-metadata.outputs.tags, secrets.RELEASE_DOCKERHUB_USERNAME, 'frontend')}} | |
labels: ${{needs.docker-metadata.outputs.labels}} | |
annotations: ${{needs.docker-metadata.outputs.annotations}} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
e2e-test: | |
name: E2E Test | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
defaults: | |
run: | |
working-directory: e2e | |
needs: | |
- build-backend | |
- build-frontend | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: npm | |
cache-dependency-path: e2e/package-lock.json | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Run tests | |
run: ./start-test.sh | |
env: | |
E2E_DOCKER_TAG: sha-${{ github.sha }}-dev | |
E2E_LLM_PROVIDER: ${{vars.E2E_LLM_PROVIDER}} | |
E2E_LLM_MODEL: ${{vars.E2E_LLM_MODEL || ''}} | |
E2E_LLM_CREDENTIALS: ${{secrets.E2E_LLM_CREDENTIALS}} | |
E2E_EMBEDDING_PROVIDER: ${{vars.E2E_EMBEDDING_PROVIDER || 'openai'}} | |
E2E_EMBEDDING_MODEL: ${{vars.E2E_EMBEDDING_MODEL || ''}} | |
E2E_EMBEDDING_CREDENTIALS: ${{secrets.E2E_EMBEDDING_CREDENTIALS}} | |
E2E_RERANKER_PROVIDER: ${{vars.E2E_RERANKER_PROVIDER || 'jinaai'}} | |
E2E_RERANKER_MODEL: ${{vars.E2E_RERANKER_MODEL || ''}} | |
E2E_RERANKER_CREDENTIALS: ${{secrets.E2E_RERANKER_CREDENTIALS}} | |
- uses: actions/upload-artifact@v4 | |
if: "!cancelled()" | |
with: | |
name: e2e-report | |
path: e2e/playwright-report/ | |
retention-days: 30 | |
e2e-test-deploy: | |
name: "Deploy E2E Test Results" | |
runs-on: ubuntu-latest | |
needs: e2e-test | |
if: "!(contains(needs.*.result, 'skipped')) && !cancelled()" | |
defaults: | |
run: | |
working-directory: e2e | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: e2e-report | |
path: e2e/playwright-report/ | |
- name: Deploy Test Results to Vercel | |
id: deploy-test-result | |
run: | | |
deploy_message=$(./deploy-test-result.sh) | |
echo "deploy-message=${deploy_message}" >> $GITHUB_OUTPUT | |
if: "!cancelled()" | |
env: | |
VERCEL_TOKEN: ${{secrets.E2E_VERCEL_TOKEN}} | |
VERCEL_ORG_ID: ${{secrets.E2E_VERCEL_ORG_ID}} | |
VERCEL_PROJECT_ID: ${{secrets.E2E_VERCEL_PROJECT_ID}} | |
VERCEL_CLI_ARGS: ${{(github.ref == 'refs/heads/main' && '--prod') || ''}} | |
- name: Find PR Comment | |
uses: peter-evans/find-comment@v3 | |
if: github.event.pull_request.number | |
id: find-comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: E2E Result Deployment | |
- name: Upsert Comment on PR | |
uses: peter-evans/create-or-update-comment@v4 | |
if: github.event.pull_request.number | |
with: | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
### E2E Result Deployment | |
${{steps.deploy-test-result.outputs.deploy-message}} | |
edit-mode: replace |