mirror of https://github.com/langgenius/dify.git
chore: add pytest XML and branch coverage reports (#33730)
Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
parent
ef9803f8b9
commit
7019395a28
|
|
@ -6,8 +6,8 @@ runs:
|
||||||
- name: Setup Vite+
|
- name: Setup Vite+
|
||||||
uses: voidzero-dev/setup-vp@4a524139920f87f9f7080d3b8545acac019e1852 # v1.0.0
|
uses: voidzero-dev/setup-vp@4a524139920f87f9f7080d3b8545acac019e1852 # v1.0.0
|
||||||
with:
|
with:
|
||||||
node-version-file: "./web/.nvmrc"
|
node-version-file: web/.nvmrc
|
||||||
cache: true
|
cache: true
|
||||||
|
cache-dependency-path: web/pnpm-lock.yaml
|
||||||
run-install: |
|
run-install: |
|
||||||
- cwd: ./web
|
cwd: ./web
|
||||||
args: ['--frozen-lockfile']
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,12 @@ name: Run Pytest
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
secrets:
|
||||||
|
CODECOV_TOKEN:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: api-tests-${{ github.head_ref || github.run_id }}
|
group: api-tests-${{ github.head_ref || github.run_id }}
|
||||||
|
|
@ -11,6 +17,8 @@ jobs:
|
||||||
test:
|
test:
|
||||||
name: API Tests
|
name: API Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -24,6 +32,7 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
with:
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup UV and Python
|
- name: Setup UV and Python
|
||||||
|
|
@ -79,21 +88,12 @@ jobs:
|
||||||
api/tests/test_containers_integration_tests \
|
api/tests/test_containers_integration_tests \
|
||||||
api/tests/unit_tests
|
api/tests/unit_tests
|
||||||
|
|
||||||
- name: Coverage Summary
|
- name: Report coverage
|
||||||
run: |
|
if: ${{ env.CODECOV_TOKEN != '' && matrix.python-version == '3.12' }}
|
||||||
set -x
|
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
|
||||||
# Extract coverage percentage and create a summary
|
with:
|
||||||
TOTAL_COVERAGE=$(python -c 'import json; print(json.load(open("coverage.json"))["totals"]["percent_covered_display"])')
|
files: ./coverage.xml
|
||||||
|
disable_search: true
|
||||||
# Create a detailed coverage summary
|
flags: api
|
||||||
echo "### Test Coverage Summary :test_tube:" >> $GITHUB_STEP_SUMMARY
|
env:
|
||||||
echo "Total Coverage: ${TOTAL_COVERAGE}%" >> $GITHUB_STEP_SUMMARY
|
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
|
||||||
{
|
|
||||||
echo ""
|
|
||||||
echo "<details><summary>File-level coverage (click to expand)</summary>"
|
|
||||||
echo ""
|
|
||||||
echo '```'
|
|
||||||
uv run --project api coverage report -m
|
|
||||||
echo '```'
|
|
||||||
echo "</details>"
|
|
||||||
} >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ jobs:
|
||||||
needs: check-changes
|
needs: check-changes
|
||||||
if: needs.check-changes.outputs.api-changed == 'true'
|
if: needs.check-changes.outputs.api-changed == 'true'
|
||||||
uses: ./.github/workflows/api-tests.yml
|
uses: ./.github/workflows/api-tests.yml
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
web-tests:
|
web-tests:
|
||||||
name: Web Tests
|
name: Web Tests
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[pytest]
|
[pytest]
|
||||||
pythonpath = .
|
pythonpath = .
|
||||||
addopts = --cov=./api --cov-report=json --import-mode=importlib
|
addopts = --cov=./api --cov-report=json --import-mode=importlib --cov-branch --cov-report=xml
|
||||||
env =
|
env =
|
||||||
ANTHROPIC_API_KEY = sk-ant-api11-IamNotARealKeyJustForMockTestKawaiiiiiiiiii-NotBaka-ASkksz
|
ANTHROPIC_API_KEY = sk-ant-api11-IamNotARealKeyJustForMockTestKawaiiiiiiiiii-NotBaka-ASkksz
|
||||||
AZURE_OPENAI_API_BASE = https://difyai-openai.openai.azure.com
|
AZURE_OPENAI_API_BASE = https://difyai-openai.openai.azure.com
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
coverage:
|
||||||
|
status:
|
||||||
|
project:
|
||||||
|
default:
|
||||||
|
target: auto
|
||||||
|
|
||||||
|
flags:
|
||||||
|
web:
|
||||||
|
paths:
|
||||||
|
- "web/"
|
||||||
|
carryforward: true
|
||||||
|
|
||||||
|
api:
|
||||||
|
paths:
|
||||||
|
- "api/"
|
||||||
|
carryforward: true
|
||||||
Loading…
Reference in New Issue