Live data from Hacker News

Act: Run your GitHub Actions locally

github.com

11–20 of 161 posts

Re: Act: Run your GitHub Actions locally

#11
post #7

I’ve used this a bunch; I actually don’t know how else you’d write and test a GitHub action. Do people just push them and hope they work and push more commits with “fix” as the message until it works?

yeah i also use other incredibly informative messages like: - oh oops - fix for real this time - will this actually work? - this probably won't fix it - a

Yeah, but with one word messages you can pass it on the command line without quotes:

    git commit . -m fix

Re: Act: Run your GitHub Actions locally

#12
Finally! I've been wanting something like this for ages- generally speaking I don't consider myself an idiot, but I'm forced to pull that into questioning every time I test and debug ci/cd actions with an endless stream of pull request modifications

Re: Act: Run your GitHub Actions locally

#13

I’ve used this a bunch; I actually don’t know how else you’d write and test a GitHub action. Do people just push them and hope they work and push more commits with “fix” as the message until it works?

> Do people just push them and hope they work and push more commits with “fix” as the message until it works?

Unironically yes. It's awful, it's ugly, but it works with no extra setup, effort, or cost (other than feeling dirty for a few minutes).

Re: Act: Run your GitHub Actions locally

#15

Finally! I've been wanting something like this for ages- generally speaking I don't consider myself an idiot, but I'm forced to pull that into questioning every time I test and debug ci/cd actions with an endless stream of pull request modifications

I don't consider myself a cynic (1), but I am forced to pull that into questioning every time I see how many paid worker minutes are wasted by such endless streams of pull request modifications.

(1) Who am I kidding, of course I am a cynic.

Re: Act: Run your GitHub Actions locally

#16

I’ve used this a bunch; I actually don’t know how else you’d write and test a GitHub action. Do people just push them and hope they work and push more commits with “fix” as the message until it works?

I add a workflow like this:

- write the main job in a Python/PowerShell/Bash script that runs locally,

- write a workflow that sets up the environment (AWS login), installs dependencies (using GitHub's facilities for that) and calls the script (often passing values using GitHub Secrets),

- push the workflow with a "push" trigger on a feature branch (for fast testing),

- push 30 fixup commits to fix all the small syntax errors, logic mistakes, and GHA idiosyncrasies I hadn't thought of,

- remove the push trigger,

- do an interactive rebase to squash all the fixups,

- force-push and merge.

It works pretty well and can be easily used locally or in other CI/CD systems.

Re: Act: Run your GitHub Actions locally

#17

I’ve used this a bunch; I actually don’t know how else you’d write and test a GitHub action. Do people just push them and hope they work and push more commits with “fix” as the message until it works?

  git add […] && EDITOR=true git commit --amend && git push -f […]
(You don't have to open a PR / the usual history rewriting consequences don't apply if you're just pushing to Actions to see how it reacts.)

But alternatively, if you find yourself doing this a lot and it's really the code of the step that you're debugging (vs. debugging how the workflow interacts with Actions itself) I try to keep my jobs' steps pretty simple:

  - run: ci/thing.sh
… specifically so that I can run the step locally. It's usually much faster. (And on a MBP, doesn't incur the costs of virtualization, at the cost of needing to port to macOS. Usually worth it.)

Re: Act: Run your GitHub Actions locally

#18

Finally! I've been wanting something like this for ages- generally speaking I don't consider myself an idiot, but I'm forced to pull that into questioning every time I test and debug ci/cd actions with an endless stream of pull request modifications

Unfortunately act is only capable of running very simple workflows. I've found this action to be more useful against the endless PR stream: https://github.com/mxschmitt/action-tmate

You drop it in your workflow and get an SSH shell into the worker, figure things out iteratively, then push when it's working.

Re: Act: Run your GitHub Actions locally

#19
I use this a lot. It's not perfect, but better than nothing. For example, last time I checked it did not support reusable workflows, and I have had a few cases I got some error from github but act worked. I guess it's a hard catchup game, not only do you have to get the semantic for correct workflows correctly, you also want to error out on the same errors.

I really don't understand why github don't release a local runner for github actions. Everyone I know which has worked with cicd wants the same, some way to run and debug the pipelines/workflows locally.

Re: Act: Run your GitHub Actions locally

#20

Finally! I've been wanting something like this for ages- generally speaking I don't consider myself an idiot, but I'm forced to pull that into questioning every time I test and debug ci/cd actions with an endless stream of pull request modifications

I normally create a draft PR first to test CI/CD changes and open a new one when it's working. The workflow still sucks but I at least look like less of an idiot in the eyes of my peers.
Post reply on HN