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 Python Code Style Enforcement to GitHub Actions #272

Merged
merged 3 commits into from
Oct 13, 2023

Conversation

komish
Copy link
Contributor

@komish komish commented Oct 12, 2023

This PR adds a:

  1. A Makefile within the scripts/ directory for use in enforcing style and managing virtualenvs
  2. a GitHub Actions that consumes the Makefile targets to enforce style guidelines for changes to tooling within the scripts/ directory
  3. An expanded .gitignore to remove a lot of cruft that gets added to the filesystem when building/installing various CI tools.

Style

We've previously applied Black to the code in this repository, and fixed a few pep8 complaints. This just takes that a bit further and starts to enforce it on PRs.

Linting is currently configured to auto-pass because we have a lot of things that are not automatically fixable (namely import positioning and line length). The idea here is that, when so motivated, we can review the CI results against the repository and go about fixing them as we go along (vs. requiring an immediate fix to all the line length complaints today).

ruff is used as the linter here simply due to its speed promises. If we have issues with it, we can eventually migrate to something else.

Makefile

I make heavy use of venvs for python-related things. I'm less familiar with newer tooling thats in the same problem space. To that end, I've added Make targets that simply help facilitate the management and installation of virtualenvs. One target venv.codestyle is used for style tooling (black, ruff), the other venv.tools is used for our scripts themselves.

For development, there are additional "subtargets" that let you always reinstall these venvs, for cases where you're making changes to scripts and want to call them using the installed executables. E.g. venv.tools.always-reinstall.

gitignore

Just adds various paths. This is borrowed from a partial of the GitHub Python default gitignore that's scaffolded for new projects.

@komish komish requested review from mgoerens and jsm84 October 12, 2023 19:58
… on src files

Signed-off-by: Jose R. Gonzalez <komish@flutes.dev>
Signed-off-by: Jose R. Gonzalez <komish@flutes.dev>
This was referenced Oct 12, 2023
Signed-off-by: Jose R. Gonzalez <komish@flutes.dev>
This was referenced Oct 12, 2023
@komish komish requested a review from OchiengEd October 12, 2023 21:10
This was referenced Oct 12, 2023
Copy link
Contributor

@OchiengEd OchiengEd left a comment

Choose a reason for hiding this comment

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

/lgtm

scripts/Makefile Show resolved Hide resolved
@komish komish merged commit 7ae469f into openshift-helm-charts:main Oct 13, 2023
5 checks passed
@komish komish deleted the py-codestyle-tooling branch February 1, 2024 18:06
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