Skip to content

Commit

Permalink
2023 Maintenance (#66)
Browse files Browse the repository at this point in the history
* Swap Flake8 for Ruff
* 79 char line length
* Full Python Testing Matrix
* Bandit
  • Loading branch information
jslay88 authored Apr 3, 2023
1 parent 597ef9a commit 940b980
Show file tree
Hide file tree
Showing 13 changed files with 557 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ trim_trailing_whitespace = true
# 4 space indentation
[*.py]
charset = utf-8
max_line_length = 120
max_line_length = 79
indent_style = space
indent_size = 4
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

79 changes: 67 additions & 12 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
name: Python Checks
name: Python QA Checks
# Python checks (usually tox matrix) to ensure code quality for PRs and merging
# Runs on pull requests

on: pull_request

jobs:
tox:
name: Tox Matrix
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dorny/[email protected]
id: filter
with:
filters: |
python:
- '**.py'
- 'tox.ini'
- name: Setup Python
uses: actions/[email protected]
if: steps.filter.outputs.python == 'true'
with:
python-version: "3.11"

- name: Install Dependencies
if: steps.filter.outputs.python == 'true'
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run Tox Linting
if: steps.filter.outputs.python == 'true'
run: tox
env:
TOXENV: lint

unittest:
name: Unit Tests
runs-on: ubuntu-latest

strategy:
matrix:
toxenv:
- lint
- unittest
- py38-unittest
- py39-unittest
- py310-unittest
- py311-unittest
include:
- toxenv: py38-unittest
python-version: "3.8"
- toxenv: py39-unittest
python-version: "3.9"
- toxenv: py310-unittest
python-version: "3.10"
- toxenv: py311-unittest
python-version: "3.11"

steps:
- uses: actions/checkout@v3
Expand All @@ -29,7 +72,7 @@ jobs:
uses: actions/[email protected]
if: steps.filter.outputs.python == 'true'
with:
python-version: "3.11"
python-version: "${{ matrix.python-version }}"

- name: Install Tox
if: steps.filter.outputs.python == 'true'
Expand All @@ -42,18 +85,26 @@ jobs:
run: |
tox -e ${{ matrix.toxenv }}
- name: Dump Test Coverage
if: steps.filter.outputs.python == 'true' && matrix.toxenv == 'py311-unittest'
run: |
pip install coverage
coverage xml
- name: Store Test Coverage
if: steps.filter.outputs.python == 'true' && matrix.toxenv == 'unittest'
uses: actions/upload-artifact@v2.2.4
if: steps.filter.outputs.python == 'true' && matrix.toxenv == 'py311-unittest'
uses: actions/upload-artifact@v3
with:
name: coverage
path: ./coverage.xml
path: |
./.coverage
./coverage.xml
coverage:
runs-on: ubuntu-latest
name: Coverage
needs:
- tox
- unittest

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -84,12 +135,16 @@ jobs:
uses: actions/[email protected]
with:
name: coverage
path: coverage

- name: Overall Coverage
if: steps.filter.outputs.python == 'true'
run: |
coverage report
- name: Check Coverage Diff
if: steps.filter.outputs.python == 'true'
run: |
diff-cover coverage/coverage.xml --compare-branch=origin/master --fail-under=100
diff-cover ./coverage.xml --compare-branch=origin/master --fail-under=100
build:
runs-on: ubuntu-latest
Expand Down
16 changes: 10 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.260
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==22.10.27]
- id: ruff
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: [ '-c', 'pyproject.toml' ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# qBt Migrate
![Python](https://github.com/jslay88/qbt_migrate/actions/workflows/python.yml/badge.svg)
![Python QA Checks](https://github.com/jslay88/qbt_migrate/actions/workflows/python.yml/badge.svg)

This tool changes the paths of existing torrents in qBittorrent in a bulk fashion.
It can also convert slashes when migrating between Windows and Linux/Mac.
Expand Down
28 changes: 24 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ dynamic = [

[project.optional-dependencies]
dev = [
"bandit",
"black",
"coverage",
"diff-cover",
"flake8",
"isort",
"pre-commit",
"pytest>=2.7.3",
"ruff",
]
test = [
"tox",
Expand All @@ -53,13 +54,32 @@ Source = "https://github.com/jslay88/qbt_migrate"
[project.scripts]
qbt_migrate = "qbt_migrate.cli:main"

[tool.bandit]
exclude_dirs = [
"tests",
]

[tool.black]
line-length = 120
target-version = ['py39']
line-length = 79
target-version = ['py311']
include = '\.pyi?$'

[tool.isort]
profile = "black"
line_length = 120
line_length = 79
lines_after_imports = 2
skip = [".tox", "venv"]

[tool.ruff]
exclude = [
"venv",
"__init__.py",
]
line-length = 79
select = [
"B",
"C",
"E",
"F",
"W",
]
Loading

0 comments on commit 940b980

Please sign in to comment.