.github/workflows/build.yaml
name: Run tests
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# os: [ubuntu-latest, macos-latest]
python-version: ["3.8", "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: Cache venv
id: cached-pip-wheels
uses: actions/cache@v3
with:
path: ~/.venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
python -m pip install --upgrade poetry
python -m poetry config virtualenvs.in-project "true"
python -m poetry install --no-interaction
- name: Run pytest and coverage
run: python -m poetry run coverage run --source=secsgem -m pytest
- name: Publish coverage to codeclimate
uses: paambaati/codeclimate-action@v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_REPORTER_ID }}
with:
coverageCommand: python -m poetry run coverage xml
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && github.ref == 'refs/heads/main'
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Cache venv
id: cached-pip-wheels
uses: actions/cache@v3
with:
path: ~/.venv
key: venv-ubuntu-latest-3.11-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
python -m pip install --upgrade poetry
python -m poetry config virtualenvs.in-project "true"
python -m poetry install --no-interaction
- name: Run linters
run: |
python -m poetry run pylint --recursive=y .
python -m poetry run ruff .
python -m poetry run mypy .
release:
needs: [test, lint]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.16
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"