diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..f53dde9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-json + - id: check-toml + - id: check-yaml + - id: detect-private-key + - repo: https://github.com/rhysd/actionlint + rev: v1.6.24 + hooks: + - id: actionlint + - repo: https://github.com/asottile/reorder_python_imports + rev: v3.9.0 + hooks: + - id: reorder-python-imports + - repo: https://github.com/asottile/setup-cfg-fmt + rev: v2.2.0 + hooks: + - id: setup-cfg-fmt diff --git a/Makefile b/Makefile index 6566795..3b2d8c5 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,15 @@ # Set up an environment .PHONEY: setup -setup: +setup: setup-python setup-pre-commit + +.PHONE: setup-python +setup-python: bash ./dev/setup.sh +.PHONE: setup-pre-commit +setup-pre-commit: + pre-commit install + # Check all the coding style. .PHONY: lint lint: lint-shell lint-python diff --git a/pyproject.toml b/pyproject.toml index 8d04d02..dda4db7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,4 +53,5 @@ dev = [ "yapf >=0.29.0", "pyyaml >=5.3", "pdoc3 >=0.9.2", + "pre-commit >=2.15.0", ]