OpenManus/.github/workflows/unittest.yaml
2025-03-08 15:54:23 +08:00

48 lines
1.3 KiB
YAML

name: Unit Tests
on:
pull_request_target:
push:
branches:
- 'main'
- 'dev'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.12']
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Run tests with pytest
run: |
pytest app/ | tee unittest.txt
- name: Show failed tests and summary
run: |
grep -E "FAILED|ERROR|[0-9]+ passed," unittest.txt
failed_count=$(grep -E "FAILED|ERROR" unittest.txt | wc -l)
if [[ "$failed_count" -gt 0 ]]; then
echo "$failed_count failed tests found! Task failed."
exit 1
fi
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.python-version }}
path: ./unittest.txt
retention-days: 3
if: ${{ always() }}