CDCgov / ww-inference-model

An in-development R package and a Bayesian hierarchical model jointly fitting multiple "local" wastewater data streams and "global" case count data to produce nowcasts and forecasts of both observations
https://cdcgov.github.io/ww-inference-model/
Apache License 2.0
17 stars 2 forks source link

Add GH actions to automatically commit autofixes from `pre-commit` #139

Open kaitejohnson opened 2 months ago

kaitejohnson commented 2 months ago

Goal

Currently have to pull locally and run pre-commit --all-files and commit the result to apply autofixes, which can be slow and annoying especially in final stages of review with a number of minor tweaks. @zsusswein has set this up to be done automatically via github actions

zsusswein commented 2 months ago

See the workflow file with the change here: https://github.com/CDCgov/cfa-epinow2-pipeline/pull/18

dylanhmorris commented 2 months ago

Adjusted the title and text a bit to be more specific. @kaitejohnson can you confirm that this is what you're looking to do?

kaitejohnson commented 2 months ago

Yeah, I thought it was a quick fix though and I am not sure it is so leaving as a draft. Feels low priority.

seabbs commented 2 months ago

As discussed with Zach I think automating this will get very annoying. I think instead you might want to look at PR comment triggered actions to do this.

kaitejohnson commented 2 months ago

I think that it what @zsusswein implemented! So only reruns for suggestions. I need to look into it but agree it isn't top priority, might just close for now. I thought it would be a two second thing that would save us from rerunning pre-commit --all-files

zsusswein commented 2 months ago

I did two things:

  1. Pre-commit hooks run in CI and auto-commit & -push changes on failure
    • This doesn't include roxygen because that particular hook requires manually keeping a second, duplicate package manifest in the .pre-commit.config.yaml and I refuse to do that. It also breaks if the package has any non-R (system) dependencies.....like Stan.
  2. I set up roxygen2 render and code styling to trigger via a button push (workflow_dispatch) and/or a comment with a slash command in the PR. I don't want to do all the re-rendering locally and we have frequent suggested changes to documentation.

As Sam is saying, the auto-commit might be a mistake if the team isn't comfortable with rebasing pulls. I'm currently the only one consistently committing to this project, but will re-evaluate down the road if it becomes an issue.