Skip to content

Commit

Permalink
ci: fix precommit config
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitpascal committed Oct 28, 2024
1 parent 6db4d4d commit fc5fd84
Showing 1 changed file with 4 additions and 57 deletions.
61 changes: 4 additions & 57 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
---
# .pre-commit-config.yaml
exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.(?!github/workflows)[^/]*/.*))$
repos:
# Several miscellaneous checks and fix (on yaml files, end of files fix)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# This hook tests the name of the branch and return an error if the name is
# 'develop' or an official version 'x.y'
# So you can't commit if your branch name is not a custom branch name.
# Using a custom branch name is good practice that makes it easier to manage PRs.
# You can skip this:
# - Permanently:
# export SKIP=no-commit-to-branch # In your .bashrc or session.
# - Only this for one commit:
# SKIP=no-commit-to-branch git commit -a -m "My message"
# - Skipping all checks for a commit:
# git commit -a -m "My message" --no-verify
# (Recommendation: run git commit -a .. once, then with `--no-verify`)
- id: no-commit-to-branch
args: [--branch, develop, --pattern, \d+.0]
# This checks that xml files are correct
- id: check-xml
exclude: |
(?x)^(htdocs/includes/.*)$
# This checks that yaml files are correct
- id: check-yaml
args: [--unsafe]
# This checks that json files are correct
- id: check-json
# Fixes Fix files that have DOS end of line endings
- id: mixed-line-ending
# alternative for dev/tools/fixdosfiles.sh
exclude: |
(?x)^(htdocs/includes/tecnickcom/tcpdf/fonts/.*
|.*/CRLF.*.php # Files in swiftmailer
)$
args: [--fix=lf]
# Remove trailing whitespace
- id: trailing-whitespace
exclude_types: [markdown]
# Fix the end of file
- id: end-of-file-fixer
# Check that there are no completely merged file conflicts
- id: check-merge-conflict
stages: [pre-commit, pre-rebase, pre-commit, pre-merge-commit]
# Check that files with shebangs have the executable bit set (in git)
stages: [commit, merge-commit]
- id: check-executables-have-shebangs
# Check that shell files are executables
- id: check-shebang-scripts-are-executable
exclude:
(?x)^( dev/tools/dolibarr-postgres2mysql.php |test/other/test_serialize.php
|test/phpunit/textutf8.txt |test/phpunit/textiso.txt |htdocs/includes/.*
|htdocs/modulebuilder/template/.* |build/debian/dolibarr.postrm |build/debian/dolibarr.postinst
|build/debian/dolibarr.config )$
# Fix the first UTF8 byte
- id: fix-byte-order-marker
# Check that there are no files that have are the same when uppercased (conflict on windows)
- id: check-case-conflict

# Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, api keys, and tokens in git repos
- repo: https://github.com/gitleaks/gitleaks.git
rev: v8.16.1
hooks:
- id: gitleaks

# Check github actions
- repo: https://github.com/rhysd/actionlint
rev: v1.7.3
hooks:
- id: actionlint

# Beautify shell scripts
- repo: https://github.com/lovesegfault/beautysh.git
rev: v6.2.1
hooks:
Expand All @@ -80,16 +52,6 @@ repos:
)$
args: [--tab]

# Run local script
#
# For example, to update the license in edited files, you could add to local.sh:
#
# ```shell
# #!/bin/bash
# MYDIR=$(dirname "$0")
# git diff HEAD --name-only | grep -v includes | \
# xargs "$MYDIR/dev/tools/updatelicense.php"
# ```
- repo: local
hooks:
- name: Find missing/unused/duplicate language keys
Expand Down Expand Up @@ -123,13 +85,11 @@ repos:
- id: fix-alt-languages
stages: [manual]
name: Fix alt languages
# Selection: see fixaltlanguages.sh script
files: (?x)^(htdocs/langs/(e[lnstu]|k[akmno]|s[lqrv]|b[nrs]|c[asy]|n[bel]|[ip]t|a[mr]|d[ae]|f[ar]|h[ei]|m[sy]|t[ag]|u[kr]|gl|ja|lo|ru|vi|zh)_[^/]*/.*\.lang)
language: script
entry: ./dev/tools/fixaltlanguages_pre-commit.sh
pass_filenames: true

# Check PHP syntax
- repo: https://github.com/mdeweerd/pre-commit-php
rev: v1.6.8
hooks:
Expand All @@ -147,7 +107,6 @@ repos:
]
- alias: php-cs-with-cache
id: php-cs
# Configuration for ci - run on all files with cache
stages: [manual]
args:
[
Expand All @@ -158,13 +117,12 @@ repos:
--cache=.cache/pre-commit/dolibarr-php-cs.cache,
.,
]
pass_filenames: false # Run on all files
pass_filenames: false
- id: php-lint
- id: php-stan
stages: [manual]
files: \.(php)$

# Prettier (format code, only for non common files)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
Expand All @@ -187,7 +145,6 @@ repos:
- css
- yaml

# Check format of yaml files
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
Expand All @@ -197,15 +154,10 @@ repos:
- -d
- "{extends: relaxed, rules: {line-length: {max: 120}}}"

# Execute codespell to fix typo errors (setup of codespell into dev/tools/codespell/)
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
# Due to a current limitation of configuration files,
# we can specify two dicts only on the CLI.
# You can update the contents of the exclude-file codespell-lines-ignore with the script
# dev/tools/codespell/addCodespellIgnores.sh
args:
- -D
- "-"
Expand All @@ -219,9 +171,6 @@ repos:
exclude: (?x)^(.phan/stubs/.*|phpstan\.neon.*)$
additional_dependencies: [tomli]
- alias: codespell-lang-en_US
# Only for translations with specialised exceptions
# -D contains predefined conversion dictionaries
# -L is to ignore some words
id: codespell
files: ^htdocs/langs/en_US/.*$
args:
Expand All @@ -240,19 +189,17 @@ repos:
- --uri-ignore-words-list
- ned

# Check some shell scripts
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: [-W, "100"]

# Check sql file syntax
- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.1.0
hooks:
- id: sqlfluff-lint
stages: [pre-commit, manual] # manual needed for ci
stages: [commit, manual]
exclude: (?x)^
(dev/initdemo/mysqldump_.*\.sql
|htdocs/core/menus/init_menu_auguria\.sql
Expand Down

0 comments on commit fc5fd84

Please sign in to comment.