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

run pre-commit on PRs and have auto updates #311

Closed
Mikejmnez opened this issue Apr 24, 2024 · 3 comments
Closed

run pre-commit on PRs and have auto updates #311

Mikejmnez opened this issue Apr 24, 2024 · 3 comments
Assignees

Comments

@Mikejmnez
Copy link
Collaborator

Mikejmnez commented Apr 24, 2024

Description

I would like to set up pre-commit to run on GH as an action. It would run on every PR, and it should periodically trigger PR updating the hooks.

There are two ways to do this,

  1. Add a pre-commit.yml file under .github/workflows. You can see this repo for more details: pre-commit/action. This action is in maintanance mode, but it is pretty direct.
  2. Have pre-commit ci install on Pydap's repo.

In both scenarios, a .pre-commit-config.yaml file is needed in the main directory of pydap with the appropriate configuration (hooks, id, etc etc). You can read more about the hooks pre-commit runs in the documentation here.

What I did

I have already included the .pre-commit-config.yaml with the appropriate configuration on Pydap.

However, I tried option 2) above, to add pydap onto as an installation on pre-commit ci. It looks like the request needs to be approved and after a couple of days (or more) it states that it is pending. You can see from the screenshot below:

Screenshot 2024-04-23 at 9 15 20 PM

I never got an email about this. Did you @jgallagher59701 ?

It may be that the easier way to move forwards with this is to manually create a github action worflow, as detailed in option 1). It requires minimal changes and should work right away.

@jgallagher59701
Copy link
Member

I think I did get an email, but that's because I set up notifications in my GitHub profile just recently. It was pretty complicated - I could not replicate the process other than to say that I googled to learn how to set those options.

Are you wanting to get something automated to reformat your source code when you push a commit to GitHub? (If so, that is what I want as well and I don't know exactly how to do it, but I know we used to do it using Subversion so I think
it's possible)

@Mikejmnez
Copy link
Collaborator Author

Mikejmnez commented Apr 24, 2024

Are you wanting to get something automated to reformat your source code when you push a commit to GitHub? (If so, that is what I want as well and I don't know exactly how to do it, but I know we used to do it using Subversion so I think
it's possible)

The answer is Yes, and it can be done via running pre-commit on github actions.

There are two ways to set up some formatting on github with pre-commit. One of the ways is to do it manually, which I ended up doing in PR #312. And so we can cancel the online request since it is no longer needed.

What pre-commit does:

  1. Applies automatic rules for linting, spacing, length of lines, whitespace, etc. Each of these is a specific hook.
  2. Requires a configuration file. This is the pre-commit-config.yaml already at the root of this repo. You can check all the specifications I defined is such file.
  3. It can run locally on the developers computer. It requires installation once, and everytime there is a commit, pre-commit runs on all files. When necessary makes automatic corrections, but it may not always be able to fix things automatically (for example whitespaces between operators).
  4. Can trigger automatic PRs to be continuously be updated with respect to the newer formatting requires by latest Python version format. In that scenario, the PR will only change the file /.github/workflows/pre-commit.yml, but these updates can trigger a fail during the testing. But this way the code can be kept up to date for formatting standards.

1-3) Already are True for Pydap. PR #312 allows for 4).

@Mikejmnez
Copy link
Collaborator Author

Closed by #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants