From 9a4229339b486c97b0c25e41211ea2152d9c414a Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 6 Jan 2024 11:39:45 -0600 Subject: [PATCH] Add pre-commit support to CI This will help to make sure that style things that are enforced by pre-commit are set appropriately. --- .gitlab-ci.yml | 9 +++++++++ .pre-commit-config.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f06d9c..bb7392b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,8 @@ image: fedora:rawhide variables: + PRECOMMIT: pre-commit + git DEPENDENCIES: gcc gcovr gtk-doc @@ -25,6 +27,13 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'push' +pre_commit: + before_script: + - dnf update -y + - if [ -x /bin/dnf ]; then dnf install -y $PRECOMMIT; else dnf5 install -y $PRECOMMIT; fi + script: + - pre-commit run --all-files + build_stable: before_script: - dnf update -y diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4aec8ba --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +default_stages: [commit] +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: no-commit-to-branch + args: [--branch, main] + - id: check-added-large-files + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: forbid-new-submodules + - id: check-yaml + - id: check-json + - id: pretty-format-json + args: ['--no-sort-keys'] + - id: check-symlinks + - id: check-xml + - id: end-of-file-fixer + types_or: [c, shell, python] + - id: trailing-whitespace + types_or: [c, shell, python, xml] + - id: check-docstring-first + - id: check-merge-conflict + - id: mixed-line-ending + args: [--fix=lf] +- repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + args: ['--write-changes'] +# disabled until amdgpu panel power action is merged +#- repo: https://github.com/ambv/black +# rev: 23.12.0 +# hooks: +# - id: black +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.38.0 + hooks: + - id: markdownlint + args: ['--fix']