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

chore: Configure pre-commit, update the justfile #890

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Mar 19, 2024

Setups pre-commit instead of the ad-hoc .github/pre-commit file, and cleans up the just recipes.

The main benefit of this is to avoid running both codebase tests on each commit, since pre-commit filters the required checks based on the modified files.

Updates DEVELOPMENT.md with the new commands. It should be a bit more straightforward now.

drive-by: Fixes for the trailing-whitespace and end-of-file-fixer hooks.

@aborgna-q aborgna-q requested a review from cqc-alec March 19, 2024 17:22
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.55%. Comparing base (3406e88) to head (d82d695).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #890      +/-   ##
==========================================
- Coverage   85.62%   85.55%   -0.07%     
==========================================
  Files          78       78              
  Lines       14397    14396       -1     
  Branches    14397    14396       -1     
==========================================
- Hits        12327    12317      -10     
- Misses       1436     1445       +9     
  Partials      634      634              
Flag Coverage Δ
python ∅ <ø> (∅)
rust 85.55% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran just check on this branch and got a couple of errors:

(env) alec:~/r/hugr$ just check
poetry run pre-commit run --all-files
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy:pydantic.
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check that executables have shebangs.....................................Failed
- hook id: check-executables-have-shebangs
- exit code: 1

specification/schema/serialization.md: marked executable but has no (or invalid) shebang!
  If it isn't supposed to be executable, try: `chmod -x specification/schema/serialization.md`
  If on Windows, you may also need to: `git add --chmod=-x specification/schema/serialization.md`
  If it is supposed to be executable, double-check its shebang.

check for merge conflicts................................................Passed
check toml...............................................................Passed
check vcs permalinks.....................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing specification/schema/hugr_schema_v1.json
Fixing specification/schema/hugr_schema_v0.json

trim trailing whitespace.................................................Passed
fix utf-8 byte order marker..............................................Passed
mixed line ending........................................................Passed
check python ast.........................................................Passed
check docstring is first.................................................Passed
debug statements (python)................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
mypy.....................................................................Passed
cargo format.............................................................Passed
cargo check..............................................................Passed
cargo test...............................................................Passed
cargo clippy.............................................................Passed
error: Recipe `check` failed on line 13 with exit code 1

Should we fix these before merging?

@aborgna-q
Copy link
Collaborator Author

Done.
It may be problematic that we have extra tests here that are not ran in CI (end-of-file-fixer and trailing-whitespace are the most problematic).
Should I disable them?

Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to keep or disable those checks.

@aborgna-q
Copy link
Collaborator Author

Let's leave them for now, we can always disable them if they become annoying

@aborgna-q aborgna-q added this pull request to the merge queue Mar 20, 2024
Merged via the queue into main with commit 63afb03 Mar 20, 2024
17 checks passed
@aborgna-q aborgna-q deleted the chore/pre-commit-rebase branch March 20, 2024 10:58
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