News for hackers. Stuff that matters.
Re:GitHub Actions Are a Problem by simonw on Sunday November 12, 2023 @10:13AM (#38240759)
If you want the ability to run as much of your GitHub Actions locally as possible (which you should! Testing via pushing commits is painful) you can arrange your actions so the majority of the logic lives in shell scripts (or Python scripts or whatever) that are called by the workflow.

Then you can run those scripts locally and iterate in them before you try them on GitHub Actions.

I agree: Actions would be more useful if I could run the entire stack locally (an official implementation, not a community-maintained clone). But it's not a big enough inconvenience for me to care very much.

Re:GitHub Actions Are a Problem by simcop2387 on Sunday November 12, 2023 @10:41AM (#38241093)
Isn't that exactly what the self hosted runners are?

https://docs.github.com/en/actions/hosting-your-own-runners/...

Then you configure the repo settings to only use the self hosted ones.

Re:GitHub Actions Are a Problem by jahsome on Sunday November 12, 2023 @10:50AM (#38241196)
If you're suggesting the self-hosted runners are equivalent to running locally, then no, self-hosted runners still require a commit + push and runs remotely with the added overhead of the job being queued, reported, etc.

The dream is to have something like a container _locally_ and be able to run something like:

    > gh actions run
Re:GitHub Actions Are a Problem by mplewis on Sunday November 12, 2023 @10:31AM (#38240997)
Incidentally, this is sort of how the Earthly runner serves to provide you local actions that also work in CI.
Re:GitHub Actions Are a Problem by dinkleberg on Sunday November 12, 2023 @10:47AM (#38241155)
This is the way. It also lets you pretty much seamlessly switch CI tools at any time.
Re:GitHub Actions Are a Problem by jahnu on Sunday November 12, 2023 @10:52AM (#38241224)
I third this opinion: another reason it’s important is it allows you to do your build in an emergency when CI is down for whatever reason.

CI automation is for me the thing that replaces me running scripts one by one (and reporting/deploying results)

It is not the thing that does the building/testing/deploying. That’s the scripts that are hopefully written in a debuggable, portable, language.

Re:GitHub Actions Are a Problem by simonw on Sunday November 12, 2023 @10:56AM (#38241250)
This is a really good point. Most of my deploys go via GitHub Actions these days and it's not easy for me to deploy manually should I need to when Actions is unavailable - I should fix that!
Re:GitHub Actions Are a Problem by jahnu on Sunday November 12, 2023 @11:05AM (#38241347)
Like aviation, every regulation/rule is written in blood ;)
Re:GitHub Actions Are a Problem by leetrout on Sunday November 12, 2023 @11:24AM (#38241547)
This is why the three of us should record a podcast episode talking about this in the context of the points made in the Ironies of Automation

https://en.wikipedia.org/wiki/Ironies_of_Automation

Re:GitHub Actions Are a Problem by jamesfinlayson on Sunday November 12, 2023 @07:39PM (#38245632)
Agreed - I had to switch from TeamCity to GitLab earlier this year and I was very glad that all of pipelines were single-line calls to shell scripts.
Re:GitHub Actions Are a Problem by jasonm23 on Sunday November 12, 2023 @10:25PM (#38246529)
Indeed, to rely on third party actions in a closed runner ecosystem, is simply unwise.
Re:GitHub Actions Are a Problem by notnmeyer on Sunday November 12, 2023 @10:54AM (#38241230)
yes! what we did was use a task runner to encapsulate the work in a “ci” task. you can run it locally, and then the GHA runner does little more than clone, install a couple depa and run the task.
Re:GitHub Actions Are a Problem by remram on Sunday November 12, 2023 @10:56AM (#38241249)
The problem is that GitHub Action offers a large ecosystem of reusable actions that you can't easily call from a script.
Re:GitHub Actions Are a Problem by simonw on Sunday November 12, 2023 @11:06AM (#38241354)
I mainly ignore those - I stick to the actions that install things (setup-python) and run scripts.
Re:GitHub Actions Are a Problem by remram on Sunday November 12, 2023 @11:09AM (#38241398)
You can get around the setup ones by using Docker images (e.g. run in python:3.11 rather than using setup-python).
Re:GitHub Actions Are a Problem by ddorian43 on Sunday November 12, 2023 @02:55PM (#38243538)
Can you provide a link to an example?
Re:GitHub Actions Are a Problem by remram on Sunday November 12, 2023 @09:22PM (#38246175)
The docs have examples: https://docs.github.com/en/actions/using-jobs/running-jobs-i...

Basically you set `container.image`.

Re:GitHub Actions Are a Problem by xeromal on Sunday November 12, 2023 @11:02AM (#38241320)
You, you sacrifice that convenience for something purely in shell that is more portable.
Re:GitHub Actions Are a Problem by remram on Sunday November 12, 2023 @11:10AM (#38241404)
you you?
Re:GitHub Actions Are a Problem by xeromal on Sunday November 12, 2023 @11:44AM (#38241766)
It's like a yo-yo but faster
Re:GitHub Actions Are a Problem by philipswood on Sunday November 12, 2023 @01:47PM (#38242971)
Like yo-yo, but slower due to the extra W.
Re:GitHub Actions Are a Problem by slenk on Sunday November 12, 2023 @05:44PM (#38244891)
You should check out: https://github.com/nektos/act

Works pretty well for the actions I have used it on.

Re:GitHub Actions Are a Problem by jasonm23 on Sunday November 12, 2023 @10:24PM (#38246526)
That's not a problem. You just don't use them if you don't want to suffer vendor lock.
Re:GitHub Actions Are a Problem by rewmie on Monday November 13, 2023 @02:42AM (#38247918)
> That's not a problem. You just don't use them if you don't want to suffer vendor lock.

How do you use GitHub Actions without using actions such as actions/checkout, actions/upload-artifact, actions/download-artifact?

Re:GitHub Actions Are a Problem by maccard on Sunday November 12, 2023 @11:03AM (#38241326)
Doing this also means that your build scripts are version controlled. You can iterate on the build scripts in different branches, for example.
Re:GitHub Actions Are a Problem by twic on Sunday November 12, 2023 @11:08AM (#38241388)
GitHub actions are configured by version-controlled files too though. I have an actions-dev branch on my project, so I can iterate on actions config without having to clutter up master.

Would still be better if I could run locally to iterate. But the local run would have to have very high fidelity to what happens on GitHub to be useful.

Re:GitHub Actions Are a Problem by philihp on Sunday November 12, 2023 @01:34PM (#38242845)
Running actions triggered from a non-main branch does it for me, either on pushes to the branch, or 'workflow_dispatch'. You'll otherwise never get that level of fidelity to what happens in production.

Keep the logic in your YAML "dumb". Avoid variables and subroutines in the file, if you want to DRY something, create your own custom action. You can have unit tests on an action, you can't have unit tests on a GHA workflow.

Re:GitHub Actions Are a Problem by mdaniel on Sunday November 12, 2023 @12:56PM (#38242487)
That cuts both ways, in my experience: a bug fix needs a metric boatload of cherry-pick, possibly across a bunch of repos, to fix any bugs. Centralization is great until it's not

We have gotten a lot of good mileage out of GitLab's include: feature <https://docs.gitlab.com/ee/ci/yaml/#include>, which for clarity absolutely carries this same hazard, but can mean centralized fixes are less onoz than trying to patch every active branch of every active repo's build scripts

I am also aware this cuts against the thrust of the thread about "build scripts should be locally executable," but until they (they: GitHub, they: GitLab) straighten out their runner binary to be sane, it is currently a better use of our engineering effort maintaining CI yaml than teaching devs how to run CI locally

Re:GitHub Actions Are a Problem by SethMLarson on Sunday November 12, 2023 @11:22AM (#38241517)
This is the way.
Re:GitHub Actions Are a Problem by marcosdumay on Sunday November 12, 2023 @11:54AM (#38241865)
Building Java and C# on the command line nowadays is a hard undertaking, requiring weeks of learning and debugging, just to have your code change in a way that makes the scripts outdated at any time (oh, and it's never portable).

I really don't get why people use those complex CI/CD tools for other languages, but at least on the enterprise ones, I can understand people moving from the IDE into some huge centralized mess that can import it.

Re:GitHub Actions Are a Problem by twic on Sunday November 12, 2023 @12:23PM (#38242182)
Why does Java take weeks?

For a straightforward application or library project, you can fill in this form and get a shovel-ready build: https://gradle-initializr.cleverapps.io/

I usually tweak it a bit, but that's minutes, not weeks.

There's often more stuff to add as a project grows, but again, minutes to hours for the common stuff. Setting up publishing to a Maven repository is more work than I'd like, but it's still not weeks.

So what are you doing that it takes so long? And how long would that take if done any other way?

Re:GitHub Actions Are a Problem by neonsunset on Sunday November 12, 2023 @11:56AM (#38241901)
Building C# is quite literally 'dotnet build -c release'.
Re:GitHub Actions Are a Problem by Kwpolska on Sunday November 12, 2023 @12:19PM (#38242142)
(And building code that targets the classic .NET Framework can usually be accomplished by a single call to msbuild.exe.)
Re:GitHub Actions Are a Problem by hypeatei on Sunday November 12, 2023 @12:08PM (#38242029)
Exactly. I don't know where the newer .NET versions get the bad rap from.

You can criticize Microsoft for other things but .NET is not one of them. They've done a great job with it.

Re:GitHub Actions Are a Problem by Timon3 on Sunday November 12, 2023 @01:31PM (#38242822)
I wish I didn't have to circumvent the UI with a strategy like this. Part of the reason I like CI/CD tools is the visualization factor - I can create specific steps, see which step is currently active during execution, and only care for the output of a specific step during debugging.

A platform with support for visual control from the scripts (implemented as no-ops during local execution) would be perfect.

Re:GitHub Actions Are a Problem by truculent on Sunday November 12, 2023 @04:28PM (#38244242)
If you split your scripts into small tasks (i.e. one task per script), and call each one from your GA yaml, you would seem to have the best of both?
Re:GitHub Actions Are a Problem by Timon3 on Sunday November 12, 2023 @04:57PM (#38244507)
That still makes running it a bit annoying, since you have to call each script in order. You could of course create a script that covers this, but that's duplication that can drift apart. I guess you could generate the script from your YAML or use a linter or something, but it all feels a bit annoying. It would be awesome to e.g. just call a command like "gh-success" or "gh-failure" to manually indicate the success/failure, maybe with an optional ID to prevent accidental double calls etc.
Re:GitHub Actions Are a Problem by snnn on Sunday November 12, 2023 @03:00PM (#38243579)
I'm not quite familiar with GitHub Actions, but Azure DevOps Pipeline has a nice Preview API: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipe... which runs the preprocessing steps(like running the C preprocessor on a C source file) then gives you the processed yaml file. Then if you'd like, you can write your own local runner based on that if your yaml files do not use too many different kinds Azure DevOps pipeline steps.