Feature: Added an action type for the action.yaml that uses sh #141
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind
Chore
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo/act!141
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "slatian/act:action-using-sh"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently the only way to get pre and post actions is to go through the nodejs mechanism, which is quite wasteful when all one wants to do is run a couple of shell commands, I'm trying to get around this with this patch.
It works similar to the node* actions in that it supports
pre,mainandpost.It is different in that these strings are passed to the system shell using
sh -cand execute similar to the composite run action with the shell set tosh.Example action to make use of this patch: https://codeberg.org/slatian/test-action/src/branch/main/action.yaml
References
GitHub Actions on the topic of pre / post support for composite actions https://github.com/actions/runner/issues/1478
cascading-pr updated at forgejo/runner#594
Feature: Added an action type for the action.yaml that uses shto Feature: Added an action type for the action.yaml that uses sh [skip cascade]I use composite quite often but never used pre/post. Does it work with composite as well?
You should be able to use the
shactions inside other composite actions without any problems as it is using the same interface as all the others (will test) but I've actively decided against touching composite actions themselves as that would have added more complexity in a place where it easily gets into the way of keeping up to date with upstream. This way it's also easier to draw a line between upstream and forgejo-flavored.I'll also have a look at the failed test.
Update: I've just tested it being used as part of a composite action and it works as expected.
Any changes you want me to apply?
For tests I might need a little pointer on how to write them.
I suggest you look for tests covering the other type of pre/post and mimic what they do. I don't know where they are from the top of my head. Once you find them, also make sure they are actually run the current suite only has some (because some of the tests are GitHub runner specific).
I've pushed a fist attempt at writing a test that should execute all three commands.
Unfortunately docker being hardcoded for the tests makes testing, more difficult than necessary, which is why I haven't tested the test yet. I pushed it in the hoes that the CI here would run it, but I haven't found it in the logs.
In addition I've deployed a
forgejo-runnerwith this version of act to my own runners, seems to work.@slatian wrote in #141 (comment):
It is not trivial indeed. Can I suggest you introduce a failure deliberately to verify it runs at all? That would be proof enough.
Bad news, it doesn't run and it fails, along with a whole bunch of other tests. To run it:
I tried running those in the not-too-distant past on my laptop but they fail. I suspect that's because they assume the test environment is setup in a way that only exists in GitHub Action. It is not a container but a virtual machine and has zillions of things pre-installed.
https://code.forgejo.org/forgejo/act/src/branch/main/.forgejo/workflows/test.yml
The test are running out of an application container which limits what they can install (or makes it needlessly complicated as in using DIND for instance).
Note that further down there are tests running on
lxc-bookwormwhich is a LXC container where you can install pretty much anything you want.To move forward, I suggest you create a new job for the sole purpose of running ./pkg/runner, out of an lxc-bookworm container. And there you can install the requirements.
23a4c636fe16c401ea8b0b2d004464ced8021692Okay besides the
preaction, which doesn't get tested because local actions don't execute the pre-stage for intransparent github reasons my tests and code work now.Do you want to get rid of this limitation?
My tests can be ran by themselves using:
go test -run=TestRunEventHostEnvironment/uses-sh -v ./pkg/runnergo test -run=TestRunEventHostEnvironment/uses-sh-test-action-path -v ./pkg/runner@slatian wrote in #141 (comment):
Great!
Can you add those two lines here?
- name: unit testrun: |go test -short -v ./pkg/containergo test -v ./pkg/jobparser ./pkg/model ./pkg/exprparserThat will be perfect and ready to merge then 🚀
Done!
Feature: Added an action type for the action.yaml that uses sh [skip cascade]to Feature: Added an action type for the action.yaml that uses shChecked to pass.
https://code.forgejo.org/forgejo/act/actions/runs/800#jobstep-10-1205
677c5a93f5225f4127f3cascading-pr updated at forgejo/runner#614
Added to the description for the record:
GitHub Actions on the topic of pre / post support for composite actions https://github.com/actions/runner/issues/1478
@slatian I tried to add an end-to-end test at forgejo/end-to-end#787 but the pre step does not run. Did I do something obviously wrong or does this deserve a bug report?
The syntax for IO is wrong, but after tinkering for a while I'm pretty sure my code is wrong too. I'll follow up with an explanation and another pull request.
Outputs are working.
Yes, I fell on my nose there too, the
preaction won't run for local actions and now I know why … dependency problem, local actions come from the workspace which has to be populated at which point it is too late to run theprestage of course … They could have explained that instead of saying it just doesn't work.Which explains why where is no pre-stage.
For populating the outputs the correct syntax is the same as with javascript actions.
And the test for the post command will fail simply because the post command hasn't run at that point in time, I'm also not sure if outputs are supported there at all because the post stage is for cleaning things up.
What I messed up though are the inputs, they should show up as
INPUT_…environment variables, but they don't.Not even that, for some reason the regex that should make sure only valid characters end up in the environment variable name lets minuses pass which aren't valid environment variables keys at some point (tbh. I have never seen a environment variable with a minus in it)
envKey := regexp.MustCompile("[^A-Z0-9-]").ReplaceAllString(strings.ToUpper(inputID), "_")To me this looks like a typo, but I haven't validated it yet.Update: Minus characters in environment variable names are POSIX compliant, they're filtred out somewhere by mistake.
If you change the variable name to not include a minus it will work.
foobecomesINPUT_FOO@earl-warren Okay, that's all from me. I hope the information helps.
I'm unable to find where the inputs with minuses get lost right now.