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>
* fix: rework `setupShellCommand`
* move all logic to separate function so we can test that later
* split `step.Shell` and `step.WorkingDirectory` setup into own funcs
* general cleanup of function
* use `ActPath` to not collide with checked out repository
* use `shellquote.Split()` instead of `strings.Fields()` for better command split
* replace single string concat with `fmt`
Signed-off-by: hackercat <me@hackerc.at>
* lint(editorconfig): ignore *_test.go due to mixed style
Signed-off-by: hackercat <me@hackerc.at>
* fix: continue jobs + steps after failure
To allow proper if expression handling on jobs and steps (like always,
success, failure, ...) we need to continue running all executors in
the prepared chain.
To keep the error handling intact we add an occurred error to the
go context and handle it later in the pipeline/chain.
Also we add the job result to the needs context to give expressions
access to it.
The needs object, failure and success functions are split between
run context (on jobs) and step context.
Closes#442
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* style: correct linter warnings
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* fix: job if value defaults to success()
As described in the documentation, a default value of "success()" is
applied when no "if" value is present on the job.
https://docs.github.com/en/actions/learn-github-actions/expressions#job-status-check-functions
Co-authored-by: Markus Wolf <mail@markus-wolf.de>
* fix: check job needs recursively
Ensure job result includes results of previous jobs
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
* test: add runner test for job status check functions
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
* test: add unit tests for run context if evaluation
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* refactor: move if expression evaluation
Move if expression evaluation into own function (step context) to
better support unit testing.
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* test: add unit tests for step context if evaluation
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
* fix: handle job error more resilient
The job error is not stored in a context map instead of a context
added value.
Since context values are immutable an added value requires to keep
the new context in all cases. This is fragile since it might slip
unnoticed to other parts of the code.
Storing the error of a job in the context map will make it more stable,
since the map is always there and the context of the pipeline is stable
for the whole run.
* feat: steps should use a default if expression of success()
* test: add integration test for if-expressions
* chore: disable editorconfig-checker for yaml multiline string
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* feat: read docker credentials from local docker config
* fix: url.Parse requires protocol
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* fix: docker decides by the existence of . or : if...
... the image is in a custom registry or not.
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* fix: make docker hostname detection more robust
* test: mock docker config for getImagePullOptions test
By default github actions have a docker config set with a token to pull
images from docker hub.
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
We should reuse an existing context logger if in test context.
This will allow test to setup act with a null logger to assert
log messages.
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Co-authored-by: Markus Wolf <markus.wolf@new-work.se>
Adds option to rebuild local action docker images
Fixed up README due to missing flags after
PR #714 and #716
Signed-off-by: hackercat <me@hackerc.at>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Don't interpolate joboutputs, before job is donei
All credits go to @ChristopherHX which fixed this issue.
I only created a PR for this so it will be fixed in the upstream binary.
This fixes#758
* Added output test
* Fix typo
* tests(pkg/common) add failing test case for SSH git URL
* fix(pkg/common) github SSH regex for missing .git extension
Co-authored-by: Ryan <me@hackerc.at>
We should reuse an existing context logger if available.
This will allow test to setup act with a null logger to assert
log messages.
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* ci(golangci-lint): switch to latest
remove schema override since it was fixed in upstream
Signed-off-by: hackercat <me@hackerc.at>
* fix: apply lint fixes
* Add asset server and upload handling of binary files
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* Add asset download parts to the asset server
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* Add artifact-server-path flag
If the flag is not defined, the artifact server isn't started.
This includes the configuration of ACTIONS_RUNTIME_URL and
ACTIONS_RUNTIME_TOKEN which are set if the server is started.
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* Move ACTIONS_RUNTIME_* vars into the withGithubEnv setup
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* feat: add artifact server port as flag
This commits adds a flag to define the artifact server port.
If not given, the port defaults to 34567.
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* test: add artifact server tests
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* refactor: use fs.FS
This allows to add tests with in-memory file system
* feat: add support for gzip encoded uploads
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* test: add artifact integration test
* chore: run act tests with asset server path
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* docs: add new cli flags
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* test: add test workflow to testdata
* feat: add log output
* refactor: log shutdown error instead of panic
* feat: use outbound ip for the asset server
This change should allow to use the host ip in macos and windows.
Since docker is running in an intermediate vm, localhost is not
sufficient to have the artifacts in the host system.
* fix: do not use canceled context
To shutdown artifact server, we should not use the already canceled
context but the parent context instead.
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* feat: shutdown artifact server at end of pipeline
When the pipeline is done the asset server should be shut down
gracefully.
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* fix: close server if graceful shutdown failed
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
* fix: ignore server closed error from listen call
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
* fix: set default shell for containers to sh
This matches GitHub Actions behaviour where,
runners use bash since it's guaranteed to exist there
while containers use sh for compatibility
* tests: fixup for default shell
Running Docker on non-Linux platforms is very painful,
especially in CI. It's better to remove macOS for now,
until a better implementation is present.
Signed-off-by: hackercat <me@hackerc.at>
* ci: unpin goreleaser version
homebrew issue has been fixed
* ci: drop homebrew from goreleaser
act has been for quite a long time in homebrew-core
and it supports all macos/linux so there is no
reason for us to have separate tap, as it might
confuse some users
Co-authored-by: Casey Lee <cplee@nektos.com>
* fix: rewrite StepContext env
step env from workflow should be last one to be written
fixes https://github.com/nektos/act/issues/777
* test: verify env correctness
* fix: move test into existing workflow