Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to spawn and run a local reusable workflow #1423

Merged
merged 11 commits into from
Dec 15, 2022

Conversation

KnisterPeter
Copy link
Member

@KnisterPeter KnisterPeter commented Nov 3, 2022

This change contains the ability to parse/plan/run a local reusable workflow.
There are still numerous things missing:

  • inputs
  • secrets
  • outputs

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2022

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 8 0 0.04s
✅ REPOSITORY gitleaks yes no 2.86s
✅ REPOSITORY git_diff yes no 0.0s
✅ REPOSITORY secretlint yes no 1.25s

See errors details in artifact MegaLinter reports on CI Job page
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Merging #1423 (f911901) into master (4f8da0a) will increase coverage by 3.90%.
The diff coverage is 67.71%.

@@            Coverage Diff             @@
##           master    #1423      +/-   ##
==========================================
+ Coverage   57.50%   61.41%   +3.90%     
==========================================
  Files          32       46      +14     
  Lines        4594     7124    +2530     
==========================================
+ Hits         2642     4375    +1733     
- Misses       1729     2443     +714     
- Partials      223      306      +83     
Impacted Files Coverage Δ
pkg/common/file.go 0.00% <0.00%> (ø)
pkg/container/docker_logger.go 52.08% <ø> (ø)
pkg/container/host_environment.go 0.00% <0.00%> (ø)
pkg/container/parse_env_file.go 0.00% <0.00%> (ø)
pkg/container/util.go 0.00% <0.00%> (ø)
pkg/model/action.go 0.00% <0.00%> (ø)
pkg/model/step_result.go 0.00% <ø> (ø)
pkg/container/docker_run.go 13.58% <11.48%> (+8.04%) ⬆️
pkg/model/workflow.go 42.11% <18.51%> (-8.80%) ⬇️
...ontainer/linux_container_environment_extensions.go 24.32% <24.32%> (ø)
... and 39 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@KnisterPeter KnisterPeter marked this pull request as ready for review December 7, 2022 11:16
@KnisterPeter KnisterPeter requested a review from a team as a code owner December 7, 2022 11:16
Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments, you don't have to address them in this PR. I will approve this after testing it.

@@ -315,6 +315,8 @@ func rewriteSubExpression(ctx context.Context, in string, forceFormat bool) (str
func getEvaluatorInputs(ctx context.Context, rc *RunContext, step step, ghc *model.GithubContext) map[string]interface{} {
inputs := map[string]interface{}{}

setupWorkflowInputs(ctx, &inputs, rc)
Copy link
Contributor

@ChristopherHX ChristopherHX Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this behind workflow_dispatch (line 349) ?, because workflow_call has precedence and unset inputs are filled up by workflow_dispatch inputs of the parent workflow.

The workflow_dispatch on field is probably wrong in this case...
Is github.event_name / ghc.EventName correctly set the parent / grandparent event_name? It is never workflow_call.
, the value is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inputs in the expression evaluator are a bit messy currently.
We should consider refactoring the setup of the evaluator to be more flexible and factor in the context availability.
Currently we only have to kind of fixed setups for the expression evaluator which is too tightly coupled.

}

if value == nil && config != nil && config.Inputs != nil {
value = input.Default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my research, the inputs ctx is available here as the workflow_dispatch inputs of the caller workflow.

pkg/runner/job_executor.go Show resolved Hide resolved
@mergify mergify bot requested a review from a team December 7, 2022 14:37
Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow outputs are not working as expected, see comments from me.
You still get my +1

@mergify mergify bot merged commit a8e05cd into master Dec 15, 2022
@mergify mergify bot deleted the local-reusable-workflows branch December 15, 2022 16:45
aholmes added a commit to aholmes/act that referenced this pull request Dec 15, 2022
* feat: allow to spawn and run a local reusable workflow

This change contains the ability to parse/plan/run a local
reusable workflow.
There are still numerous things missing:

- inputs
- secrets
- outputs

* feat: add workflow_call inputs

* test: improve inputs test

* feat: add input defaults

* feat: allow expressions in inputs

* feat: use context specific expression evaluator

* refactor: prepare for better re-usability

* feat: add secrets for reusable workflows

* test: use secrets during test run

* feat: handle reusable workflow outputs

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mergify bot added a commit that referenced this pull request Dec 19, 2022
* Support "result" on "needs" context.

This change adds "result" to a job's "needs" context, as documented [here](https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context). `act` currently tracks the success/failure/cancelled status of a job, but does not include this value the `needs` context.

Fixes #1367

* Change `Needs` to use a new struct rather than the open type `interface{}`.

Related #1497
Fixes #1367

* Add integration test to "needs" context change.

Relates: #1497

* feat: allow to spawn and run a local reusable workflow (#1423)

* feat: allow to spawn and run a local reusable workflow

This change contains the ability to parse/plan/run a local
reusable workflow.
There are still numerous things missing:

- inputs
- secrets
- outputs

* feat: add workflow_call inputs

* test: improve inputs test

* feat: add input defaults

* feat: allow expressions in inputs

* feat: use context specific expression evaluator

* refactor: prepare for better re-usability

* feat: add secrets for reusable workflows

* test: use secrets during test run

* feat: handle reusable workflow outputs

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* refactor: fix savestate in pre steps (#1466)

* refactor: fix savestate in pre steps

* fix pre steps collision

* fix tests

* remove

* enable tests

* Update pkg/runner/action.go

* Rename InterActionState to IntraActionState

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* fix: tail (not absolute) as entrypoint of job container (#1506)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Fix conflict in merge.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants