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

Precommit: formatting and creation of notebooks/markdown #25

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Conversation

APJansen
Copy link
Contributor

@APJansen APJansen commented Mar 26, 2024

This PR adds precommit hooks for JuliaFormatter and notebook creation, as well as a check on the formatting in the CI.

See here for instructions on how to set it up.

JuliaFormatter hook

I have used the "official" JuliaFormatter hook following this.

It is not as nice as what I'm used to in python with black, in that a. it checks all files rather than only those that have been modified, and b. it doesn't list the files it had to format.

Not a big issue, as long as everyone uses it the only files that it has to modify should be ones you changed, and if you want to see exactly which, you can just do a git status.

notebooks hook

I didn't find any existing hook for this, so I created one that just calls the julia script (changing the the overwrite setting to true). It seems to work fine for me.

JuliaFormatter CI

Here I also used the official one. It seems overly complicated to me, going through some code checker service reviewdog. Also it doesn't seem to be working, in that it passed on this PR before I applied any formatting.

Remaining issues

  • JuliaFormatter CI
  • It is slow enough to be annoying, ~7 seconds for me. Perhaps both hooks do need a check for files that have changed and only be applied there.

@APJansen APJansen self-assigned this Mar 26, 2024
@APJansen APJansen force-pushed the precommit branch 5 times, most recently from 90051e0 to 9815494 Compare March 26, 2024 13:18
@APJansen
Copy link
Contributor Author

I had to run the formatter in the CI manually as well (i.e. without using the official action), but now it works fine. here is an example of what you see on failed formatting: all the changes it made.

@APJansen APJansen marked this pull request as ready for review March 26, 2024 13:22
@APJansen
Copy link
Contributor Author

I rebased this on main and squashed everything. The only thing that's not working is that it considers also the files in examples/coupling_functions as notebooks, but that's probably best fixed in a separate PR changing the file structure.

@APJansen
Copy link
Contributor Author

sorry one sec, didn't actually rebase on latest main.

@APJansen
Copy link
Contributor Author

Can you both check if you can set up pre-commit following the instructions in CONTRIBUTING.md, and if when you run pre-commit run --all-files nothing changes? Just to be sure it's correctly reading the settings for everyone.

@APJansen APJansen merged commit b3842f0 into main Mar 26, 2024
4 checks passed
@luisaforozco luisaforozco deleted the precommit branch May 24, 2024 13:01
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.

Implement git hooks to create markdowns and notebooks Structure as a Julia package
2 participants