test: move unit tests from robotoff to openfoodfacts-python (#309) #655
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python SDK quality checks and unit tests | |
on: | |
push: | |
paths: | |
- "openfoodfacts/**" | |
- "pyproject.toml" | |
- "poetry.lock" | |
- "tests/**" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1.3 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
run: poetry install --with=dev --all-extras | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
- name: Launch quality checks | |
run: | | |
poetry run flake8 . | |
poetry run black --check . | |
poetry run mypy . | |
poetry run isort --check . | |
- name: Test with pytest | |
run: | | |
poetry run pytest tests |