Skip to content

Commit add0a35

Browse files
committed
Switch to pre-commit for linting
Signed-off-by: John Strunk <[email protected]>
1 parent 9f2db42 commit add0a35

File tree

4 files changed

+81
-69
lines changed

4 files changed

+81
-69
lines changed

.ci-scripts/pre-commit.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

.ci-scripts/yamlconfig.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ ignore: |
1111
hack/crds/*
1212
helm/volsync/**
1313
rules:
14+
comments: # renovate-bot dosen't put 2 spaces before the version number
15+
ignore: |
16+
.github/workflows/*
1417
indentation:
1518
indent-sequences: consistent
1619
line-length:

.github/workflows/operator.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,26 @@ jobs:
2727

2828
steps:
2929
- name: Checkout source
30-
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
30+
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
31+
32+
- name: Install pre-commit
33+
run: |
34+
python -m pip install --user pre-commit
35+
echo "PYHASH=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
36+
37+
- name: Enable cache for pre-commit hooks
38+
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
39+
with:
40+
path: ~/.cache/pre-commit
41+
key: pre-commit|${{ env.PYHASH }}|${{ hashFiles('.pre-commit-config.yaml') }}
42+
restore-keys: |
43+
pre-commit|${{ env.PYHASH }}
44+
pre-commit|
3145
32-
- name: Install prereqs
46+
- name: Run pre-commit checks
3347
run: |
34-
echo 'APT::Acquire::Retries "5";' | sudo tee /etc/apt/apt.conf.d/80-retries
35-
sudo apt-get update
36-
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip ruby
37-
sudo gem install asciidoctor mdl
38-
sudo pip3 install yamllint
39-
- name: Run linters
40-
run: ./.ci-scripts/pre-commit.sh --require-all
48+
pre-commit run -a
49+
pre-commit gc
4150
4251
generated-files-check:
4352
name: Auto Generated Files Check

.pre-commit-config.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
# yamllint disable rule:line-length
3+
4+
# See https://pre-commit.com for more information
5+
# See https://pre-commit.com/hooks.html for more hooks
6+
7+
# Install in your local dev environment
8+
# > pip install --upgrade --user pre-commit
9+
# Enable the hooks for this repo
10+
# > pre-commit install
11+
12+
# Exclude the vendored sources from all checks since we don't control them
13+
exclude: |
14+
(?x)^(
15+
mover-restic/minio-go/.*|
16+
mover-restic/restic/.*
17+
)$
18+
repos:
19+
- repo: https://github.com/pre-commit/pre-commit-hooks
20+
rev: "v4.4.0"
21+
hooks:
22+
- id: check-added-large-files # Prevents giant files from being committed
23+
- id: check-json # Check that JSON files are valid
24+
- id: check-merge-conflict # Check for files that contain merge conflict strings
25+
- id: check-symlinks # Ensure symlinks have a valid target
26+
- id: check-toml # Ensure toml files are valid
27+
- id: check-xml # Check that XML files are valid
28+
- id: end-of-file-fixer # Ensures that a file is either empty, or ends with one newline
29+
- id: fix-byte-order-marker # Forbid utf-8 byte order marker
30+
- id: trailing-whitespace # Trims trailing whitespace
31+
args: [--markdown-linebreak-ext=md]
32+
33+
- repo: https://github.com/pre-commit/pygrep-hooks
34+
rev: "v1.10.0"
35+
hooks:
36+
- id: rst-backticks
37+
- id: rst-directive-colons
38+
- id: rst-inline-touching-normal
39+
40+
- repo: https://github.com/adrienverge/yamllint
41+
rev: "v1.32.0"
42+
hooks:
43+
- id: yamllint
44+
args: ["--strict", "-c", ".ci-scripts/yamlconfig.yaml"]
45+
46+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
47+
rev: "3.0.0"
48+
hooks:
49+
- id: shellcheck
50+
51+
- repo: https://github.com/markdownlint/markdownlint
52+
rev: "v0.12.0"
53+
hooks:
54+
- id: markdownlint
55+
args: ["--style", ".ci-scripts/mdl-style.rb"]
56+
57+
- repo: https://github.com/renovatebot/pre-commit-hooks
58+
rev: "36.78.7"
59+
hooks:
60+
- id: renovate-config-validator

0 commit comments

Comments
 (0)