-
Notifications
You must be signed in to change notification settings - Fork 158
build: integrate pre-commit hooks with upstream files filtering support #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4a571be
c310875
fba660f
250c431
3a41223
d739d3b
c0c59e3
6cfa338
fab273b
ea3388d
9a632b4
45b9885
bcda734
4819f5c
f53e9d1
0565060
6394b7e
409def6
9d9c631
9afc8c4
8879363
b025d27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Usage: | ||
# 1) Install the hooks: | ||
# pre-commit install && pre-commit install --hook-type pre-push | ||
# 2) [Optional] Run the hooks on demand before committing: | ||
# pre-commit run --all-files | ||
# 3) [Optional] Run the hooks on demand before pushing changes: | ||
# pre-commit run --hook-stage pre-push --all-files | ||
# | ||
# NOTE: 2) and 3) are only needed to run the hooks manually. | ||
# The hooks are automatically run by git when committing or pushing changes. | ||
# | ||
# If you want to temporarily disable the hooks without uninstalling them, you can use: | ||
# git commit --no-verify | ||
# git push --no-verify | ||
# | ||
# If you want to uninstall the hooks, you can use: | ||
# pre-commit uninstall | ||
# | ||
# If you want to re-install the hooks, you can run 1) again. | ||
|
||
minimum_pre_commit_version: "3.6.0" | ||
|
||
repos: | ||
# Fast feedback at commit time: baseline golangci-lint (v1) | ||
- repo: https://github.com/golangci/golangci-lint | ||
rev: v1.63.4 | ||
hooks: | ||
- id: golangci-lint | ||
name: golangci-lint (baseline) | ||
args: ["--config=.golangci.yml"] | ||
stages: [pre-commit] | ||
|
||
# Local utility scripts and full repo checks | ||
- repo: local | ||
hooks: | ||
# Stricter extra lints (golangci-lint v2) on staged changes at pre-commit | ||
- id: extra-golangci-lint | ||
name: golangci-lint (extra via scripts/lint.sh) | ||
entry: scripts/lint.sh | ||
language: system | ||
stages: [pre-commit] | ||
pass_filenames: false | ||
env: | ||
TESTS: "avalanche_golangci_lint" | ||
|
||
- id: actionlint | ||
name: actionlint | ||
entry: scripts/actionlint.sh | ||
language: system | ||
files: ^\.github/workflows/.*\.(yml|yaml)$ | ||
stages: [pre-commit] | ||
pass_filenames: false | ||
|
||
- id: shellcheck | ||
name: shellcheck | ||
entry: scripts/shellcheck.sh | ||
language: system | ||
files: \.sh$ | ||
stages: [pre-commit] | ||
pass_filenames: false | ||
|
||
# General purpose housekeeping hooks | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v6.0.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
name: trailing-whitespace (filtered) | ||
entry: scripts/filter_precommit_files.sh trailing-whitespace-fixer -- | ||
pass_filenames: true | ||
args: [--markdown-linebreak-ext=md] | ||
- id: end-of-file-fixer | ||
name: end-of-file-fixer (filtered) | ||
entry: scripts/filter_precommit_files.sh end-of-file-fixer -- | ||
pass_filenames: true | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
name: check-yaml (filtered) | ||
entry: scripts/filter_precommit_files.sh check-yaml -- | ||
pass_filenames: true | ||
- id: check-toml | ||
name: check-toml (filtered) | ||
entry: scripts/filter_precommit_files.sh check-toml -- | ||
pass_filenames: true | ||
- id: check-json | ||
name: check-json (filtered) | ||
entry: scripts/filter_precommit_files.sh check-json -- | ||
pass_filenames: true | ||
# Exclude intentionally invalid JSON fixtures used by tests | ||
exclude: ^rpc/testdata/invalid-.*\.json$ | ||
|
||
# Markdown formatter | ||
- repo: https://github.com/hukkin/mdformat | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's standard here? I'm not sure if we want to make these changes just for the pre-commit hooks (added arbitrarily) if we're not also going to lint for them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the style guide it follows https://mdformat.readthedocs.io/en/stable/users/style.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @alarso16 re aligning pre-commit and linter checks. IMO the pre-commit is the fast-fail while the linter is the gatekeeper. |
||
rev: 0.7.22 | ||
hooks: | ||
- id: mdformat | ||
additional_dependencies: | ||
- mdformat-gfm==0.4.1 | ||
- mdformat-frontmatter==2.0.8 |
alarso16 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
// | ||
// Much love to the original authors for their work. | ||
// ********** | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm 99% sure that this is not what we want. By removing the blank space it will force the copyright header to become part of the package comment. Run I suspect that the header hasn't been configured correctly. |
||
package main | ||
|
||
import ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
// | ||
// Much love to the original authors for their work. | ||
// ********** | ||
|
||
package main | ||
|
||
import ( | ||
|
Uh oh!
There was an error while loading. Please reload this page.