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

Support more assets formats (lefthook) #72

Closed
meruiden opened this issue Aug 26, 2024 · 8 comments · Fixed by #73
Closed

Support more assets formats (lefthook) #72

meruiden opened this issue Aug 26, 2024 · 8 comments · Fixed by #73
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@meruiden
Copy link
Contributor

meruiden commented Aug 26, 2024

I'm trying to install lefthook for better pre-commit hook support, but rokit cant properly identify the right asset, but there are definitely assets that feel like they should be compatible:

https://github.com/evilmartians/lefthook/releases/tag/v1.7.14

> rokit add evilmartians/lefthook
ERROR Failed to extract contents for evilmartians/lefthook@1.7.14

Caused by:
    failed to extract artifact: unknown format

(I'm on windows)

@meruiden
Copy link
Contributor Author

meruiden commented Aug 26, 2024

The problem seems to be that lefthook has both the raw executable unzipped, and as .gz zip. and Rokit seems to think the raw unzipped asset is the best option, but then it can't extract it because its not compressed. So either, Rokit should prioritize/sort on compressed file formats, zip, gz, tar gz, or it should support downloading executables from assets that aren't compressed. + it seems rokit doesn't support .gz, only tgz and tar.gz.

@meruiden
Copy link
Contributor Author

Some background:
It would be awesome to support lefthook in the Roblox development workflow because it allows for easy pre-commit hooks for tools like selene and stylua without needing NPM for husky or pyhton for pre-commit[dot]com. Lefthook is a CLI tool without dependencies making it a great fit for the aftman/rokit style workflow for Rojo projects.

This is a great Lefthook config for a more professional workflow in Rojo:

lefthook.yml

pre-commit:
  commands:
    selene:
      glob: "*.{lua}"
      run: selene {staged_files}
    stylua:
      glob: "*.{lua}"
      run: stylua {staged_files}
      stage_fixed: true

@rojo-rbx rojo-rbx deleted a comment Aug 26, 2024
@filiptibell filiptibell added the bug Something isn't working label Aug 26, 2024
@filiptibell
Copy link
Collaborator

Looks like this mostly falls under #4 , however, looking at that release, it definitely seems like it should be grabbing one of the compatible (compressed) artifacts, and not trying to use one that Rokit doesn't know how to handle. Seems like a bug to me.

@meruiden
Copy link
Contributor Author

I cloned it, and from debugging, I can tell it tries to download https://api.github.com/repos/evilmartians/lefthook/releases/assets/186574661, which goes well, but then with extracting, it goes wrong. seems like it doesn't handle .gz files properly yet. Any chance you can have a look?

It fails here:

let format = self.format.ok_or(ExtractError::UnknownFormat)?;

@filiptibell
Copy link
Collaborator

I cloned it, and from debugging, I can tell it tries to download https://api.github.com/repos/evilmartians/lefthook/releases/assets/186574661, which goes well, but then with extracting, it goes wrong. seems like it doesn't handle .gz files properly yet. Any chance you can have a look?

It fails here:

let format = self.format.ok_or(ExtractError::UnknownFormat)?;

Ah, I missed that those .gz assets are actually bare executables (meaning, not inside of any container like zip, tar) but still compressed. This is a bit strange but something I want to support with Rokit either way. There is some ongoing work to support this in #66 .

@filiptibell filiptibell added duplicate This issue or pull request already exists enhancement New feature or request and removed bug Something isn't working labels Aug 27, 2024
@meruiden
Copy link
Contributor Author

yeah its a bit in between. a .gz file, is a zip/tar.gz file with a single file in it. but thats not what #66 implements. Although in lefthooks case, it ALSO has bare/raw exectuable files as artifacts. for every os/arch it has 2 artifacts, a raw executable, which is implemented in #66, and also a .gz file, which is simply the same format as the other compressed formats, .zip,.tar.gz etc.

image

https://github.com/evilmartians/lefthook/releases/download/v1.7.14/lefthook_1.7.14_Windows_x86_64.exe
and
https://github.com/evilmartians/lefthook/releases/download/v1.7.14/lefthook_1.7.14_Windows_x86_64.gz

are 2 of the same artifacts from lefthook with different filetypes. 1 raw and 1 zipped.

@meruiden
Copy link
Contributor Author

Another unrelated bug I found, is if you add a tool, using rokit add ... and it fails to extract the asset, like with lefthook right now, it still keeps it in rokit.toml and thus leaves it in a broken state. I feel like it should only update the toml file if an add/install is successful

@meruiden
Copy link
Contributor Author

I kinda need the feature so I made a PR #73 . would be awesome if you could review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@meruiden @filiptibell and others