Skip to content

Commit

Permalink
Merge pull request #2 from bandophahita/update_package_installer
Browse files Browse the repository at this point in the history
update package to use pyproject.toml
  • Loading branch information
bandophahita authored Sep 10, 2023
2 parents da2c679 + 3708d1d commit 02fadd1
Show file tree
Hide file tree
Showing 14 changed files with 1,787 additions and 28 deletions.
31 changes: 31 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[flake8]
exclude =
.github,
.pytest_cache,
.venv,
venv,
dockerfiles,
docs,
.coverage,
.coveragerc,
.env,
.env.example,
.flake8,
.gitignore,
alembic.ini,
bandit.yaml,
Makefile,
mkdocks.yml,
mypy.ini,
poetry.lock,
pyproject.toml,
pytest.ini,
README.md,
.idea,

max-line-length = 88
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,

per-file-ignores = conf.py:E501
45 changes: 45 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lint

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]

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
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e .[dev-all]
- name: Lint with black
run: |
black --check --diff screenpy_pyotp
- name: Lint with isort
run: |
isort --check-only --diff screenpy_pyotp
- name: Lint with flake8
run: |
flake8 --exit-zero screenpy_pyotp
- name: Lint with mypy
run: |
mypy screenpy_pyotp
- name: Lint with pylint
run: |
pylint screenpy_pyotp
39 changes: 39 additions & 0 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Poetry

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
run-tests:
name: Python ${{ matrix.python-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]
poetry-version: ["1.3.2"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Check toml structure
run: poetry check

- name: Check lock file
run: poetry lock --check
33 changes: 33 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# adapted from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# with changes from https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/

name: Publish to PyPI

on: push

jobs:
build-and-pypi-publish:
name: Build and upload release to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Poetry
run: >-
python -m
pip install
poetry
--user
- name: Build ScreenPy PyOTP
run: >-
python -m
poetry
build
- name: Publish distribution to PyPI # only on new tag push
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
run-tests:
name: Python ${{ matrix.python-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 9
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest]

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 dev dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
6 changes: 6 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[settings]
line_length = 88
multi_line_output = 3
include_trailing_comma = True
use_parentheses = True
src_paths = screenpy_pyotp,tests
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ files: 'screenpy_pyotp/.*'
fail_fast: false
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/timothycrosley/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
language_version: python3.11
Expand All @@ -17,7 +17,7 @@ repos:
- id: flake8
language_version: python3.11
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.3.0
hooks:
- id: mypy
language_version: python3.11
Expand All @@ -26,6 +26,6 @@ repos:
hooks:
- id: pylint
name: pylint
entry: pylint --max-line-length=88 --disable=bad-continuation --disable=no-self-use --disable=too-few-public-methods --disable=invalid-name --disable=wrong-import-order --disable=import-error --disable=super-init-not-called --disable=duplicate-code --disable=logging-format-interpolation --disable=logging-fstring-interpolation
entry: pylint
language: system
types: [python]
15 changes: 15 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[MASTER]
ignore-paths=^.*/tests/.*$
disable=
arguments-renamed,
duplicate-code,
import-error,
invalid-name,
logging-format-interpolation,
logging-fstring-interpolation,
no-member,
super-init-not-called,
too-few-public-methods,
unused-argument,
useless-super-delegation,
wrong-import-order,
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# shortcuts to help manage flipping between branches with different dependencies
sync:
poetry install --extras dev_all --sync

update_lock_only:
poetry update --lock

update: update_lock_only
poetry install --extras dev_all

check:
poetry check

requirements:
poetry export --without-hashes --with dev -f requirements.txt > requirements.txt

.PHONY: sync update_lock_only update check requirements
11 changes: 11 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
[mypy]
show_error_codes = True
exclude = (?x)(
setup\.py
; | tests/
| docs/
)

[mypy-screenpy_pyotp.*]
disallow_untyped_defs = True

[mypy-tests.*]
ignore_missing_imports = True
Loading

0 comments on commit 02fadd1

Please sign in to comment.