Skip to content
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

chore: more precommit hooks #1325

Merged
merged 10 commits into from
Nov 27, 2024

Conversation

jjmaestro
Copy link
Contributor

@jjmaestro jjmaestro commented Nov 19, 2024

Note

Stacked on top of #1327

Here's a bit of a winter house cleaning :)

Add a bunch of pre-commit hooks:

  • Some basic hooks to prevent usual whitespace nits (mixed line endings, trailing whitespace and missing EOF) and merge conflicts
  • Lint YAML (actions) and validate GH Actions (two validators because they are both quite useful for different reasons!)
  • Also validate shell scripts and Makefiles (NOTE: one of the GH Action validators also shellchecks the scripts in them :)
  • Finally, skip checks on generated files (diff/patches and testing expected outputs).

Then, run pre-commit run --all-files to lint and fix the things that can be automatically fixed.

Finally, a few more commits to fix the stuff that can't be fixed manually:

  • some outdated GH Actions + shellcheck parts of the GH actions
  • check Makefiles
  • shellcheck scripts and exclude examples/ because there's quite a bunch of warnings so it's probably better to leave those for another PR.

@jjmaestro
Copy link
Contributor Author

Ah, forgot to double-check tests locally :S The .pre-commit hooks modified some expected test output. I'll exclude those files as well.

@jjmaestro jjmaestro force-pushed the chore-more-precommit-hooks branch from 445ed20 to 7e5e93e Compare November 19, 2024 11:58
I broke the patch when changing the URLs because the change was done in
a context line that doesn't exist in the real branch.
Update to docs patches so that they all build with the stardoc from
main.

NOTE: I used this gist to generate and test these patches:

https://gist.github.com/jjmaestro/8f42d1ea04988ca86011de427b245ceb
* Add pre-commit linting and validation
* Auto-generate the strategy matrix
* Move Bazelisk and mdBook versions to `env` so that it's easier to
  test and upgrade to new versions.
* `fail-fast: false` so that when one of the matrix jobs fails so that
  we can see failures for all of the jobs (easier to debug and the jobs
  are lightweight so it's not too costly).
* Simplify the patching of old branches
* Make steps easier to read, shortening lines and adding whitespace
@jjmaestro jjmaestro force-pushed the chore-more-precommit-hooks branch from 7e5e93e to e8206b0 Compare November 20, 2024 16:20
* Some basic hooks to prevent usual whitespace nits (mixed line endings,
  trailing whitespace and missing EOF) and merge conflicts

* Lint and validate all YAML (actions) and GH Actions (two validators
  because they are both quite useful for different reasons!)

* Also validate shell scripts and Makefiles (NOTE: one of the GH Action
  validators also shellchecks the scripts in them :)

* Finally, skip checks on bazel-* directories, generated files
  (diff/patches and generated files used as expected output in tests).
Automatic linting of all the files. Also, commit with --no-verify
because there's still a bunch of things that require manual fixing.
There's a lot of stuff reported so excluding it from the time being,
will probably create a separate PR just for this.
@jjmaestro jjmaestro force-pushed the chore-more-precommit-hooks branch from e8206b0 to c296c51 Compare November 20, 2024 17:26
@jjmaestro
Copy link
Contributor Author

@jsharpe hopefully you'll like this one, it makes it easier to contribute stuff :) This one should be all green once #1327 lands!

@jsharpe
Copy link
Member

jsharpe commented Nov 26, 2024

Sigh, more download issues in CI.. Seems the python.org download site has some bad permissions at the moment.

@jsharpe jsharpe enabled auto-merge (squash) November 27, 2024 01:05
@jsharpe jsharpe merged commit be14cca into bazel-contrib:main Nov 27, 2024
20 checks passed
@jjmaestro jjmaestro deleted the chore-more-precommit-hooks branch November 27, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants