Skip to content

Add workflows and adjust configuration#8

Merged
jdw-creare merged 3 commits intodevelopfrom
feature/ci_unit_test
May 28, 2025
Merged

Add workflows and adjust configuration#8
jdw-creare merged 3 commits intodevelopfrom
feature/ci_unit_test

Conversation

@scranford1
Copy link
Copy Markdown

No description provided.

@scranford1 scranford1 requested a review from jdw-creare May 23, 2025 17:50
@scranford1 scranford1 self-assigned this May 23, 2025
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For my own curiosity more than anything else - what does this file affect? Does it create a pre-commit hook for commits that are done through the GitHub site, or is it something that's meant to take effect on developer machines?

Copy link
Copy Markdown
Contributor

@mpu-creare mpu-creare May 28, 2025

Choose a reason for hiding this comment

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

It's supposed to take effect on the developer's machine. This prevents you from committing code that hasn't been formatted using Black. Unfortunately, there have been cases where developers do not properly install this precommit hook, and so unformatted text does show up in the repo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting - how does one install that hook? I don't see any directions in the readme, and git commands usually don't take yaml files, is there a tool we're supposed to use?

We could also flip a switch now, to make Black formatting mandatory for pull requests to be accepted: line 35

I'm personally not a fan of pre-commit hooks for a couple reasons:

  • I think the point where formatting matters is merge time. I personally like being able to commit stuff that doesn't meet any quality bar, as long as it's not on the develop or main branch, because it lets me use git as a simple backup mechanism. Developers can commit something that doesn't even have correct syntax, just to have a checkpoint at the end of the workday or whatever.
  • It requires a manual action by every developer on every checkout - they have to know to install the pre-commit hook. In contrast, if we lean on CI checks, it's all automated and nobody has to remember anything.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The hook "used" to get automatically installed with setup.py. See here: https://github.com/creare-com/ogc/blob/main/setup.py#L66C7-L66C25 and here: https://github.com/creare-com/ogc/blob/main/setup.py#L102

With Python's move to a pyproject.toml file, I'm not sure how this works anymore.

The main advantages of this approach is that the automatic formatting makes the total codebase smaller, and you don't have to look at all the changes to to formatting when you're reviewing a merge request. In theory it's also automatic with no effort on the developer's part... in practice the hook seems to misbehave. Personally, I'm a fan of doing both the CI check and the hook.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally, I'm a fan of doing both the CI check and the hook.

I can totally get behind that! Seems like one of those situations where the redundancy is helpful.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Setup.py still gets called with pyproject.toml present. However our PostDevelopCommand does not. In order to get the pre commit install you now need to run python setup.py develop directly. I can add a note on this or come up with a workaround.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we provide a setup.sh file in our python project template to install precommit hooks now... that was the best workaround we came up with.

Copy link
Copy Markdown
Contributor

@jdw-creare jdw-creare left a comment

Choose a reason for hiding this comment

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

This looks great!

As additional work in the future, it would be really cool to get SonarQube to ingest the coverage report from pytest. I got it working in our GitLab setup, but I am not sure how we're meant to hook that into the free cloud version of SonarQube.

I'm gonna merge in this pull request for now though - I think that would be work for a future PR!

@jdw-creare jdw-creare merged commit aad1db1 into develop May 28, 2025
3 checks passed
@scranford1 scranford1 deleted the feature/ci_unit_test branch June 5, 2025 13:52
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.

3 participants