feat: allow inputs in runs-on #1117
No reviewers
Labels
No labels
FreeBSD
Kind/Breaking
Kind/Bug
Kind/Chore
Kind/DependencyUpdate
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
Windows
linux-powerpc64le
linux-riscv64
linux-s390x
run-end-to-end-tests
run-forgejo-tests
run-multi-platform-tests
No milestone
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
forgejo/runner!1117
Loading…
Reference in a new issue
No description provided.
Delete branch "aahlenst/runner:variables-in-runs-on"
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?
Allows referencing the
inputscontext injobs.<job_id>.runs-on. That is a prerequisite for enabling users to enter a label in the Forgejo UI duringworkflow_dispatch.Example:
While Forgejo already has the necessary UI to enter the variable, it does not pass the context to the jobparser. That still has to be done.
Apart from enabling
inputs, this PR expands the test coverage of the contexts supported byruns-on.How does this affect Forgejo showing icon near workflow when no runner required by workflow is online? Is the icon always present?
cascading-pr updated at actions/setup-forgejo#734
You will want to add the context in the schema too:
"context": ["forge", "forgejo", "github", "inputs", "vars", "needs", "strategy", "matrix"],and have a test associated with it to verify it validates.
Nevermind, it is aready there, just not where I expected 😊
bad review on my part
I think this should be fine as Forgejo can statically evaluate the workflow before it is submitted to the runner.
runsOn := origin.GetJob(id).RunsOn()for i, v := range runsOn {runsOn[i] = evaluator.Interpolate(v)}job.RawRunsOn = encodeRunsOn(runsOn)swf := &SingleWorkflow{Name: workflow.Name,RawOn: workflow.RawOn,Env: workflow.Env,Defaults: workflow.Defaults,}if err := swf.SetJob(id, job); err != nil {return nil, fmt.Errorf("SetJob: %w", err)}ret = append(ret, swf)Since
runs-onis already interpolated, it will be replaced with the result, the only thing missing is the input.@proton-ab Forgejo side workflows that generate multiple runs are first transformed in a series of workflows via jobparser, each of which is exactly one run. So, as long as
runs-onis replaced with the actual value statically evaluated, it will be fine.Since I overlooked the dynamic aspect causing problem with this other proposed change you authored, I would welcome a second opinion from @mfenniak
Unfortunately the code in Forgejo doesn't seem to work that way. While running actions work as you're describing, @earl-warren, displaying the Actions list actually parses the workflow file in order to determine if the
no_matching_online_runner_helper(No matching online runner with label: %s) label is displayed:codeberg.org/forgejo/forgejo@c3412d0579/routers/web/repo/actions/actions.go (L114-L148)Theoretically this could be updated on the Forgejo side. Rather than parsing the workflow, it could search the database
action_run_jobfor runs that have been performed (in some time range?) with that workflow file and check their definedruns_on, and then display an error if there are no runners available. 🤔But as it is, this seems incompatible with Forgejo's assumptions about
runs-onbeing able to be evaluated straight from the workflow file.Perhaps we could change where the warning icon is displayed, from having it on workflow list, to showing it near name on active action that is already in waiting state (hence it was evaluated by runner beforehand)? Not sure if it would require changes in how runner communicates with Forgejo though.
This solution would also hide warning icon in environments where runner is dynamically spawned in response to needs from autoscaler software.
Wait, it seems that we already skip evaluating of expressions for
runs-on?codeberg.org/forgejo/forgejo@c3412d0579/routers/web/repo/actions/actions.go (L134)This comment suggests that not showing the tool tip when
runs-oncontains expressions is expected.If you always want to be able to display whether a runner is available or not, looking at
runs-onafter it has been evaluated is a must. I have GitHub Actions workflows whose set ofruns-onlabels changes with every run because the labels are used to provision an on-demand runner for that specific run only.Ah... good spot, re: it's already skipped. That seems unfortunate as it would sure be hard to diagnose why an action isn't running. That isn't quite in the scope of this PR then, but it deserves a little criticism out to the world in general; "when my
runs-onis complicated I lose the ability to find out if I don't have a runner for it, which is more likely the time that I need that ability".I don't think that's a blocker for this PR.
This PR seems good to me. The only thing that prevents me from ✅ on it is that I'd like to hear that it's been integrated into Forgejo and tested end-to-end. Typically I do this by modifying
go.modand adding a newreplacedirective (eg.codeberg.org/forgejo/forgejo@c3412d0579/go.mod (L281)) that points at my localforgejo-runnercheckout, then running a development Forgejo. Then the testing I'd expect is to create a test repo, register a runner, and use a workflow dispatch to create an input runs-on -- basically exercise the capability. The automated testing here just can't cover the whole scope of potential change, so I think that manual test is warranted before merging here, waiting for a release, upgrading Forgejo, and then finding something that prevents it from working as expected.I have tested it locally. However, I'm not sure I covered every aspect of it. So it's probably best to wait until I have the PR ready for Forgejo. Then, you can look at the code and see for yourself whether I missed something or not. In any case, it will not be a perfect solution. For example,
inputsshould also work with reusable workflows. It does not and I have no idea why. But I prefer tiny steps over fixing every problem at once.Forgejo PR: https://codeberg.org/forgejo/forgejo/pulls/9950
Looks good to me. 👍
I think publishing v11.3.0 would be good. Not just for this PR but also for the LXC bootstrap race fix which Forgejo needs.
v11.3.0 is released. https://code.forgejo.org/forgejo/runner/releases/tag/v11.3.0 👍