Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

inclyc
Copy link
Member

@inclyc inclyc commented Apr 27, 2024

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

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)
Copy link
Member

@MattSturgeon MattSturgeon left a 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 ]
Copy link
Member

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.

Suggested change
[ pull_request ]
push

Copy link
Member Author

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Member Author

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!)

.github/workflows/nixf-tidy-action.yaml Outdated Show resolved Hide resolved
@inclyc inclyc marked this pull request as draft April 27, 2024 11:41
@GaetanLepage
Copy link
Member

I am personally not against trying this. However, I would much prefer having a pre-commit hook based solution (using flake-parts).
Indeed, this could be dealt with within the development environment and also, naturally checked by the CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants