Live data from Hacker News

Act: Run your GitHub Actions locally

github.com

91–100 of 161 posts

Re: Act: Run your GitHub Actions locally

#91

Earlier quoted context omitted.

> Running things in parallel is literally a single `&` character. Yes now try waiting for all parallel tasks, and error out if at least one errors. And try separating their output so that they don't get interleaved into a big mess. And try by default hiding the outputs of commands that succeeded, only showing those that failed, except when the user explicitly asks for it. Your "simple" shell script now suddenly isn't…

Using GNU make you can get very nice output sync: all: variant-1 variant-2 @echo done with all variant-%: @echo starting $@ @sleep 1 @echo done $@ Use `make -j2 --output-sync=target`.

    brew install make
    gmake -j2 --output-sync=target
on macOS.

Re: Act: Run your GitHub Actions locally

#92
I NEED this RIGHT NOW - awesome and thank you so much to the submitter! I'm writing my first action and there are so many facets to interacting with the runtime environment that I was testing by pushing updates. Checking my commits, I see that I committed and pushed 19 times this morning and most of them could have been avoided using act. I should also note that my Action is a bit odd since it has the local (to Docker) checkout and then calls back to the GitHub GraphQL API to make changes.

Re: Act: Run your GitHub Actions locally

#93
post #88

Rather than replacing your Makefile with GH Actions, replace your GH Actions with a Makefile, and make your GH Actions run `make` in a script task. Do you really need that GH Action for pulling Docker images / installing $language_compiler / creating cloud resources ? A `docker` / `curl` / `sudo apt-get install` invocation in a Makefile / script needs to be written once and is the same in CI as on your dev machines.…

This is what I do except I use a shell script instead of a Makefile. A working example of this is at: https://github.com/nickjj/docker-flask-example/blob/912388f3... Those ./run ci:XXX commands are in: https://github.com/nickjj/docker-flask-example/blob/912388f3... I like it because if CI ever happens to be down I can still run that shell script locally.

You should still have a Makefile that calls your shell scripts when "make" or "make test" is run. Every person who writes shell scripts has a different filename and arguments. "make" and "make test" are always the same everywhere.

Re: Act: Run your GitHub Actions locally

#94
We have used this many times during GitHub outages. It's great and does what it says.

But just one word of warning: when you run `act` with no arguments, what does it do? Displays usage? Nope -- it runs all workflows defined in the repo, all at once in parallel!

This seems like a crazy default to me. I've never wanted to do anything remotely like that, so it just seems both dangerous and inconvenient all at once.

Nice otherwise though...

Re: Act: Run your GitHub Actions locally

#95

Rather than replacing your Makefile with GH Actions, replace your GH Actions with a Makefile, and make your GH Actions run `make` in a script task. Do you really need that GH Action for pulling Docker images / installing $language_compiler / creating cloud resources ? A `docker` / `curl` / `sudo apt-get install` invocation in a Makefile / script needs to be written once and is the same in CI as on your dev machines.…

> installing $language_compiler

Yes, because proper use of the tool cache (and other caches) significantly speed up GitHub Actions builds.

Look, I'm all for putting logic in Makefiles instead of in YAML. But not at the expense of slower (and therefore more expensive) builds!

Re: Act: Run your GitHub Actions locally

#96

Rather than replacing your Makefile with GH Actions, replace your GH Actions with a Makefile, and make your GH Actions run `make` in a script task. Do you really need that GH Action for pulling Docker images / installing $language_compiler / creating cloud resources ? A `docker` / `curl` / `sudo apt-get install` invocation in a Makefile / script needs to be written once and is the same in CI as on your dev machines.…

[deleted]

Re: Act: Run your GitHub Actions locally

#97
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

I just commit --amend and the push -f to not waste brainpower on messages.

Re: Act: Run your GitHub Actions locally

#98
post #31
post #23

Earlier quoted context omitted.

I'd love to. Do you have anything more specific in mind?

Generally speaking: have one syntax/pipeline that works on GitHub, Gitlab, etc I think the big problem would be the marketplace, you need to implement your own or make it compatible with the GitHub one

This is already entirely doable: just create some executable "test" program in $language_of_choice (shell script, Python, compiled C binary if you really want to) and run that in the CI. You're still going to have to need a wee bit of CI configuration (usually YAML) to tell it which containers to run and whatnot, but this usually isn't all that much.

Re: Act: Run your GitHub Actions locally

#99

Rather than replacing your Makefile with GH Actions, replace your GH Actions with a Makefile, and make your GH Actions run `make` in a script task. Do you really need that GH Action for pulling Docker images / installing $language_compiler / creating cloud resources ? A `docker` / `curl` / `sudo apt-get install` invocation in a Makefile / script needs to be written once and is the same in CI as on your dev machines.…

Strongly concur. I'll concede some cons:

* GNU make is sometimes unavailable

* syntax is an acquired taste

* not everything fits in a rule body

Imho, these are far outweighed by the flexibility, portability, and "least surprise" convention embodied in a Makefile.

Re: Act: Run your GitHub Actions locally

#100
post #63
post #49

Earlier quoted context omitted.

This is a lesson that I've learned after going all-out on actions once. Now my makefiles in addition to the usual "make" and "make test" also support "make prerequisites" to prepare a build environment by installing everything necessary and "make ci" to run everything that CI should check. With actual implementation being scripts placed under "scripts/ci". The scripts do provide some goodies when they are run by GitH…

What about caching to reduce ci time? GH setup scripts cache dependencies in a way that would seem hard to replicate in a make file.

GH setup scripts cache dependencies in a way that is hard to replicate --- full stop.
Post reply on HN