Improve pre-commit hooks & code cleaning
This commit is contained in:
parent
742e00f24d
commit
1c12d4fce5
5 changed files with 72 additions and 42 deletions
|
@ -1,36 +1,67 @@
|
||||||
# Pre-commit hooks to run tests and ensure code is cleaned.
|
# Pre-commit hooks to run tests and ensure code is cleaned.
|
||||||
# See https://pre-commit.com for more information
|
# See https://pre-commit.com for more information
|
||||||
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v3.15.0
|
rev: v0.1.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: ruff
|
||||||
args: ['--keep-percent-format', '--py37-plus']
|
args:
|
||||||
- repo: https://github.com/psf/black
|
- --fix
|
||||||
rev: 23.11.0
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
hooks:
|
rev: v3.3.1
|
||||||
- id: black
|
hooks:
|
||||||
args: ['--target-version', 'py37', '--line-length', '100']
|
- id: pyupgrade
|
||||||
- repo: https://github.com/PyCQA/isort
|
args: ["--keep-percent-format", "--py37-plus"]
|
||||||
rev: 5.12.0
|
- repo: https://github.com/psf/black
|
||||||
hooks:
|
rev: 22.12.0
|
||||||
- id: isort
|
hooks:
|
||||||
args: ['--profile', 'black', '--line-length', '100']
|
- id: black
|
||||||
- repo: https://github.com/PyCQA/flake8
|
args: ["--target-version", "py37", "--line-length", "100"]
|
||||||
rev: 6.1.0
|
- repo: https://github.com/PyCQA/isort
|
||||||
hooks:
|
rev: 5.11.5
|
||||||
- id: flake8
|
hooks:
|
||||||
args: ['--max-line-length=100']
|
- id: isort
|
||||||
- repo: local
|
args: ["--profile", "black", "--line-length", "100"]
|
||||||
hooks:
|
- repo: https://github.com/PyCQA/flake8
|
||||||
- id: pylint
|
rev: 6.0.0
|
||||||
name: pylint
|
hooks:
|
||||||
entry: pylint
|
- id: flake8
|
||||||
language: system
|
args: ["--max-line-length=100"]
|
||||||
types: [python]
|
- repo: https://github.com/codespell-project/codespell
|
||||||
require_serial: true
|
rev: v2.2.2
|
||||||
- repo: https://github.com/PyCQA/bandit
|
hooks:
|
||||||
rev: 1.7.5
|
- id: codespell
|
||||||
hooks:
|
args:
|
||||||
- id: bandit
|
- --ignore-words-list=fro,hass
|
||||||
args: [--skip, "B101", --recursive, "mylib"]
|
- --skip="./.*,*.csv,*.json,*.ambr"
|
||||||
|
- --quiet-level=2
|
||||||
|
exclude_types: [csv, json]
|
||||||
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
|
rev: v1.32.0
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
args: ["-d {extends: relaxed, rules: {line-length: disable}}", "-s"]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
|
rev: v2.7.1
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: pylint
|
||||||
|
name: pylint
|
||||||
|
entry: pylint
|
||||||
|
language: system
|
||||||
|
types: [python]
|
||||||
|
require_serial: true
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
|
||||||
|
rev: v1.0.5
|
||||||
|
hooks:
|
||||||
|
- id: python-bandit-vulnerability-check
|
||||||
|
name: bandit
|
||||||
|
args: [--skip, "B101", --recursive, mylib]
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
stages: [manual]
|
||||||
|
|
|
@ -18,7 +18,7 @@ pipeline:
|
||||||
commands:
|
commands:
|
||||||
- echo "$GPG_KEY"|base64 -d|gpg --import
|
- echo "$GPG_KEY"|base64 -d|gpg --import
|
||||||
- ./build.sh --quiet
|
- ./build.sh --quiet
|
||||||
secrets: [ maintainer_name, maintainer_email, gpg_key, debian_codename ]
|
secrets: [maintainer_name, maintainer_email, gpg_key, debian_codename]
|
||||||
|
|
||||||
publish-dryrun:
|
publish-dryrun:
|
||||||
group: publish
|
group: publish
|
||||||
|
|
|
@ -37,7 +37,6 @@ Copyright (c) 2023 Benjamin Renard <brenard@zionetrix.net>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -24,7 +24,7 @@ sed -i "s/^VERSION *=.*$/VERSION = '$VERSION'/" $BDIR/check_forgejo_upgrade
|
||||||
|
|
||||||
if [ -z "$DEBIAN_CODENAME" ]
|
if [ -z "$DEBIAN_CODENAME" ]
|
||||||
then
|
then
|
||||||
echo "Retreive debian codename using lsb_release..."
|
echo "Retrieve debian codename using lsb_release..."
|
||||||
DEBIAN_CODENAME=$( lsb_release -c -s )
|
DEBIAN_CODENAME=$( lsb_release -c -s )
|
||||||
else
|
else
|
||||||
echo "Use debian codename from environment ($DEBIAN_CODENAME)"
|
echo "Use debian codename from environment ($DEBIAN_CODENAME)"
|
||||||
|
|
|
@ -55,7 +55,7 @@ logging.basicConfig(level=logging.DEBUG if options.debug else logging.WARNING)
|
||||||
CURRENT = None
|
CURRENT = None
|
||||||
|
|
||||||
cmd = [options.path, "--version"]
|
cmd = [options.path, "--version"]
|
||||||
logging.debug("Command use to retreive current version of Forgejo: %s", " ".join(cmd))
|
logging.debug("Command use to retrieve current version of Forgejo: %s", " ".join(cmd))
|
||||||
OUTPUT = None
|
OUTPUT = None
|
||||||
EXCEPTION = None
|
EXCEPTION = None
|
||||||
try:
|
try:
|
||||||
|
@ -69,7 +69,7 @@ except Exception as err: # pylint: disable=broad-except
|
||||||
logging.debug("Current version: %s", CURRENT)
|
logging.debug("Current version: %s", CURRENT)
|
||||||
|
|
||||||
if not CURRENT:
|
if not CURRENT:
|
||||||
print("UNKNOWN - Fail to retreive current Forgejo")
|
print("UNKNOWN - Fail to retrieve current Forgejo")
|
||||||
print(f'Command: {" ".join(cmd)}')
|
print(f'Command: {" ".join(cmd)}')
|
||||||
print("Output:")
|
print("Output:")
|
||||||
print(OUTPUT if OUTPUT else "")
|
print(OUTPUT if OUTPUT else "")
|
||||||
|
@ -85,7 +85,7 @@ LATEST_INT = None
|
||||||
try:
|
try:
|
||||||
logging.debug("Get releases RSS feed from %s...", options.url)
|
logging.debug("Get releases RSS feed from %s...", options.url)
|
||||||
r = requests.get(options.url, timeout=options.timeout)
|
r = requests.get(options.url, timeout=options.timeout)
|
||||||
logging.debug("Data retreive:\n%s", r.text)
|
logging.debug("Data retrieve:\n%s", r.text)
|
||||||
data = xmltodict.parse(r.text)
|
data = xmltodict.parse(r.text)
|
||||||
versions = {}
|
versions = {}
|
||||||
for item in data["rss"]["channel"]["item"]:
|
for item in data["rss"]["channel"]["item"]:
|
||||||
|
@ -111,7 +111,7 @@ except Exception: # pylint: disable=broad-except # nosec
|
||||||
logging.debug("Latest version: %s", LATEST)
|
logging.debug("Latest version: %s", LATEST)
|
||||||
|
|
||||||
if not LATEST:
|
if not LATEST:
|
||||||
print("UNKNOWN - Fail to retreive latest Forgejo release from the project RSS feed")
|
print("UNKNOWN - Fail to retrieve latest Forgejo release from the project RSS feed")
|
||||||
print(f"Current version: {CURRENT}")
|
print(f"Current version: {CURRENT}")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue