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

Add GitHub workflow for running pre-commit #51

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented Mar 14, 2024

Add "pre-commit" GitHub Actions workflow with standard pre-commit hooks1 as well as ruff2, prettier3 and schema validations4 for GitHub workflow files.

Footnotes

  1. https://github.com/pre-commit/pre-commit-hooks

  2. https://beta.ruff.rs/docs/

  3. https://prettier.io/docs/en/

  4. https://github.com/python-jsonschema/check-jsonschema

This commit updates the Python scripts based on the automatic fixes
applied using the ruff configuration introduced in the subsequent commit:

```
$ pre-commit run -a

[...]

Fixed 85 errors:
- Modules/Scripted/Home/Home.py:
     3 × COM812 (missing-trailing-comma)
     2 × D202 (no-blank-line-after-function)
     1 × UP015 (redundant-open-modes)
     1 × UP004 (useless-object-inheritance)
- Modules/Scripted/VPAWModel/VPAWModel.py:
    31 × COM812 (missing-trailing-comma)
     2 × D202 (no-blank-line-after-function)
     1 × F401 (unused-import)
- Modules/Scripted/VPAWVisualize/VPAWVisualize.py:
    32 × COM812 (missing-trailing-comma)
     4 × RUF010 (explicit-f-string-type-conversion)
     1 × SIM114 (if-with-same-arms)
- Modules/Scripted/VPAWVisualize/vpawvisualizelib/isosurfaces.py:
     6 × COM812 (missing-trailing-comma)
     1 × D202 (no-blank-line-after-function)
```
This commit updates the markdown files based on the automatic fixes
applied using the prettier introduced in the subsequent commit.
@jcfr jcfr mentioned this pull request Mar 14, 2024
@jcfr
Copy link
Contributor Author

jcfr commented Mar 14, 2024

Once this is integrated the following commits will be added to .git-blame-ignore-revs:

  • STYLE: Update python script using ruff
  • STYLE: Reformat markdown documents using prettier

For reference, .git-blame-ignore-revs was introduced in:

Copy link
Contributor

@Leengit Leengit left a comment

Choose a reason for hiding this comment

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

Thank you. I'm not knowledgeable enough to critique the yaml and toml files but I assume that you've done the right thing there. The md files look good. For the py files, my only critique is that taking repr out of some f-strings means that they'll print the likes of the name is MyFile rather than the name is 'MyFile'. If you intended that change then that's fine. If not, perhaps revert that part.

Copy link
Contributor

@ebrahimebrahim ebrahimebrahim left a comment

Choose a reason for hiding this comment

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

Some of the commits here should be added to the .git-blame-ignore-revs.
(Thank you for providing the .git-blame-ignore-revs in #50 btw)

EDIT: I just noticed your comment above saying you will add to .git-blame-ignore-revs later. It could just be done here in this PR though right?

The CI stuff like ruff and pre-commit is going over my head but I appreciate having it and know it will make life better. Not sure how I would even test it though, so I'm not including that in my review. Happy to merge and see what happens. Thanks for adding that 😄

@jcfr
Copy link
Contributor Author

jcfr commented Mar 15, 2024

I just noticed your comment above saying you will add to .git-blame-ignore-revs later. It could just be done here in this PR though right?

Since we will likely integrate with Rebase and Merge to keep the history linear, we do not now the commit beforehand

@jcfr
Copy link
Contributor Author

jcfr commented Mar 15, 2024

see what happens

image image

@ebrahimebrahim
Copy link
Contributor

Rebase and Merge

Why not do an ordinary merge?

This is the problem with rebasing, that it changes the history and therefore the commit hashes

Hmm on second thought maybe merge commits themselves can show up in the git blame... idk

@jcfr
Copy link
Contributor Author

jcfr commented Mar 15, 2024

Why not do an ordinary merge?

In the context of Slicer-based project like this one, this allows to keep the history simple and easy to comprehend. It also enable us to use the computed revision (monotonously increasing revision number) to compare version.

References:

@ebrahimebrahim
Copy link
Contributor

ebrahimebrahim commented Mar 15, 2024

Why not do an ordinary merge?

In the context of Slicer-based project like this one, this allows to keep the history simple and easy to comprehend. It also enable us to use the computed revision (monotonously increasing revision number) to compare version.

References:

Haha, okay fine. I always dislike when commit hashes change on me. But I can understand from the references you provided why it can be desirable to have linear history

@jcfr
Copy link
Contributor Author

jcfr commented Mar 15, 2024

I always dislike when commit hashes change on me.

Ditto. To clarify, commit already integrated in the main branch would not change.

@jcfr jcfr merged commit a147a1d into KitwareMedical:main Mar 15, 2024
1 check passed
@jcfr jcfr deleted the add-ci-workflow branch March 15, 2024 15:20
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