CI: Ensure no hyphens in Python file and directory names in the "Style Checks" workflow #3703
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've documented that underscores, not hyphens, should be used in Python file and directory names, but we don't have a way to enforce it.
This PR adds a check in the "Style Checks" workflow, so the workflow will fail if there are violations. The following two commands list all Python files and directories.
and then we can use
grep "-"
to check hyphens.grep "-"
exits with 0 if hyphens are found and 1 if unfound, which makes GitHub Actions step fail. So we need to add|| true
so that the commands always exit with 0.The related entry in the pull request template is removed so keep the template simple.
In 5879833, one file and directory with hyphens are added to test the workflow. The workflow fails as expected (https://github.com/GenericMappingTools/pygmt/actions/runs/12431105443/job/34707863816?pr=3703).