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 pre-commit.ci #83

Merged
merged 3 commits into from
Aug 23, 2024
Merged

Add pre-commit.ci #83

merged 3 commits into from
Aug 23, 2024

Conversation

b-rowan
Copy link
Contributor

@b-rowan b-rowan commented Aug 23, 2024

Adds proper pre-commit handling for PRs, along with pytest being run in a separate github action.

Closes #80

@b-rowan b-rowan force-pushed the dev_pre-commit_ci branch from 87b9aa4 to 179834d Compare August 23, 2024 16:03
Ignore H021 (inline styles), swap to `url_for` where applicable from static links, and update image tags with width, height, and alt attributes.
@tsagadar
Copy link
Collaborator

If I understand it correctly (no deep knowledge if github actions though)

  • pytests would be executed for every PR on GitHub - but no longer as part of pre-commit on the dev machine
  • all linting / formatting checks are only executed as part of pre-commit on the dev machine

Should we not have both activities be executed for every PR on GitHub - in case that the developer is not using pre-commit?

And why not keep pytest as part of pre-commit? The only downside I saw so far is that during a commit the server cannot run in parallel.

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 23, 2024

If I understand it correctly (no deep knowledge if github actions though)

  • pytests would be executed for every PR on GitHub - but no longer as part of pre-commit on the dev machine

  • all linting / formatting checks are only executed as part of pre-commit on the dev machine

Should we not have both activities be executed for every PR on GitHub - in case that the developer is not using pre-commit?

And why not keep pytest as part of pre-commit? The only downside I saw so far is that during a commit the server cannot run in parallel.

This is actually not correct. pytest is only being removed from the pre-commit.ci run, it still gets run locally. It just breaks when being run on the CI server, so I moved it to github actions.

Basically, everything gets executed on every PR push, and can be run locally if pre-commit is installed.

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 23, 2024

Here's a better breakdown of what's actually happening here -

pre-commit.ci - Remote CI server, runs pre-commit and can commit any changes needed (such as formatting fixes) automatically.
- Fails to run pytest, since that uses a locally configured hook.
- Because of this failure, it is disallowed from running the pytest hook.

ci:
skip:
- pytest

GitHub Actions - Local action added to run pytest because it is not being run on pre-commit.ci
https://github.com/UpstreamDataInc/goosebit/blob/d8e6a30cd1cf28980cffa78a8be2f5494388e585/.github/workflows/pr-run-tests.yml

pytest-md-report - Runs as part of the pytest action, it will display a chart of failed tests as a comment if the tests fail.

pre-commit - Locally run pre-commit config. No changes, this works exactly the same as before.

This means that all in all -

  • Local pre-commit has not changed.
  • pytest is run on PRs via an action, and will comment a formatted table with failures when tests fail.
  • pre-commit hooks are run on PR with the exception of pytest, since it would break, and is handled by a separate action because of that. The pre-commit hooks may also make changes to the PR with a commit.

@tsagadar
Copy link
Collaborator

Is it possible that you did not commit pre-commit.ci?

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 23, 2024

Is it possible that you did not commit pre-commit.ci?

It's a website, technically installed as a github app.

https://pre-commit.ci

You can also take a look at the checks for this PR for more info.

@tsagadar
Copy link
Collaborator

tsagadar commented Aug 23, 2024

Alright - now I did understand all the magic that is going on here ;-)

Could have helped to use a different commit message than "Skip pytest in pre-commit.ci" - something like

Activate pre-commit.ci

Use https://pre-commit.ci to run pre-commit checks and automatically fix
detected issues.

Disables pytest in pre-commit.ci because they won't pass.

@tsagadar
Copy link
Collaborator

Just looked at the report as well - love this integration.

@b-rowan
Copy link
Contributor Author

b-rowan commented Aug 23, 2024

Alright - now I did understand all the magic that is going on here ;-)

Could have helped to use a different commit message than "Skip pytest in pre-commit.ci" - something like


Activates pre-commit.ci



Use https://pre-commit.ci to run pre-commit checks and automatically fix

detected issues.



Disable pytest in pre-commit.ci because they won't pass.

Still getting the hang of when to use longer commit messages and for what.

@b-rowan b-rowan merged commit 3b4fde3 into master Aug 23, 2024
2 checks passed
@b-rowan b-rowan deleted the dev_pre-commit_ci branch August 23, 2024 17:23
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.

Introduce GitHub Action to run pre-commit for pull requests
2 participants