From e4c257e376ea3efe5622774850eda3d02899da9d Mon Sep 17 00:00:00 2001 From: resulyurttakalan Date: Thu, 11 Aug 2022 00:54:13 +0300 Subject: [PATCH] - add pre-commit hooks - add flake8 configs - add workflow --- .github/workflows/tests.yaml | 28 ++++++++++++++++++++++++++++ .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ requirements-dev.txt | 3 +++ setup.cfg | 6 +++++- setup.py | 1 + 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 requirements-dev.txt diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..c17d6dd --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,28 @@ +name: Python package + +on: [ push, pull_request ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.7", "3.8", "3.9", "3.10" ] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + - name: Run pre commit hooks + run: | + pre-commit run --all-files --show-diff-on-failure + - name: Test with pytest + run: | + pytest tests diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..eafbbe9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +# To install the git pre-commit hook run: +# pre-commit install +# To update the pre-commit hooks run: +# pre-commit install-hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: '.*\.pth$' + - id: debug-statements + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + - repo: https://github.com/asottile/pyupgrade + rev: v2.32.1 + hooks: + - id: pyupgrade + args: [ --py36-plus ] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..ba479d9 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +flake8 +pytest +pre-commit diff --git a/setup.cfg b/setup.cfg index 74109a6..14d8ec2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,4 +8,8 @@ norecursedirs = dist [bdist_wheel] -universal = 1 \ No newline at end of file +universal = 1 + +[flake8] +exclude = + tests/conftest.py diff --git a/setup.py b/setup.py index 8172a93..340ffd5 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os + from setuptools import setup