ca1989

ca1989

Hi all,

as per title, I am considering the possibility to add git hooks to a Phoenix project.
We are a team af a few people (< 10) with the same editor setup.
No CI workflow is present at the moment.

That is why I would like to add git hooks, do you have advices on which checks to run and when?

I would love for them to don’t get much in the way (for example, when prototyping features on temporary branches).

I thought about this:

  • mix clean && mix compile on push
  • mix format on commit (is that a good idea to format files in place on commit? Running --check-formatted could be too annoying)
  • mix credo and mix test as responsibilities of developers

I’d love to hear from you
Kind Regards

Showing Posts 1 to 10

hauleth

hauleth

Start with solving that.

IMHO commit hook should not modify code.

crova

crova

You might want to look at ex_check | Hex.
You could put that on your hook.

al2o3cr

al2o3cr

I’m curious about the motivation of this step; why would somebody be committing code that doesn’t compile? If it doesn’t compile, it can’t run in tests or even with manual prodding.

szsoppa

szsoppa

Hey! There is a cool lib for that - helps maintain the proper “local CI” (Git hooks) for all of the devs in the project: GitHub - qgadrian/elixir_git_hooks: 🪝 Add git hooks to Elixir projects · GitHub.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

FYI this will be a real pain the first time somebody on your team needs to push up code that won’t compile so that a team member can help them.

I agree with @hauleth, this is the problem to solve. You can put specific rules about specific branches, rules about how PRs get merged etc, and it lets you handle mix credo and mix test centrally too.

ca1989

ca1989 OP

In our setup you have to run tests manually. If you forget to run them you could very much commit code that doesn’t compile :confused:

Which is the reason I thought about git hooks

ca1989

ca1989 OP

Thank you all,
setting up a CI seems the most logical first step to make.

eahanson

eahanson

I have a shell script in every project I work on called bin/dev/shipit.

It does all the things such as:

  • runs tests
  • runs dialyzer
  • runs mix audit
  • runs the formatter

If all those things pass, then it pushes. It’s very simple but it works (if everyone remembers to run it instead of just git push). If you for some reason need to push with one or more of those steps failing, you can just not run the script but instead just run git push.

tfwright

tfwright

I am strongly against imposing workflows on developers collaborating on a project. Everybody has a different order/process for producing code that is ready for review, and until its ready for review (and CI) all barriers and challenges should be minimized. If part of your process is to autoformat your code on every commit using a git hook, by all means do that, but please, please don’t impose that on your fellow devs who do not want to think about formatting at all until everything is ready.

gregvaughn

gregvaughn

I like writing a custom mix ci task/alias. The CI server should be configured to execute that, but also each developer can choose to run that on their own machine in case they need help diagnosing a problem that only occurs on CI.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews