pre-commit: introduce make lint

Also make the linters part of the github actions.
This commit is contained in:
Florian Schüller 2024-12-20 18:36:31 +01:00 committed by Florian Schüller
parent 734c132500
commit c408577b2d
11 changed files with 157 additions and 0 deletions

View file

@ -9,6 +9,18 @@ on: # yamllint disable-line rule:truthy
types: ["checks_requested"] types: ["checks_requested"]
jobs: jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install yamllint
run: sudo apt-get install -y yamllint aspell
- name: "Clone Repository"
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Run linters
run: make lint
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
uses: ./.github/workflows/testdeps.yaml uses: ./.github/workflows/testdeps.yaml

32
.golangci.yml Normal file
View file

@ -0,0 +1,32 @@
---
exclude-dirs:
- vendor
linters-settings:
govet:
disable:
- shadow # default value recommended by golangci
- composites
gosec:
excludes:
- G101
linters:
enable:
- gosec
run:
build-tags:
- integration
timeout: 5m
issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default
# is 3.
max-same-issues: 0
exclude-rules:
- path: ^(pkg|internal)/.*_test\.go$
linters: ["gosec"]

45
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,45 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: [--strict]
- repo: https://github.com/schuellerf/pre-commit-pyspelling
rev: 0.1.0
hooks:
- id: pyspelling
args: ["--config", ".spellcheck.yml"]
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
hooks:
- id: golangci-lint
- repo: https://github.com/hhatto/autopep8
rev: v2.3.0
hooks:
- id: autopep8
- repo: https://github.com/pycqa/pylint
rev: v3.2.6
hooks:
- id: pylint
additional_dependencies: ["PyYAML", "types-PyYAML", "pytest"]
files: ^(?!test/|tools/)
- id: pylint
name: pylint test/ directory
additional_dependencies: ["PyYAML", "types-PyYAML", "pytest"]
args: ["--rcfile=test/.pylintrc"]
files: ^test/
- id: pylint
name: pylint tools/ directory
additional_dependencies: ["PyYAML", "types-PyYAML", "pytest"]
args: ["--rcfile=tools/.pylintrc"]
files: ^tools/

2
.pylintrc Normal file
View file

@ -0,0 +1,2 @@
[FORMAT]
max-line-length=120

14
.spellcheck-en-custom.txt Normal file
View file

@ -0,0 +1,14 @@
backend
bootc
bootmode
buildable
Changelog
cli
distro
github
globbing
https
json
osbuild
qcow
UEFI

28
.spellcheck.yml Normal file
View file

@ -0,0 +1,28 @@
# SPDX-License-Identifier: Apache-2.0
matrix:
- name: markdown
aspell:
lang: en
d: en_US
camel-case: true
mode: markdown
sources:
- "**/*.md|!venv/**|!vendor/**"
dictionary:
wordlists:
- .spellcheck-en-custom.txt
pipeline:
- pyspelling.filters.context:
context_visible_first: true
escapes: '\\[\\`~]'
delimiters:
# Ignore multiline content between fences (fences can have 3 or more back ticks)
# ```language
# content
# ```
- open: '^(?P<open> *`{3,}).*$'
close: '^(?P=open)$'
# Ignore text between inline back ticks
- open: '(?P<open>`+)'
close: '(?P=open)'

10
.yamllint Normal file
View file

@ -0,0 +1,10 @@
---
extends: default
rules:
document-start: disable
line-length: disable
ignore:
- test/data/error/09-duplicated-key.yaml
- test/data/error/10-duplicated-key-no-otk.yaml

View file

@ -85,6 +85,7 @@ help:
@echo " srpm: Build the source RPM" @echo " srpm: Build the source RPM"
@echo " scratch: Quick scratch build of RPM" @echo " scratch: Quick scratch build of RPM"
@echo " clean: Remove all built binaries" @echo " clean: Remove all built binaries"
@echo " lint: Run all known linters"
$(BUILDDIR)/: $(BUILDDIR)/:
mkdir -p "$@" mkdir -p "$@"
@ -186,3 +187,5 @@ release_artifacts: $(RPM_TARBALL_VERSIONED)
# Print the artifact path for Packit # Print the artifact path for Packit
echo "release_artifacts/$(shell basename $<)" echo "release_artifacts/$(shell basename $<)"
lint:
pre-commit run --all

2
setup.cfg Normal file
View file

@ -0,0 +1,2 @@
[pep8]
max-line-length = 120

5
test/.pylintrc Normal file
View file

@ -0,0 +1,5 @@
[MESSAGES CONTROL]
disable=
missing-module-docstring,
missing-function-docstring,
fixme

4
tools/.pylintrc Normal file
View file

@ -0,0 +1,4 @@
[MESSAGES CONTROL]
disable=
missing-module-docstring,
missing-function-docstring