-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
ci: introduce nixf-tidy-action
#1469
base: main
Are you sure you want to change the base?
Conversation
nixf-tidy-action is a nix linter based on libnixf. It detects deadcode, unused `rec`, and syntax errors. nixf-tidy-action will only report warnings on changed files in diff (thus it will not be very pedantic). ![nixf-sample](https://discourse.nixos.org/uploads/default/optimized/3X/a/f/af8abbdc32b4d27f525170e45c57812816dba674_2_986x1000.png)
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.
Thanks, this looks interesting!
name: nixf-tidy code linter | ||
|
||
on: | ||
[ pull_request ] |
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.
Prefer YAML syntax to JSON-style
Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").
Instead, we'd want this to run whenever a branch is updated (push).
We could use branches-ignore
to prevent running on main
and nixos-*
, but IMO I don't see an issue with having the CI on these branches too.
Note if the action expects github.event.pull_request.head.sha
, this'll be missing when using on.push
. Instead github.sha
or GITHUB_SHA
should be used for non-pr events.
[ pull_request ] | |
push |
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.
Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").
I haven't test it exactly for events other than "pull_request", maybe I should update the action itself then.
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.
Also, I'm not sure pull_request is the right event here. That runs whenever a PR is opened, edited, reviewed, etc (see "activity types").
I think some of my assumptions were off here. The pull_request
event does get triggered by a bunch of stuff, but pushes to a PR branch don't always seem to trigger the push
event...
extra_nix_config: | | ||
trusted-public-keys = nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= | ||
substituters = https://nix-community.cachix.org https://cache.nixos.org/ | ||
- run: nix profile install github:nix-community/nixd#nixd |
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.
IMO this should be the responsibility of the nixf-tidy-action
action.
Is there some technical reason why we need to install the action's dependency in our workflow?
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.
IMO this should be the responsibility of the
nixf-tidy-action
action.Is there some technical reason why we need to install the action's dependency in our workflow?
Thanks, I just wrote nixf-tidy-action
action in purely typescript. Thus I think it is more elegant to handle dependencies in nix?
(Otherwise these installation should be performed in "js" exec, looks bad!)
Co-authored-by: Matt Sturgeon <[email protected]>
I am personally not against trying this. However, I would much prefer having a pre-commit hook based solution (using flake-parts). |
nixf-tidy-action is a nix linter based on libnixf. It detects deadcode, unused
rec
, and syntax errors.nixf-tidy-action will only report warnings on changed files in diff (thus it will not be very pedantic).