-
-
Notifications
You must be signed in to change notification settings - Fork 81
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 hook #565
base: main
Are you sure you want to change the base?
Add pre-commit hook #565
Conversation
65784e2
to
05b36fe
Compare
@@ -0,0 +1,15 @@ | |||
- id: selene-system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust-based pre-commit does not work because pre-commit hardcodes the --path
to .
(source) which leads to build failure with error: found a virtual manifest at <path>/Cargo.toml instead of a package manifest
.
Pre-commit maintainer disagrees with making --path
configurable so it is not possible to add a rust based hook: pre-commit/pre-commit#2931 unless we somehow make it possible to install the binary from root level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to point entry
to a custom install script. But we'd need to handle the caching, unless we distribute the executable directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure if we wanted a custom install script just for the pre-commit use case. I can add it if that's something we are okay with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would depend on how it would look like. Caching binaries by version may not be trivial and we don't get the same advantages language: rust
gets, which makes me think it's likely not worth the effort to support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. That's why went ahead with only setting up system
and docker
workflows. Is there some trivial way to make this work by may be a configuration change at our end? I did some preliminary research but did not find much (but then I have not worked with rust
ever before).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at how StyLua handles the pre-commit hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their rust
workflow works because they do not use workspaces.
The python
workflow seems interesting. We can integrate it, but it would depend on a python package (https://pypi.org/project/release-gitter/) to do the release download for us. If that is something we are okay with, I can add it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added GitHub release based pre-commit hook in 5f1a755
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need changelog
@@ -0,0 +1,15 @@ | |||
- id: selene-system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible to point entry
to a custom install script. But we'd need to handle the caching, unless we distribute the executable directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like pre-commit builds docker with docker build .
, which causes the light build to be used. This isn't compatible with roblox projects. It also doesn't seem like pre-commit supports changing the build command, so a rather hacky workaround could be to move the selene-musl
build to the last in the dockerfile.
Head branch was pushed to by a user without write access
8cd3099
to
5f1a755
Compare
@chriscerie @jenstroeger Let me know if there's something else needed from my end to get this through. |
I’m currently ooo, I’ll take a look at the changes within the next week or so. |
@amitds1997 Are you able to upload the builds under your fork's release? I think that's needed to test selene-github. |
I was able to test it out with this: - repo: https://github.com/amitds1997/selene
rev: d895ab518a9a3fd6e8efe1716fde501dd29fe8ba # The latest commit on the PR branch
hooks:
- id: selene-github Did not face any issues. The reason I think this should work is that it looks for releases under Kampfkarren/selene's releases (see amitds1997/selene/pyproject.toml#L6). Are you seeing any particular error? |
It works when I have a local copy of selene, but it's breaking when it's not installed:
You're right about it using git-url to get the upstream repo. Perhaps where it's breaking is it's missing |
Hello. I just started looking into Selene and noticed that this is kind of waiting on me! Sorry about that. I just pushed a new version that should resolve this issue and allow the GitHub install hook to properly download. |
b537deb
to
93b27be
Compare
@chriscerie @jenstroeger With the latest release to release-gitter (thanks @IamTheFij), we have a working solution for pip-based pre-commit installation. With this, we should have pre-commit support using local exec, docker and pip (python). Let me know if anything else would be needed from my end. |
pyproject.toml
Outdated
[tool.release-gitter.map-system] | ||
Darwin = "macos" | ||
Windows = "windows" | ||
Linux = "linux" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should no longer be needed. This was common enough that I added it as default values. That said, there is no harm in leaving them.
https://github.com/IamTheFij/release-gitter/blob/main/release_gitter.py#L51
SYSTEM_SYNONYMS: list[list[str]] = [
["Darwin", "darwin", "MacOS", "macos", "macOS"],
["Windows", "windows", "win", "win32", "win64"],
["Linux", "linux"],
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the input! Removed this in the latest commit (391b18d).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Fixes #539
Rust-based pre-commit does not work because pre-commit hardcodes the
--path
to.
which leads to build failure and errors withfound a virtual manifest at <path>/Cargo.toml
instead of a package manifest. Pre-commit maintainer disagrees with making this configurable so it is not possible to add arust
based hook: pre-commit/pre-commit#2931