Feature/GitHub actions ci #3
This file contains hidden or 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: CI Python 3.9+ | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Verify Python version | |
| run: | | |
| python --version | |
| python -c "import sys; assert sys.version_info >= (3, 9), f'Python 3.9+ required, got {sys.version}'" | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| version: latest | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| - name: Load cached venv | |
| id: cached-poetry-dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: .venv | |
| key: venv-v3-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install dependencies | |
| if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
| run: poetry install --no-interaction --no-root | |
| - name: Install project | |
| run: poetry install --no-interaction --with dev | |
| - name: Run tests with unittest | |
| run: | | |
| export PYTHONPATH="${PYTHONPATH}:$(pwd)/src" | |
| python -m unittest discover tests/ -v | |
| - name: Run tests with pytest (if available) | |
| run: | | |
| pip install pytest | |
| export PYTHONPATH="${PYTHONPATH}:$(pwd)/src" | |
| pytest tests/ -v | |
| continue-on-error: true | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| version: latest | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| - name: Install dependencies | |
| run: poetry install --no-interaction --with dev | |
| - name: Run flake8 | |
| run: poetry run flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
| - name: Run black format | |
| run: poetry run black src/ tests/ | |
| - name: Run isort format | |
| run: poetry run isort src/ tests/ | |
| - name: Run mypy | |
| run: poetry run mypy src/ --ignore-missing-imports | |
| continue-on-error: true |