diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index c4df6dbf6..51b644214 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -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() }} + \ No newline at end of file diff --git a/tests/scripts/run_install_deps.sh b/tests/scripts/run_install_deps.sh index 2758e24da..9e483ed1d 100644 --- a/tests/scripts/run_install_deps.sh +++ b/tests/scripts/run_install_deps.sh @@ -1,4 +1,4 @@ python -m pip install --upgrade pip pip install -e .[test] npm install -g @mermaid-js/mermaid-cli -playwright install --with-deps chromium \ No newline at end of file +playwright install --with-deps \ No newline at end of file