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

fix: Skip no-commit-to-branch hook in CI #207

Closed
wants to merge 2 commits into from
Closed

Conversation

sinopeus
Copy link
Collaborator

@sinopeus sinopeus commented Dec 11, 2023

The no-commit-to-branch hook fails on merge commits on main when using GitHub Actions. That specific hook can be skipped using the SKIP environment variable. We can do that in the poe lint task definition based on whether we are in CI or not. To know that, we can check for the existence of the CI environment variable and if it exists, set SKIP=no-commit-to-branch when running pre-commit.

@sinopeus sinopeus requested a review from lsorber December 11, 2023 09:45
@sinopeus sinopeus self-assigned this Dec 11, 2023
@sinopeus sinopeus force-pushed the xga-fix-ci-lint branch 2 times, most recently from 93255d7 to cf8c408 Compare December 11, 2023 09:54
@sinopeus
Copy link
Collaborator Author

sinopeus commented Dec 11, 2023

I'll add that the way I had to fix this (specifically exposing the CI env variable to the dev container) shows that the approach of using devcontainers/cli for CI has some downsides, like having to explicitly expose environment variables in docker-compose.yml instead of automatically loading the environment variables. This is annoying in CI as there can be environment variables e.g. predefined by the CI platform, defined in an earlier stage of the CI pipeline, ... that you want to use.

@sinopeus
Copy link
Collaborator Author

By the way, the alternative here is simply removing the no-commit-to-branch pre-commit hook altogether and using protected branches on GitHub/GitLab instead. It's definitely a simpler solution 🙂

@lsorber
Copy link
Member

lsorber commented Dec 19, 2023

Thanks for the PR @sinopeus!

I took the liberty of adding a commit with two small changes:

  • Only export CI in strict mode, since we have no need for it in simple mode.
  • Turn the SKIP into a one-liner.

That said, I'm not sure the complexity of the solution is worth the value that the no-commit-to-branch hook brings. I'm actually more inclined to just remove the hook entirely and have this be solved with branch rules as you also suggest.

If you prefer to keep it, we can continue with this PR, but otherwise I'd suggest that we remove it.

@sinopeus
Copy link
Collaborator Author

All right, let's open a new one where we simply remove the no-commit-to-branch hook 🙂

@sinopeus sinopeus closed this Dec 19, 2023
@sinopeus sinopeus deleted the xga-fix-ci-lint branch December 19, 2023 14:09
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