pr trigger unittest, maintainer approve the unittest

This commit is contained in:
voidking 2024-01-05 17:39:13 +08:00
parent 230192f5e0
commit f7d04d7f81
2 changed files with 19 additions and 2 deletions

View file

@ -1,11 +1,21 @@
name: Python application test
on:
workflow_dispatch:
pull_request:
branches:
- 'main'
- 'dev'
- '*-release'
push:
branches:
- 'main'
- 'dev'
- '*-release'
jobs:
build:
runs-on: ubuntu-latest
environment: unittest
strategy:
matrix:
# python-version: ['3.9', '3.10', '3.11']
@ -23,6 +33,7 @@ jobs:
- name: Test with pytest
run: |
echo "${{ secrets.METAGPT_KEY_YAML }}" | base64 -d > config/key.yaml
mkdir -p ~/.metagpt/ && echo "${{ secrets.METAGPT_KEY_YAML }}" | base64 -d > ~/.metagpt/key.yaml
pytest tests/ --doctest-modules --cov=./metagpt/ --cov-report=xml:cov.xml --cov-report=html:htmlcov --durations=20 | tee unittest.txt
- name: Show coverage report
run: |
@ -30,6 +41,11 @@ jobs:
- name: Show failed tests and overall summary
run: |
grep -E "FAILED tests|[0-9]+ passed," unittest.txt
failed_count=$(grep "FAILED" unittest.txt | wc -l)
if [[ "$failed_count" -gt 0 ]]; then
echo "$failed_count failed lines found! Task failed."
exit 1
fi
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
@ -40,4 +56,5 @@ jobs:
./tests/data/rsp_cache_new.json
retention-days: 3
if: ${{ always() }}