validate-pyproject icon indicating copy to clipboard operation
validate-pyproject copied to clipboard

GitHub Action for project

Open gtkacz opened this issue 9 months ago • 4 comments

Hey there! Would you guys mind if I turned this package into a GitHub Action? It might be useful for open-source projects where the maintainers don't trust that the contributors are running pre-commit hooks.

gtkacz avatar Mar 15 '25 16:03 gtkacz

Hi @gtkacz, you should be able to easily run validata-pyproject in GHA via CLI:

- run: pipx run 'validate-pyproject[all]' pyproject.toml

(pipx is available without need to installing at least on Linux and Windows workers, and except from specific versions, on macOS too)

You can also use different flavours like validate-pyproject[all,store] to include validations from SchemaStore via validate-pyproject-schema-store. You should also be able to pass versions pipx run 'validate-pyproject[all]>0.15' pyproject.toml.

Should we add this to the README?

(An alternative is to run pre-commit itself in the CI for all files. That would be similar to what we do in this repo)

abravalheri avatar Mar 17 '25 10:03 abravalheri

Adding an action would be pretty trivial, and the benefit is that dependabot could update it. Though I think that would be more important for validate-pyproject-schema-store, so I could add it there. (repo-review and sp-repo-review have a similar relationship, and both do also provide actions, see https://github.com/scientific-python/repo-review/blob/main/action.yml for example.

By the way, pre-commit has an action, which is what I use, I don't use the individual actions. pre-commit has the benefit of being able to be run locally too, which the action doesn't have.

PS: pipx is on all versions, it was only missing for about a week IIRC.\

PPS: The guide here is very useful to see other great pre-commit hooks that I couldn't live without: https://learn.scientific-python.org/development/guides/style/

henryiii avatar Mar 17 '25 13:03 henryiii

@abravalheri thanks for the response! I think I'll do that using pipx.

Should we add this to the README?

Yup I think that'd be really useful, this way FOSS repositories can make sure their pyproject.toml is always valid, given pre-commit can be bypassed if a dev wants to.

An alternative is to run pre-commit itself in the CI for all files. That would be similar to what we do in this repo

FYI, the pre-commit team has a CI tool that checks if commits pass all pre-commit hooks and runs autoupdate on them periodically (CC: @henryiii)

gtkacz avatar Mar 17 '25 15:03 gtkacz

I do use pre-commit.ci on most of my repos :).

henryiii avatar Mar 17 '25 15:03 henryiii