xiaozhi-esp32-server/.github/workflows/unit_test.yml
2025-03-02 15:47:46 +09:00

75 lines
2 KiB
YAML

name: Run Tests
on:
pull_request:
branches:
- "*"
types:
- opened
- reopened
- synchronize
push:
branches:
- main
jobs:
test:
name: Run Pytest on Ubuntu and macOS
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu
python -m pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install ffmpeg and libopus
run: |
if [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
sudo apt-get update
sudo apt-get install -y --no-install-recommends libopus0 ffmpeg
fi
if [ ${{ matrix.os }} == 'macos-latest' ]; then
brew install ffmpeg opus
fi
# output the version of python and pip
- name: PyTest
run: |
python -m pytest test --junit-xml results/pytest.xml
continue-on-error: true
# Show the test results in the Actions tab
- name: Upload Unit Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: Unit Test Results (Python 3.7)
path: results/*.xml
- name: Download Artifacts
if: success() || failure()
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: artifacts/**/*.xml