add ci github action #1
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: ci | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version-file: ".python-version" | |
- name: Install Poetry | |
uses: snok/install-poetry@v1.3.4 | |
with: | |
version: 1.6.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.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 library | |
run: poetry install --no-interaction | |
- name: Lint with ruff | |
run: poetry run ruff check src | |
- name: Check code security with bandit | |
run: poetry run bandit -r src | |
- name: Typing with mypy | |
run: poetry run mypy --check src | |
- name: Doc format with docformatter | |
run: poetry run docformatter --check --black -r src | |
- name: Sort import with isort | |
run: poetry run isort --check src tests | |
- name: Format with black | |
run: poetry run black --check src tests | |
- name: Test with pytest | |
run: poetry run pytest tests --cov=src |