Skip to content

Commit e76fec4

Browse files
authored
ci: Introduce pre-commit hooks (#765)
* add pre-commit config * ignore yaml list indentation style * ignore long lines in python (because we want inline comments for version info) * fix lint issues fix python lint * move actionlint.yaml to the right place * add shellcheck pre-commit hook * replace flake8 with ruff * remove flake8 config * ci: add pre-commit checks on pull request * ci: disable pr-commit action until after the workflow is registered * ci: rename reviewdog workflow to be grouped with other PR workflows * fix lint issues
1 parent 86555b3 commit e76fec4

File tree

76 files changed

+236
-127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+236
-127
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
*Please add a description here.*
44

5-
65
## Definition of Done Checklist
76

87
- Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
98
- Please make sure all these things are done and tick the boxes
10-
9+
1110
```[tasklist]
1211
- [ ] Changes are OpenShift compatible
1312
- [ ] All added packages (via microdnf or otherwise) have a comment on why they are added

.github/workflows/pr_pre-commit.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
12+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
13+
with:
14+
python-version: '3.12'
15+
# NOTE (@NickLarsenNZ): Disabled until the workflow is registered in Github Actions (after merge to main)
16+
# - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
33
*.py[cod]
4-

.markdownlint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ MD013:
1818
MD024:
1919
# Only check sibling headings
2020
siblings_only: true
21+
22+
# MD033/no-inline-html Inline HTML
23+
MD033:
24+
allowed_elements: [details, summary, img]

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# See https://pre-commit.com for more information
3+
fail_fast: false
4+
5+
exclude: \.patch$
6+
7+
# See https://pre-commit.com/hooks.html for more hooks
8+
repos:
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.2.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: detect-aws-credentials
15+
args: ["--allow-missing-credentials"]
16+
- id: detect-private-key
17+
18+
- repo: https://github.com/adrienverge/yamllint
19+
rev: v1.26.3
20+
hooks:
21+
- id: yamllint
22+
23+
- repo: https://github.com/igorshubovych/markdownlint-cli
24+
rev: v0.31.1
25+
hooks:
26+
- id: markdownlint
27+
28+
- repo: https://github.com/koalaman/shellcheck-precommit
29+
rev: v0.10.0
30+
hooks:
31+
- id: shellcheck
32+
args: ["--severity=info"]
33+
34+
# WARNING (@NickLarsenNZ): Nix users need to install ruff first.
35+
# If you do not, you will need to delete the cached ruff binary shown in the
36+
# error message
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: v0.5.1
39+
hooks:
40+
# Run the linter.
41+
- id: ruff
42+
# Run the formatter.
43+
- id: ruff-format
44+
45+
- repo: local
46+
hooks:
47+
- id: update-readme-badges
48+
name: update-readme-badges
49+
language: system
50+
entry: .scripts/update_readme_badges.sh
51+
stages: [commit, merge-commit, manual]
52+
pass_filenames: false

.scripts/enumerate-product-versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
]
2323

2424
for product in conf.products:
25-
product_name = product['name']
25+
product_name = product["name"]
2626
if product_name not in PRODUCTS:
2727
continue
2828

29-
for version in product['versions']:
29+
for version in product["versions"]:
3030
print(f"{product_name}#{version['product']}")

.scripts/upload_new_tini_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ for arch in "${ARCHITECTURES[@]}"; do
3838
# tini does not currently publish signatures or SBOMs
3939
# renaming binary because original file name has no version
4040
echo "Downloading TINI"
41-
curl --fail -Ls -o "tini-$VERSION-$arch" "https://github.com/krallin/tini/releases/download/v$VERSION/tini-$arch"
41+
curl --fail -Ls -o "tini-$VERSION-$arch" "https://github.com/krallin/tini/releases/download/v$VERSION/tini-$arch"
4242

4343
echo "Uploading to Nexus"
4444
curl --fail -u "$NEXUS_USER:$NEXUS_PASSWORD" --upload-file "tini-$VERSION-$arch" 'https://repo.stackable.tech/repository/packages/tini/'

.scripts/upload_sig_storage_driver.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# shellcheck disable=all
2+
#
13
# Don't do this on your machine, as we need to sign the mirrored image, which should be done by a GitHub CI.
24
# Use the action "Mirror container image" in the docker-images repo for that.
35
# You can e.g. pull the image from

.yamllint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ rules:
1010
check-keys: false
1111
comments:
1212
min-spaces-from-content: 1 # Needed due to https://github.com/adrienverge/yamllint/issues/443
13+
indentation: disable

0 commit comments

Comments
 (0)