mirror of https://github.com/langgenius/dify.git
118 lines
3.1 KiB
YAML
118 lines
3.1 KiB
YAML
name: Web Tests
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: web-tests-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
name: Web Tests (${{ matrix.shardIndex }}/${{ matrix.shardTotal }})
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
VITEST_COVERAGE_SCOPE: app-components
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shardIndex: [1, 2, 3, 4, 5, 6]
|
|
shardTotal: [6]
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: ./web
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup web environment
|
|
uses: ./.github/actions/setup-web
|
|
|
|
- name: Run tests
|
|
run: vp test run --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage
|
|
|
|
- name: Upload blob report
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
|
with:
|
|
name: blob-report-${{ matrix.shardIndex }}
|
|
path: web/.vitest-reports/*
|
|
include-hidden-files: true
|
|
retention-days: 1
|
|
|
|
merge-reports:
|
|
name: Merge Test Reports
|
|
if: ${{ !cancelled() }}
|
|
needs: [test]
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: ./web
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Setup web environment
|
|
uses: ./.github/actions/setup-web
|
|
|
|
- name: Download blob reports
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
path: web/.vitest-reports
|
|
pattern: blob-report-*
|
|
merge-multiple: true
|
|
|
|
- name: Merge reports
|
|
run: vp test --merge-reports --coverage --silent=passed-only
|
|
|
|
- name: Report coverage
|
|
uses: canyon-project/canyon-action@v1.0.24
|
|
with:
|
|
coverage-file: web/coverage/coverage-final.json
|
|
canyon-url: https://app.canyonjs.io
|
|
instrument-cwd: ${{ github.workspace }}
|
|
|
|
web-build:
|
|
name: Web Build
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./web
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Check changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
|
|
with:
|
|
files: |
|
|
web/**
|
|
.github/workflows/web-tests.yml
|
|
.github/actions/setup-web/**
|
|
|
|
- name: Setup web environment
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
uses: ./.github/actions/setup-web
|
|
|
|
- name: Web build check
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
working-directory: ./web
|
|
run: vp run build
|