From 16d663d371335ebe2aa6160c074b29faa646604a Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Fri, 1 Aug 2025 01:21:42 +0200 Subject: [PATCH] forgejo/workflows: add pre-commit based linting --- .forgejo/pre-commit/config.yaml | 23 +++++ .forgejo/pre-commit/ignored-words.txt | 118 ++++++++++++++++++++++++++ .forgejo/workflows/lint.yml | 26 ++++++ 3 files changed, 167 insertions(+) create mode 100644 .forgejo/pre-commit/config.yaml create mode 100644 .forgejo/pre-commit/ignored-words.txt create mode 100644 .forgejo/workflows/lint.yml diff --git a/.forgejo/pre-commit/config.yaml b/.forgejo/pre-commit/config.yaml new file mode 100644 index 0000000000..965ae92caa --- /dev/null +++ b/.forgejo/pre-commit/config.yaml @@ -0,0 +1,23 @@ +exclude: ^tests/ref/ + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-illegal-windows-names + - id: check-shebang-scripts-are-executable + - id: check-yaml + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: trailing-whitespace +- repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + args: + - --ignore-words=.forgejo/pre-commit/ignored-words.txt + - --ignore-multiline-regex=codespell:off.*?(codespell:on|\Z) + exclude: ^tools/(patcheck|clean-diff)$ diff --git a/.forgejo/pre-commit/ignored-words.txt b/.forgejo/pre-commit/ignored-words.txt new file mode 100644 index 0000000000..52ba0d9e56 --- /dev/null +++ b/.forgejo/pre-commit/ignored-words.txt @@ -0,0 +1,118 @@ +abl +acount +ACN +addin +alis +alls +als +ALOG +ALS +anull +ANC +ans +ANS +basf +bloc +brane +BREIF +bu +BU +bufer +caf +CAF +clen +clens +Collet +compre +dum +endin +erro +fiel +FIEL +fils +filp +filterd +FILTERD +fle +fo +FPR +fro +Hald +ine +inh +inouts +indx +inout +inport +ist +laf +LAF +lastr +LinS +mapp +mis +mot +nd +nIn +offsetp +orderd +ot +outout +padd +paeth +PAETH +parm +PARM +parms +pEvents +PixelX +Psot +quater +readd +reencode +Reencode +recuse +redY +remaind +renderD +rin +SAV +SEH +ser +SER +setts +shft +siz +SIZ +skipd +sme +som +sover +STAP +startd +statics +struc +suble +te +TE +tha +tne +tolen +tpye +tre +truns +trun +TRUN +Tung +tE +TYE +ue +ues +UES +vai +vas +vor +vie +VILL +wel +wih diff --git a/.forgejo/workflows/lint.yml b/.forgejo/workflows/lint.yml new file mode 100644 index 0000000000..42e925ad8b --- /dev/null +++ b/.forgejo/workflows/lint.yml @@ -0,0 +1,26 @@ +on: + push: + branches: + - master + pull_request: + +jobs: + lint: + runs-on: utilities + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install pre-commit CI + id: install + run: | + python3 -m venv ~/pre-commit + ~/pre-commit/bin/pip install --upgrade pip setuptools + ~/pre-commit/bin/pip install pre-commit + echo "envhash=$({ python3 --version && cat .forgejo/pre-commit/config.yaml; } | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT + - name: Cache + uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ steps.install.outputs.envhash }} + - name: Run pre-commit CI + run: ~/pre-commit/bin/pre-commit run -c .forgejo/pre-commit/config.yaml --show-diff-on-failure --color=always --all-files