Introduce some new pre-commit hooks
This commit is contained in:
parent
ce43152252
commit
bf26acb831
6 changed files with 77 additions and 41 deletions
|
@ -1,26 +1,53 @@
|
||||||
# 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/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.1.6
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
args: ["--fix"]
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v3.15.0
|
rev: v3.15.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: ['--keep-percent-format', '--py37-plus']
|
args: ["--keep-percent-format", "--py37-plus"]
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.11.0
|
rev: 23.11.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
args: ['--target-version', 'py37', '--line-length', '100']
|
args: ["--target-version", "py37", "--line-length", "100"]
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.12.0
|
rev: 5.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: ['--profile', 'black', '--line-length', '100']
|
args: ["--profile", "black", "--line-length", "100"]
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 6.1.0
|
rev: 6.1.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
args: ['--max-line-length=100']
|
args: ["--max-line-length=100"]
|
||||||
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
rev: v2.2.2
|
||||||
|
hooks:
|
||||||
|
- id: codespell
|
||||||
|
args:
|
||||||
|
- --ignore-words-list=exten
|
||||||
|
- --skip="./.*,*.csv,*.json,*.ini,*.subject,*.txt,*.html,*.log,*.conf"
|
||||||
|
- --quiet-level=2
|
||||||
|
- --ignore-regex=.*codespell-ignore$
|
||||||
|
# - --write-changes # Uncomment to write changes
|
||||||
|
exclude_types: [csv, json]
|
||||||
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
|
rev: v1.32.0
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
|
ignore: .github/
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
|
rev: v2.7.1
|
||||||
|
hooks:
|
||||||
|
- id: prettier
|
||||||
|
args: ["--print-width", "100"]
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: pylint
|
- id: pylint
|
||||||
|
@ -33,5 +60,5 @@ repos:
|
||||||
rev: 1.7.5
|
rev: 1.7.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: bandit
|
- id: bandit
|
||||||
args: [--skip, "B101", --recursive, "mylib"]
|
args: [--skip, "B101", --recursive]
|
||||||
minimum_pre_commit_version: 3.2.0
|
minimum_pre_commit_version: 3.2.0
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
clone:
|
clone:
|
||||||
git:
|
git:
|
||||||
image: woodpeckerci/plugin-git
|
image: woodpeckerci/plugin-git
|
||||||
|
|
7
.yamllint.yml
Normal file
7
.yamllint.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length:
|
||||||
|
max: 100
|
||||||
|
level: warning
|
|
@ -8,7 +8,8 @@ This Icinga/Nagios check plugin permit to check Syncthing status :
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
First, generate and retreive the REST API key from Syncthing web interface:
|
First, generate and retrieve the REST API key from Syncthing web interface:
|
||||||
|
|
||||||
- in Actions menu, click on Configuration
|
- in Actions menu, click on Configuration
|
||||||
- in General tab, under API key, click on Generate button and copy the key
|
- in General tab, under API key, click on Generate button and copy the key
|
||||||
|
|
||||||
|
|
2
build.sh
2
build.sh
|
@ -24,7 +24,7 @@ sed -i "s/^VERSION *=.*$/VERSION = '$VERSION'/" $BDIR/check_syncthing
|
||||||
|
|
||||||
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)"
|
||||||
|
|
|
@ -78,7 +78,7 @@ def call_api(uri, method=None, data=None, headers=None, what=None):
|
||||||
)
|
)
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except Exception: # pylint: disable=broad-exception-caught
|
except Exception: # pylint: disable=broad-exception-caught
|
||||||
print(f"UNKNOWN - Fail to retreive {what if what else 'data'} from Syncthing REST API")
|
print(f"UNKNOWN - Fail to retrieve {what if what else 'data'} from Syncthing REST API")
|
||||||
if data:
|
if data:
|
||||||
print(f"Request data: {json.dumps(data, indent=2)}")
|
print(f"Request data: {json.dumps(data, indent=2)}")
|
||||||
logging.exception("Error on requesting %s %s", method, uri)
|
logging.exception("Error on requesting %s %s", method, uri)
|
||||||
|
|
Loading…
Reference in a new issue