-
Notifications
You must be signed in to change notification settings - Fork 31
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
Check for conventional commits in CI #338
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; | ||
flake-root.url = "github:srid/flake-root"; | ||
treefmt-nix.url = "github:numtide/treefmt-nix"; | ||
pre-commit-hooks-nix = { | ||
|
@@ -32,6 +33,32 @@ | |
nixpkgs-fmt.enable = true; | ||
}; | ||
}; | ||
|
||
# TODO: Move this under `CIApps` once `omnix` supports running them automatically | ||
# CONSIDER: Generalise the script, see: https://github.com/juspay/services-flake/pull/338/files#r1773042527 | ||
apps.cz-check = rec { | ||
meta.description = program.meta.description; | ||
program = pkgs.writeShellApplication { | ||
name = "cz-check"; | ||
runtimeInputs = with pkgs; [ config.pre-commit.settings.tools.commitizen git gnugrep coreutils ]; | ||
meta.description = "Verify commit messages from the default branch to HEAD follow conventional commit format"; | ||
text = '' | ||
default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5) | ||
|
||
# Get the latest commit on the default branch | ||
# rev range using the `default_branch` branch name (e.g. main..HEAD), doesn't work in Github Actions | ||
latest_default_commit=$(git rev-parse origin/"$default_branch") | ||
|
||
current_commit=$(git rev-parse HEAD) | ||
|
||
if [ "$latest_default_commit" = "$current_commit" ]; then | ||
echo "No commits to check between $default_branch and HEAD." | ||
else | ||
cz check --rev-range "$latest_default_commit"..HEAD | ||
fi | ||
Comment on lines
+46
to
+58
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 implementation isn’t generic enough, i.e, it always assumes that the current branch is going to be merged to 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.
|
||
''; | ||
}; | ||
}; | ||
devShells.default = pkgs.mkShell { | ||
packages = with pkgs; [ | ||
just | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
CIApps
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom flake-schema that can be detected by omnix to run everything under it as custom app steps.