This commit is contained in:
hiyouga 2024-06-08 01:48:30 +08:00
parent 1c7f0ab519
commit aa2578bea0
2 changed files with 42 additions and 9 deletions

View File

@ -2,28 +2,58 @@ name: tests
on: on:
push: push:
branches: [ "main" ] branches:
- main
paths:
- "**.py"
- "requirements.txt"
- ".github/workflows/*.yml"
pull_request: pull_request:
branches: [ "main" ] branches:
- main
paths:
- "**.py"
- "requirements.txt"
- ".github/workflows/*.yml"
jobs: jobs:
check_code_quality: check_code_quality:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3.8" python-version: "3.8"
cache: "pip"
cache-dependency-path: "setup.py"
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install ruff python -m pip install .[torch,metrics,quality]
- name: Check quality - name: Check quality
run: | run: |
make style && make quality make style && make quality
pytest:
needs: check_code_quality
strategy:
matrix:
python-version: ["3.8", "3.9"]
os: ["ubuntu-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "setup.py"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[torch,metrics,quality]
- name: Test with pytest
run: |
make test

View File

@ -1,4 +1,4 @@
.PHONY: quality style .PHONY: quality style test
check_dirs := scripts src tests check_dirs := scripts src tests
@ -9,3 +9,6 @@ quality:
style: style:
ruff check $(check_dirs) --fix ruff check $(check_dirs) --fix
ruff format $(check_dirs) ruff format $(check_dirs)
test:
pytest tests/