The function `WithTestContext` is never called in the project, and
there is just one usage of `TestContext`, inside one of our loggers
Co-authored-by: Casey Lee <cplee@nektos.com>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* feat: add step name to logger field
This change does add the step name to the logger fields. This does
not change the output for our users, but for the json logger, it
does make each step output traceable.
* fix: remove new logger
Since logrus and context both are immutable for our case, we
can just add a new field and store the logger in the context.
Co-authored-by: Casey Lee <cplee@nektos.com>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-Authored-By: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Casey Lee <cplee@nektos.com>
* feat: add json logger output
This will allow to format log output as json.
This is helpful in cases where act is not executed on a 'local' machine.
* refactor: use runner config
Using the runner config to configure logging is cleaner.
Co-authored-by: Casey Lee <cplee@nektos.com>
this commit adds support for the `::add-mask::` command, which was
implemented as a stub before.
it does not cover debug output that appears when you run act in
verbose mode
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
* feat: run jobs in parallel
This changes fixes and restructures the parallel execution of jobs.
The previous changes limiting the parallel execution did break this
and allowed only one job in parallel.
While we run #CPU jobs in parallel now, the jobs added per job-matrix
add to this. So we might over-commit to the capacity, but at least
it is limited.
* fix: correctly build job pipeline
The job pipeline should just append all required pipeline steps.
The parallelism will be handled by the ParallelExecutor and we
shouldn't handle it during building the pipelines.
Also this adds a test, that the ParallelExecutor does run
a limited amount of parallel goroutines.
* test: correct test implementation
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* refactor: remove debug error output
Errors should always be logged with an error level and not debug level.
Since the error is returned here, it will be logged later as an error.
Presumably this was a leftover from debugging the executor chain in:
PR: #971
* refactor: debug log wich expression is going to be evaluated
* fix: handle nil in EvalBool
We've seen this issue when the env map is not set-up properly,
i.e. when the env map is nil, EvalBool might return nil, which should
be handled as a falsy value.
* fix: fail on error in if expression and return the evaluation error
Stop running the workflow in case an expression cannot be evaluated.
Fixes: #1008
* fix: remove quotes from inside expression syntax in test
It looks like having an expression inside double quotes inside the
expression syntax is not valid: https://github.com/ZauberNerd/act-test/actions/runs/1881986429
The workflow is not valid. .github/workflows/test.yml (Line: 10, Col: 13): Unexpected symbol: '"endsWith'. Located at position 1 within expression: "endsWith('Hello world', 'ld')"
* refactor: export IsTruthy function from exprparser package
* refactor: use IsTruthy function in EvalBool
* refactor: move debug log for expression rewrite to rewrite function
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* refactor: default empty `if:` statement to `if: success()` in evaluator
Previously the code to default an empty `if:` statement in the yaml file
was implemented in different files in the model package.
Now an empty `if:` statement defaults to `success()` in the expression
evaluator.
* refactor: remove obsolete `FixIfStatement` functions
The introduction of the expression evaluator seems to have made these
functions obsolete, as the test case `TestRunEvent/issue-598` works even
without these functions.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This change extracts the functionality of reading an `action.y(a)ml` or
creation of a `(Synthetic Action)` into its own type to enable better
unit testing / mocking of those IO operations.
This is done in preparation for the implementation of pre/post action
support in act.
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
This splits the executor from the RunContext into its own function
called newJobExecutor.
We defined an interface called jobInfo which is implemented by the RunContext.
This enables better unit testing because only a small interface needs to
be mocked.
This is a preparation for implementing pre and post actions.
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Marcus Noll <marcus.noll@new-work.se>
Co-authored-by: Jonas Holland <jonas.holland@new-work.se>
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Marcus Noll <marcus.noll@new-work.se>
Co-authored-by: Jonas Holland <jonas.holland@new-work.se>
Co-authored-by: Robert Kowalski <robert.kowalski@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
* docs: Expand the GITHUB_TOKEN section
* docs: Add a note on leaking GITHUB_TOKEN through shell history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Github sets the outcome and conclusion to skipped
and this PR does the same during the pipeline run for
the StepResults in act.
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
With this change `act` will try to populate the `githubContext.ref` and
`githubContext.sha` with values read from the event payload.
Caveats:
- `page_build` should not have a ref
- `status` should not have a ref
- `registry_package` should set the ref to the branch/tag but the
payload isn't documented
- `workflow_call` should set ref to the same value as its caller but the
payload isn't documented
- most of the events should set the sha to the last commit on the ref
but unfortunately the sha is not always included in the payload,
therefore we use the sha from the local git checkout
Co-Authored-By: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
* feat: implement expression evaluator
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
* feat: integrate exprparser into act
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
* Escape { and }, do not fail on missing properties
* Fix empty inputs context
* fix: contains() comparison for complex values
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Philipp Hinrichsen <philipp.hinrichsen@new-work.se>
Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
This commit moves the githubContext, jobContext and stepResult structs
from the runner package to the model package in preparation for #908
because the expression.go file lives in the runner package and would
introduce cyclic dependencies with the exprparser package.
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Feature: uses in composite
* Negate logic
* Reduce complexity
* Update step_context.go
* Update step_context.go
* Update step_context.go
* Fix syntax error in test
* Bump
* Disable usage of actions/setup-node@v2
* Bump
* Fix step id collision
* Fix output command workaround
* Make secrets context inaccessible in composite
* Fix order after adding a workaround (needs tests)
Fixes https://github.com/nektos/act/pull/793#issuecomment-922329838
* Evaluate env before passing one step deeper
If env would contain any inputs, steps ctx or secrets there was undefined behaviour
* [no ci] prepare secret test
* Initial test pass inputs as env
* Fix syntax error
* extend test also for direct invoke
* Fix passing provided env as composite output
* Fix syntax error
* toUpper 'no such secret', act has a bug
* fix indent
* Fix env outputs in composite
* Test env outputs of composite
* Fix inputs not defined in docker actions
* Fix interpolate args input of docker actions
* Fix lint
* AllowCompositeIf now defaults to true
see https://github.com/actions/runner/releases/tag/v2.284.0
* Fix lint
* Fix env of docker action.yml
* Test calling a local docker action from composite
With input context hirachy
* local-action-dockerfile Test pass on action/runner
It seems action/runner ignores overrides of args,
if the target docker action has the args property set.
* Fix exec permissions of docker-local-noargs
* Revert getStepsContext change
* fix: handle composite action on error and continue
This change is a follow up of https://github.com/nektos/act/pull/840
and integrates with https://github.com/nektos/act/pull/793
There are two things included here:
- The default value for a step.if in an action need to be 'success()'
- We need to hand the error from a composite action back to the
calling executor
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* Patch inputs can be bool, float64 and string
for workflow_call
Also inputs is now always defined, but may be null
* Simplify cherry-picked commit
* Minor style adjustments
* Remove chmod +x from tests
now fails on windows like before
* Fix GITHUB_ACTION_PATH some action env vars
Fixes GITHUB_ACTION_REPOSITORY, GITHUB_ACTION_REF.
* Add comment to CompositeRestrictions
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Ryan <me@hackerc.at>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>