-
Notifications
You must be signed in to change notification settings - Fork 19
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
Proposal: GitHub Actions Workflow & Unix-style Piping Support #30
Comments
Hello @0bCdian thank you for the kinds words :) Lets start addressing your proposals: First proposal
This is something i 100% want to do, albeit it seems simple at first there is a reason why i haven't yet implemented that. Under the hood it uses I was waiting to release In conclusion for the first proposalThis is very complex and i think its best to tackle it myself since it involves big decisions (removing/changing libs) Second proposal
You must be reading my mind because this is also something i also want in the project.
1) First issueInstead of using Take a look at this "bug" from a few months ago here. Gowall has a feature where it can convert all files under a path. To do that it uses the
In that example the shell for some reason intercepted the Building blocksSince i was preparing to create this feature eventually i have refactored and added some functionality that would help. type ProcessOptions struct {
SaveToFile bool // Whether to save the processed image to file
OutputExt string // Optional output extension to override the original
OutputName string // Optional outputName
}
func ProcessImg(imgPath string, processor ImageProcessor, theme string, opts ...ProcessOptions) (string, *image.Image, error) { ... } The In conclusion for the second proposalYou can start by forking and playing around with it, but we must clarify the implementation before we run into issues. |
Thanks for taking the time to read through the proposal! And of course, I will let you know in advance of any progress and or / changes that I implement on my side, I'm 100% on board with having a clear communication channel so we can implement these features as smoothly as possible. We can use this issue for that, or any other channel you prefer. Having said that I have a few things to comment:
Excuse me if it sounds silly, but have you tried as a temporary workaround dockerizing the build process and using volumes to output the binary? I have used this technique before for other use cases and it works great. I have yet to test this approach but I can try it on my side and report the results.
Hmmm I have never encountered this issue myself with other tools that use - to signify stdout, but I guess it depends on the shell, I'll have to dig deeper into this. In the worst case, I think we can simply implement a --stdout flag or "simply" not pass anything, but it would require reworking the current implementation, changing from the output being implicit to a specific predefined directory to the more common approach of being explicit about the output with an -o or --output flag. Of course, I still need to dig deeper into the codebase to make a more informed opinion about the subject, but let me know what you think! |
You could probably get this working as long as you followed this. But i'm a bit confused on how to integrate that with goreleaser github action, not having a lot of experience with CI/CD in general. What i want to it just throw out the old webp lib and replace it with this pure go webp encoder and just use the goreleaser github action and automate everything.
Me either, its really strange and obscure. Can you point some of these tools out so i can see how they implement this? I dont really think its a major cause of concern though.
I think im going to rule out the |
I will toy around with it and if I'm successful I'll report back with a draft and explain the process. I'm quite familiar with ci/cd so it is not a problem for me to get my hands dirty with this issue. Btw, which platforms would you like to target? Also here are some tools that I use regularly that use the - to signify stdin or stdout |
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm64 which are the default of goreleaser essentially
Thank you for the help :) |
Hey! I've come to report good news, after some failed attempts and a lot of reading I have successfully built the binary for all the targets you needed: https://github.com/0bCdian/gowall/actions/runs/13325955334 The workflow is not yet complete, I would have to make now the actual part that pushes the binaries to the latest release. But that part is trivial. I used zig cc to cross-compile the webp library to the desired targets since CGO was not working in Linux and Windows for arm64. sources: |
I can get the whole working workflow done by today late evening (I'm kinda busy today) and make a pr if you give the green light. |
That was where i was hitting a wall in the past. Pretty smart to use Zig, did not think about that. As for the workflow i will use it to generate the binaries and put them in the v0.2.0 release. I noticed also that it took 7mins for this workflow to complete. I have decided to just change the webp lib completely so there is no need to continue this workflow, the lib still causes problems and i want it out. Plus it will cut the workflow time by a lot with the new replacement. But this workflow is very useful for the big feature of the next release OCR. Im 100% using a lib with CGO in it so if normal compilation does not work this zig cross compilation will be the saviour. Thanks so much couldn't have figured that out by myself. You can start on the pipe support whenever you want :) |
There are some rough edges and things I can improve in the workflow, but I wanted to get out of the way compilation part first before doing the whole thing. I'll start digging into the code base and research to make some drafts and proposed changes for the stdin/out stuff. If you need any help with the workflow or anything else I'm glad to help! |
No worries and above all no pressure, take your time and only work on it when you feel like it, it's not anything urgent by any means. |
Added progress indicators to the proposal and finished the GitHub Actions Workflow for Automated Binary Releases part in 02999f7. When a commit with a tag gets pushed it will trigger the workflow and build the binaries for the package. |
I'm sorry I still haven't made progress with the other proposal, I have been busy lately with my job search / personal stuff, but this weekend I'll have more time to sit down and code. |
@0bCdian You don't have anything to apologize for man don't worry, A job search is much more important than contributing to an open source project, as i said before only contribute only when you have time and you enjoy doing it. Focus on that job hunting, i know its a pain to get a job in this market in Europe and i myself will have to start looking for some internships soon when my semester ends. All the best in your future endeavors. |
@Achno Thanks for understanding man, I appreciate it. I'll try to have some draft done by Sunday tops. |
Hi @Achno, I'm passing by to let you know how it's going. I'm still in the discovery phase and investigating popular CLI tools to see what decisions they made when dealing with streams and pipes. Just as a first draft or proposal, we can do the following: In regards to receiving data via stdin we could have two approaches:
In summary, we always read from stdin if no filename is passed directly, and
I personally vote for 1 as it's more neat and compact, and it's in the style of many popular tools, but if you think it's too risky, we can go the other route, adding verbosity for explicitness and potentially a more robust approach, but I honestly don't think we are gaining anything with 2), many popular cli tools have been using style 1) with no issues for years, so I don't see why we could bump into such issues. Hierarchy of behavior:
So if we do something like: cat someimage.png | gowall convert anotherImage.webp anotherImage.webp takes precedence over the stdin stream file, and the file is output to the configured by default or whatever the user put in their config file. Another example: cat someimage.png | gowall convert anotherImage.webp - #style1
cat someimage.png | gowall convert anotherImage.webp --stdout #style2 anotherImage.webp still takes precedence over the stdin stream file, but the output destination in the configuration file is overriden in favor of stdout. |
Hey @0bCdian Okay so lets go with this like cat image.jpg | magick - -r 200% - #Imagemagick First cat image.jpg| gowall invert - - | gowall convert - -t catppuccin First in this gowall invert img.png - | gowall convert - -t catppuccin The first Try to not touch the |
Perfect! I'll start playing with my local version. Btw I see you didn't mention the case where no file input is given, so an implied stdin input:
This would take whatever is in the stdin and output it to the default directory/the one specified in the config file. You don't like implicitly consuming from stdin or just forgot to add it in your comment? In unrelated news, I have my second interview in a few days for a DevOps position 😁! |
Yea i don't want this , the user must explicitly use
Good job man, you got this! Personally since im still in my 3rd year out of 5 years in Uni, i still haven't yet decided what exactly i want to be but i'm studying kubernetes and a lot of networking just for fun and to build a good homelab :) |
Hi! I've been checking out this project while learning Go, and I think it's awesome! I want to contribute with a couple of features that could make it even more flexible and easier to use.
Proposed Contributions
1. GitHub Actions Workflow for Automated Binary Releases
I’d like to set up a GitHub Actions workflow to compile binaries for different platforms and attach them to the releases page automatically. This way, users can just grab a prebuilt binary instead of having to build from source.
Why?
2. Support for Unix-style Piping (stdin/stdout Processing)
It would be super useful if the tool could read images from
stdin
and write tostdout
, making it possible to compose commands in a pipeline like traditional Unix tools.Example Use Case:
Why?
Implementation Approach
os.Stdin
when-
is passed as a filename.os.Stdout
if no output file is specified.I think these changes would make the project a lot more powerful, especially for those who love scripting and automation. Let me know what you think—I’d love to get started on this!
The text was updated successfully, but these errors were encountered: