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 formatter pre-commit hook #310

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Conversation

whabanks
Copy link
Contributor

@whabanks whabanks commented Jul 26, 2024

Summary | Résumé

This PR adds a Ruff formatter pre-commit hook. Whenever git commit is performed, the hook will run the formatter on the staged files. Once complete just stage the formatting changes and continue with the commit.

Note:
If you do your committing outside of the vscode integrated terminal, then in order for this hook to work you need to:

  1. install the pre-commit package into your local python environment
  2. Run pre-commit install while in the repo
  3. Run pre-commit run to test if it works

image

Test instructions | Instructions pour tester la modification

Testing python file changes

  1. Build and open the dev container
  2. Edit a python file, rearranging the import order
  3. Commit the file
  4. Note that the two pre-commit hook actions, (ruff, ruff-format) are run.
  5. Do a git status and inspect the formatting changes

image

Testing non-python file changes

  1. Make a small edit to the makefile
  2. Commit the change
  3. Note that both the ruff and ruff-format hooks are skipped, and the commit command completes

image

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

Copy link

@P0NDER0SA P0NDER0SA left a comment

Choose a reason for hiding this comment

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

I think this looks good!

@whabanks whabanks merged commit be08ae2 into main Jul 30, 2024
4 checks passed
@whabanks whabanks deleted the experiment/formatter-pre-commit-hook branch July 30, 2024 20:29
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