this post was submitted on 20 Mar 2025
26 points (78.3% liked)

Programming

19813 readers
392 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] lemmeBe@sh.itjust.works 12 points 1 month ago (4 children)

Do formatting and linting and such autofix issues automatically as part of pre-commit checks. That way they don't end up as part of the CI.

[–] catalyst@lemmy.world 8 points 1 month ago (1 children)

Agreed. The idea of throwing code up at the CI and expecting it to fix my mistakes seems like a bad habit to me.

[–] lemmeBe@sh.itjust.works 7 points 1 month ago

Yep, I'd say so too. The moment I read the part about formatting in the CI, I thought to myself: I don't think GitHub Actions are the problem at hand. 😄

[–] FizzyOrange@programming.dev 7 points 1 month ago (1 children)

You need them in CI anyway to check people have actually done that, but yeah you definitely don't need to have CI automatically fix formatting and commit the fixes. That's crazy.

[–] lemmeBe@sh.itjust.works -4 points 1 month ago* (last edited 1 month ago) (1 children)

No, you don't.

To check if people have done what - committed? That's the only thing they need to do, and they'll stumble upon a roadblock immediately if the typecheck or lint fails.

Committing itself won't be possible... That's why we have automated pre-commit checks that don't depend on people remembering to do them manually.

[–] FizzyOrange@programming.dev 4 points 1 month ago (1 children)

To check that people ran the pre-commit linters.

Committing itself won’t be possible

That's not how pre-commit hooks work. They're entirely optional and opt-in. You need CI to also run them to ensure people don't forget.

[–] lemmeBe@sh.itjust.works -2 points 1 month ago (1 children)

They're optional if you make them optional. I didn't. You do as you please. 😄

[–] FizzyOrange@programming.dev 5 points 1 month ago (1 children)

No, they're inherently optional in Git. There's no way to "check in" a git hook. You have to put in your README

Clone the repo and then please run pre-commit install! Oh and whatever you do don't git commit --no-verify!

You definitely need to actually check the lints in CI. It's very easy though, just add pre-commit run -a to your CI script.

[–] bamboo@lemm.ee 2 points 1 month ago

pre-commit also has a free service for open source GitHub repos too. They’ll even push an autofix commit for you if your tools are configured for it

[–] normalexit@lemmy.world 3 points 1 month ago

This is the way. I do my checks on pre push because my team has a PR driven workflow. I also have an alias to run-tests && git push origin HEAD since my tests are expensive (minutes to run thousands of tests), and I didn't want that in a git hook.

[–] Flipper@feddit.org 2 points 1 month ago (1 children)

If it's open source I'd still add it, because a lot of people can't follow basic instructions.

[–] lemmeBe@sh.itjust.works -1 points 1 month ago (1 children)

They don't have to follow anything except try to commit their changes. Won't be possible even locally if linting or typechecking fail.

[–] bamboo@lemm.ee 2 points 1 month ago

Pre-commit hooks can’t be installed automatically and most people won’t even know they exist.