aboutsummaryrefslogtreecommitdiff
path: root/.pre-commit-config.yaml
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2023-07-01 22:55:42 +0100
committerGunes Bayir <gunes.bayir@arm.com>2023-08-08 14:23:35 +0000
commit66b4a6a8ca1ee55e5b7f05bae2543cf99fe22d6d (patch)
treea11e009e6fc742df0fd4551fd7c545325210a07d /.pre-commit-config.yaml
parentf77b969d3375f412ff236586d2b6eb2297c6b96d (diff)
downloadComputeLibrary-66b4a6a8ca1ee55e5b7f05bae2543cf99fe22d6d.tar.gz
Setup pre-commit and include code formatting scripts
This patch - includes our code formatting scripts used in our precommit pipeline - sets up pre-commit framework to help contributors validate their patches This has several benefits: - our repository becomes more inclusive to external contributions - we can use several hooks available online efficiently, w/o implementing our own - it speeds up our development flow and, it is completely optional. The pre-commit configuration includes running the following: - our code formatting scripts - CMake and Bazel build file generation scripts - hooks that check trailing whitespace, end of files, committed large files etc. The number of checks can easily be extended using pre-commit framework. Change-Id: I06bf1259715579d321f89820726a8301504c36d9 Signed-off-by: Gunes Bayir <gunes.bayir@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10064 Reviewed-by: Jakub Sujak <jakub.sujak@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to '.pre-commit-config.yaml')
-rw-r--r--.pre-commit-config.yaml70
1 files changed, 32 insertions, 38 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index baf458264a..c003d1cc94 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,53 +1,47 @@
fail_fast: false
-files: ^python/
+exclude: ^(data|include)/.*
+exclude: |
+ (?x)^(
+ data/.*|
+ include/.*|
+ src/CMakeLists.txt|
+ src/Bazel.build|
+ Android.bp
+ )$
+
repos:
+ - repo: local
+ hooks:
+ - id: format-code
+ name: ACL Format Code Script
+ stages: [commit]
+ language: python
+ entry: python ./scripts/format_code.py --files=git-diff
+ pass_filenames: false
+ additional_dependencies: ['psutil==5.8.0', 'Jinja2==3.0.1']
+ - id: prepare-cmake-build-files
+ name: Prepare CMake build files
+ stages: [commit]
+ language: python
+ entry: python ./scripts/generate_build_files.py --cmake
+ pass_filenames: false
+ - id: prepare-bazel-build-files
+ name: Prepare Bazel build files
+ stages: [commit]
+ language: python
+ entry: python ./scripts/generate_build_files.py --bazel
+ pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.0.1
+ rev: v4.4.0
hooks:
- - id: check-yaml
- stages: [commit]
- - id: check-json
- stages: [commit]
- id: end-of-file-fixer
stages: [commit]
- exclude: \.cp?p?$
- - id: requirements-txt-fixer
- stages: [commit]
- id: trailing-whitespace
stages: [commit]
- id: mixed-line-ending
args: ['--fix=lf']
description: Forces to replace line ending by the UNIX 'lf' character.
- - id: detect-private-key
- stages: [commit]
- - id: check-executables-have-shebangs
- stages: [commit]
- id: check-added-large-files
args: ['--maxkb=100']
stages: [commit]
- - repo: https://github.com/asottile/reorder_python_imports
- rev: v2.6.0
- hooks:
- - id: reorder-python-imports
- args: [--py3-plus]
- pass_filenames: true
- - repo: https://github.com/psf/black
- rev: 21.7b0
- hooks:
- - id: black
- - repo: https://github.com/asottile/blacken-docs
- rev: v1.8.0
- hooks:
- - id: blacken-docs
- additional_dependencies: [black==21.7b0]
- - repo: https://github.com/asottile/pyupgrade
- rev: v2.7.2
- hooks:
- - id: pyupgrade
- args: [--py36-plus]
- - repo: https://github.com/markdownlint/markdownlint
- rev: v0.9.0
- hooks:
- - id: markdownlint
- args: ["--style", ".mdl.rb"]