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

Basic nix fmt configuration #2600

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

Basic nix fmt configuration #2600

wants to merge 13 commits into from

Conversation

pawelchcki
Copy link
Collaborator

@pawelchcki pawelchcki commented Jun 25, 2024

Motivation

Introduces treefmt-nix and related machinery to enable custom, fast and multi language formatting.

In addition this PR leverages automated creation of Nix actions in GHa to run fast formatting scans.

Changes

Improves the nix config and adds treefmt-nix configuration
Separate PRs exist which run the improved formatter on existing codebase:

Using latest python-black:
#2599

Using shfmt and markdown formatter:
#2602

@pawelchcki pawelchcki requested a review from a team as a code owner June 25, 2024 09:49
@cbeauchesne
Copy link
Collaborator

Could you add this to the unique entry point for formatting : ./format.sh ?

  • ./format.sh --check must not modify any file, and exit with status 1 if any file must be modified
  • ./format.sh should correct files if possible, and exit with status 1 if some file must be modified, and it can't be done automatically

@pawelchcki
Copy link
Collaborator Author

Done - I've modified format.sh to use this stuff.

  • backported the whitespace checks *and fixes
  • implemented shellcheck the same way it was done in lint/action.yaml
#cold start which included downloading the dependencies
pawel@pawelthink:~/work/system-tests$ time nix fmt
[INFO ] #alejandra: 3 files processed in 30.67ms
[INFO ] #whitespace: 607 files processed in 74.07ms
[INFO ] #shellcheck: 48 files processed in 874.86ms
[INFO ] #black: 299 files processed in 1.98s
633 files changed in 2s (found 1988, matched 957, cache misses 957)

real	0m16.965s
user	0m29.831s
sys	0m2.962s
pawel@pawelthink:~/work/system-tests$ time nix fmt
warning: Git tree '/home/pawel/work/system-tests' is dirty
0 files changed in 138ms (found 1988, matched 957, cache misses 0)

real	0m1.762s
user	0m1.393s
sys	0m0.371s

pawel@pawelthink:~/work/system-tests$ time nix fmt
warning: Git tree '/home/pawel/work/system-tests' is dirty
0 files changed in 131ms (found 1988, matched 957, cache misses 0)

real	0m0.679s
user	0m0.364s
sys	0m0.217s

@pawelchcki pawelchcki marked this pull request as draft November 22, 2024 18:14
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.

2 participants