services-flake icon indicating copy to clipboard operation
services-flake copied to clipboard

Conventional Commits pre-commit check is not working

Open srid opened this issue 1 year ago • 13 comments

The second commit in PR #127 has the commit message use same installer - yet the pre-commit check did not catch it, as it doesn't comfort to conventional commits spec.

srid avatar Mar 07 '24 16:03 srid

Commit's vanished because I had to force push, but the commit message was literally use same installer.

srid avatar Mar 07 '24 16:03 srid

The hook itself works,

image

However, if I skip it:

image

And run the flake check:

image image

... it passes ^

srid avatar Mar 07 '24 18:03 srid

I don't think the pre-commit module actually adds a flake check.

Also, https://github.com/convco/convco

We can run this manually

image

srid avatar Mar 07 '24 18:03 srid

Yeah, when running in a flake check it won't have access to .git/COMMIT_EDITMSG and will therefore not be able to check the commit message. The workaround is to use nix run nixpkgs#pre-commit directly on CI. That is what I found as well, although I was using conform.

terlar avatar Mar 07 '24 20:03 terlar

A PR can have multiple commits, so whatever flake check we add must check all of them.

srid avatar Mar 08 '24 12:03 srid

But since git history will be available, perhaps it should be run outside of Nix, in github actions.

srid avatar Mar 08 '24 12:03 srid

This command checks for all the commits on the current branch, starting from main:

cz check --rev-range main..HEAD

shivaraj-bh avatar Mar 08 '24 12:03 shivaraj-bh

Cool. We should also consider #134 when deciding between cz and convco.

srid avatar Mar 08 '24 12:03 srid

This command checks for all the commits on the current branch, starting from main:

cz check --rev-range main..HEAD

Can’t do this until https://github.com/NixOS/nix/issues/6900

shivaraj-bh avatar May 20 '24 11:05 shivaraj-bh

I have made some progress at https://github.com/juspay/services-flake/tree/cz-check, will wait until there is a reliable way to copy .git to the store.

shivaraj-bh avatar May 20 '24 11:05 shivaraj-bh

Copying .git to the Nix store sounds like a bad idea in general? We only need history of commit messages, not the whole index (much less copy a variation of it every time to the store).

srid avatar May 20 '24 16:05 srid

We only need history of commit messages, not the whole index

I doubt we can pass this to flake check in a straightforward way.

One hack to make this work will be to use writeShellApplication and run cz check --rev-range main..HEAD via nix run.

shivaraj-bh avatar May 21 '24 09:05 shivaraj-bh

FYI: this recent commit https://github.com/juspay/services-flake/commit/5960a2c553ba6f5efec8d6aad64219c8fa036e50 does not follow the convention, so it is going to be missed when we next generate the changelog. @shivaraj-bh

srid avatar Sep 22 '24 14:09 srid