Commit Graph

356 Commits

Author SHA1 Message Date
Markus Wolf 14c98015c5
feat: add json logger output (#1026)
* 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>
2022-03-14 15:33:11 +00:00
Robert Kowalski c22d833830
fix: hide masked values in log files (#1011)
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>
2022-03-02 08:29:34 +00:00
Markus Wolf 18792f9620
feat: run jobs in parallel (#1003)
* 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>
2022-02-25 18:47:16 +00:00
Björn Brauer c24cfc72f4
Expression evaluator fixes (#1009)
* 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>
2022-02-25 18:39:50 +00:00
ChristopherHX d1e0216039
fix: deep evaluate matrix strategy (#964)
* fix: deep evaluate matrix strategy

* Try to make linter happy.

* Apply PR feedback, fix insert directive more tests

* Fix: logic error

Co-authored-by: Casey Lee <cplee@nektos.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-15 16:35:02 +00:00
Björn Brauer 9abc87b416
fix: always execute closeContainer() executor (#988)
* fix: always execute closeContainer() executor

During our earlier refactoring in #984 we accidentally changed the
behaviour in such a way that the `closeContainer()` executor was never
called.

This commit restores the earlier behaviour.

Ref:
* https://github.com/nektos/act/pull/984/files#diff-c057d66dc9657d8428e290c69871596e2b567bb8fecad62a99cab54398131a84L294
* https://github.com/nektos/act/pull/984/files#diff-ea9d5c93d769ef9b268932dd9990363e97fc3bec8a00114979d049bead5dd718R68

* test: add testcases to ensure job containers are started/stopped

This commit adds tests to ensure that the executors of `startContainer`,
`stopContainer`, `interpolateOutputs` and `closeContainer` are always
called in the correct order.
2022-02-10 16:54:58 +00:00
Björn Brauer e4f0080a1e
refactor: extract setupAction into ActionReader (#986)
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>
2022-02-08 20:17:59 +00:00
Philipp Hinrichsen e23223ad02
refactor: extract RunContext Executor in JobExecutor (#984)
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>
2022-02-08 17:22:41 +00:00
ChristopherHX 7dbf3fcb96
Fix: regression run after failure (#971)
* Fix: Regressions of run step after failure

* Add test, to enshure no panic

* Print error of failed step
2022-01-27 16:20:44 +00:00
ChristopherHX 3f0375aeff
Test: env.ACT in if condition of the workflow (#965)
Co-authored-by: Mathijs van Veluw <BlackDex@users.noreply.github.com>

Co-authored-by: Mathijs van Veluw <BlackDex@users.noreply.github.com>
2022-01-25 09:27:27 -08:00
Markus Wolf 2eda7c6037
feat: add skipped status as step result (#950)
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>
2022-01-21 08:10:26 -08:00
Björn Brauer edd0fb92a7
feat: try to read ref and sha from event payload if available (#889)
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>
2022-01-21 08:10:00 -08:00
ChristopherHX 4be9062dd2
fix: set composite outputs on failure (#945)
fix: conclusion and outcome after error with failure condition
fix: continue-on-error doesn't work correctly for composite actions
2022-01-21 08:08:30 -08:00
Björn Brauer eba71f98fe
Refactor expression evaluator to use parser from actionlint package (#908)
* 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>
2022-01-21 08:07:20 -08:00
Björn Brauer ed01f464ed
refactor: export and move shared contexts into pkg/model (#931)
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>
2021-12-22 19:52:09 +00:00
Ryan 558081242c
feat: add node16 support (#922)
* feat: add node16 support

Signed-off-by: hackercat <me@hackerc.at>

* feat: bump images to node16

Signed-off-by: hackercat <me@hackerc.at>

* lint(editorconfig): ignore *.md due to mixed style

Signed-off-by: hackercat <me@hackerc.at>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-12-22 19:34:18 +00:00
ChristopherHX 9868e13772
Feature: uses in composite (#793)
* 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>
2021-12-22 19:19:50 +00:00
Ryan 9be6a58c0e
ci: replace superlinter with megalinter (#923)
* ci: replace superlinter with megalinter

Signed-off-by: hackercat <me@hackerc.at>

* fix: apply lint recommendations

Signed-off-by: hackercat <me@hackerc.at>
2021-12-22 09:29:43 -08:00
Ryan adabf2a202
fix: rework setupShellCommand (#930)
* 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>
2021-12-22 06:37:16 +00:00
Björn Brauer fec0c0c529
fix: ::stop-commands:: should continue to print the lines (#920)
> This special command allows you to log anything without accidentally running a workflow command.
https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#stopping-and-starting-workflow-commands

Example: https://github.com/ZauberNerd/act-test/runs/4469496818?check_suite_focus=true#step:8:10
2021-12-09 15:10:56 +00:00
Markus Wolf 1891c72ab1
fix: continue jobs + steps after failure (#840)
* 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>
2021-12-08 20:57:42 +00:00
Till! 5bdb9ed0fd
container credentials (#868)
* Chore: add a snapshot target

* Update: support credentials for private containers

Resolves: #788

* fix: rework container credentials

Signed-off-by: hackercat <me@hackerc.at>

* fix: check if Credentials are not nil

* fix: return on missing credentials key

Co-authored-by: hackercat <me@hackerc.at>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-27 18:05:56 +00:00
Victor Popkov e793d03f4b
Add more steps context support (#887)
* feat: add more steps context support

- Add step outcome
- Remove step success in favour of conclusion

* feat: add conclusion and outcome steps context tests

Add corresponding tests and extend pkg/runner/expression.go vmSteps() to
handle steps context conclusion and outcome iota as strings.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-27 17:55:26 +00:00
Björn Brauer 6517d04b9a
feat: allow existing logger from context (#898)
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>
2021-11-27 17:45:56 +00:00
Vladimir Romashchenko f7263399b9
feat: SELinux lables for --bind (#906) 2021-11-26 05:18:31 +00:00
Ryan 8ad6c07083
feat: add option for docker image rebuild (#878)
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>
2021-11-24 07:51:37 -08:00
Mathijs van Veluw ff8b1df797
Don't interpolate joboutputs, before job is done (#894)
* 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
2021-11-24 15:49:08 +00:00
Ryan 96cf907c5e
Fix regex for GITHUB_ENV parsing (#893)
* fix: correct env pattern regex

GitHub Actions allows for envvars to contain

Signed-off-by: hackercat <me@hackerc.at>

* format: format and typo fix

Signed-off-by: hackercat <me@hackerc.at>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-19 17:36:50 +00:00
Ryan 4ae71b5878
Revert "feat: allow existing logger from context (#859)" (#890)
This reverts commit 603cf56878.
2021-11-19 14:42:39 +00:00
Mike Beaumont 09693ec5b9
fix: fromJSON should work with any JSON (#883)
* test: fromJSON should work with arrays

* fix: fromJSON should work with any JSON
2021-11-15 14:26:04 +00:00
Ryan 12fa4d703d
fix: correctly unmarshal entrypoint (#876)
Signed-off-by: hackercat <me@hackerc.at>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-11-13 19:43:31 +00:00
Ryan 099af5e6a8
fix: interpolate env for step actions (#872)
Signed-off-by: hackercat <me@hackerc.at>
2021-11-12 15:21:18 -08:00
Markus Wolf 603cf56878
feat: allow existing logger from context (#859)
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>
2021-11-12 15:20:45 -08:00
Ryan cd24df5727
ci(golangci-lint): switch to latest (#870)
* 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
2021-11-12 12:48:10 -08:00
Markus Wolf 11f6ee37a6
Asset server implementation (#677)
* 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>
2021-11-10 09:57:22 -08:00
Ryan e9ae7894e3
fix: set `sh` as default shell for containers (#853)
* 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
2021-11-03 11:47:47 -07:00
ChristopherHX 83a28d9512
Close docker client (#789)
* Close docker client!

* Fix nil dereference

* Update run_context.go

* Bump

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-10-24 16:50:43 +00:00
Ryan a0d360236e
fix: rewrite StepContext env (#832)
* 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
2021-09-28 01:18:59 +00:00
Ryan 6c60af7677
fix: rewrite how image env is merged (#828)
* fix: rewrite how image env is merged

* test: add test for extractFromImageEnv
2021-09-27 19:01:14 +00:00
Ryan 7a426a0f37
refactor: re-implement `embed` without "unused" import (#830)
* refactor: re-implement `embed` without "unused" import

* fix(gitignore): ignore local docker registry data
2021-09-27 17:33:14 +00:00
Ryan 4d552e65ce
fix: add simple concurrency limit (#823)
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-09-26 16:21:12 +00:00
Ryan 3c1454825d
fix: mount volume for workflow info (#776)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-09-24 13:32:22 +00:00
Josh Soref aa080d0ed9
Provide hint for -P (#815) 2021-09-13 23:14:41 +00:00
Marcin Falkowski 9126f15aa2
support for container option: --hostname (#809) 2021-09-10 05:03:40 +00:00
Ryan de44a505da
fix: copy whole action dir to container (#774)
fixes https://github.com/nektos/act/issues/754
this will prevent actions from failing that use resources outside
of the action directory
2021-08-10 22:21:52 -07:00
Ryan bea32d5651
Add proper support for working-directory & fix command builder (#772)
* fix: align other Docker executors to print action

* fix: formatting

* fix: add proper workdir support

* fix: replace script filepath after slice creation

* fix: match substring so it works for pwsh

+ rename containerPath to scriptPath to reflect what value it contains
2021-08-10 19:40:20 +00:00
ChristopherHX 77b3968913
Fix docker: invalid reference format (#767)
* Fix local Docker actions: invalid reference format

* Create Dockerfile

* Create Dockerfile

* Update push.yml

* Revert "Create Dockerfile"

This reverts commit 9d1dbbc2c7.

* Fix lint

* fix: re-use image that is already present in repo

ubuntu:latest would pull unnecessary blobs from registry and count toward API limit

* fix: revert change

reverting due to issue in image deletion that will have to be investigated separately

Co-authored-by: Ryan <me@hackerc.at>
2021-08-09 18:16:31 +00:00
Ryan 94fd0ac899
Simplify Matrix decode, add defaults for fail-fast and max-parallel, add test (#763)
* fix[workflow]: multiple fixes for workflow/matrix

fix[workflow]: default `max-parallel`
fix[workflow]: default `fail-fast`, it's `true`, not `false`
fix[workflow]: skipping over the job when `strategy:` is defined but `matrix:` isn't (fixes #625)
fix[workflow]: skip non-existing includes keys and hard fail on non-existing excludes keys
fix[workflow]: simplify Matrix decode (because I "think" I know how `yaml` works) (fixes #760)
fix[tests]: add test for planner and runner

* fix(workflow): use yaml node for env key

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-08-09 15:35:05 +00:00
ChristopherHX 43d46aa62f
Fix format function {{, }} are escapes (#752)
* Fix format function {{, }} are escapes

Added some tests for some corner cases

* Update format function added 2 error checks
2021-08-09 15:19:10 +00:00
ChristopherHX 0ff204b615
Read localaction's from container (#719)
Fix localaction tests (missing checkout)

Co-authored-by: Ryan (hackercat) <me@hackerc.at>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-08-03 17:39:56 +00:00
Bryan Naegele 531ea02fb9
Fix `ImageOS` format (#761)
The current algorithm given `ubuntu-18.04` returns `ubuntu18.04` when it should be `ubuntu18` according to https://github.com/actions/virtual-environments/issues/345#issuecomment-581263296.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-08-01 15:39:39 +00:00
ChristopherHX 149cc19908
Fix defaults (composite) (#753)
* Fix defaults (composite)

* uses-composite: rely on defaults to pass

* Add test_input_required back, needs more tests

* Update Tests to test defaults carefully
2021-07-21 13:50:43 +00:00
Phil Story dcbd5837af
Add `needs` job output (#629)
* Add outputs field to job model

* Add output interpolation for jobs

* Add otto config reference for interpolated job output values into 'needs' context

* Add output interpolation call after job has completed.

* gofmt

* Remove whitespace

* goimports

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-07-01 15:20:20 +00:00
Ryan (hackercat) 1cf422e411
fix: warn Apple M1 (arm64) users (#743)
* fix: warn Apple M1 (arm64) users

* fix: missing dep

* fix: linting

* fix: linting (again)
2021-06-23 18:09:27 +00:00
Ryan (hackercat) a9fe038347
Update images, fix extrapath (#723)
* fix: typo

* fix: remove debug for git references

it generates a massive amount of logs

* feat: read values from env

allows to test act on GHA when it's not a main repo

* fix: merge extrapath with PATH

* fix(tests): add additional shells for testing

* fix(image): update images

pin node to major version only, current node version: 12.22.1
replace most images with `node:12-buster-slim` to prevent
errors on macOS runner due to DockerHub pull limit
replace ocaml image

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-06-10 23:12:05 +00:00
Justin Grote a9295c9db2
Test fixups for Windows/Forks (#681)
* Test fixups for Windows/Forks

* revert change for repo/actor/owner

this is fixed via https://github.com/nektos/act/pull/723

Co-authored-by: Ryan (hackercat) <me@hackerc.at>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-10 18:27:35 +00:00
ChristopherHX e5d4886787
Refactor local, composite actions and run steps (#712)
Skips docker cp for local actions and use their correct path
Defines GITHUB_ACTION_PATH also for nodejs actions
Evaluate Env of composite action
Evaluate Run of composite action correctly
Evaluate Shell of run step
Evaluate WorkingDirectory of run step
Changed tests for behavior change

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-10 15:28:23 +00:00
Joseph Benden 003c995b36
Support container removal at exit. Fixes #694 (#714)
This patch adds a new command-line flag (`--rm`) to automatically
stop workflow container(s), just prior to exit. The default
behavior is kept, e.g.: the containers continue running at exit.

Fixes: #694
Signed-off-by: Joseph Benden <joe@benden.us>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-10 15:09:05 +00:00
Ryan (hackercat) 2261204c65
fix: wrong perms (#726)
if someone is using image with a non-root user, they will get a permission denied since only root has write perms
2021-06-09 16:08:39 -07:00
Ryan (hackercat) 96a0564526
fix: don't replace empty secrets (#725) 2021-06-07 13:54:12 +00:00
Ryan (hackercat) 33ccfa6f3b
Switch to `interface{}` instead of `map[string]...` (#700)
* fix: change `env` to be an interface

allows to use GitHub functions like `fromJson()`

* fix: change matrix to an interface instead of map

This allows to use GitHub functions like `fromJson()` to create dynamic
matrixes

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-06 14:53:18 +00:00
Joseph Benden 6b4d359737
Add support for container kernel capabilities (#716)
This patch adds two new command-line flags to specify one or
more kernel capabilities to add or remove from the workflow
containers.

The command-line flag `--container-cap-add` allows for adding
specific capabilities on the workflow containers; where as,

The command-line flag `--container-cap-drop` allows for removing
specific capabilities on the workflow containers.

This was developed to specifically be able to add `SYS_PTRACE`
to a workflow I maintain. It involves using this capability to
monitor a make build, to then build a compilation database.

Signed-off-by: Joseph Benden <joe@benden.us>
2021-06-04 16:06:59 +00:00
Ryan (hackercat) d794e2fe4c
Move actions path outside of workdir (#701)
* feat: add option to specify user for exec

* fix: move actions to static path outside workdir

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-05-24 17:09:03 +00:00
Ryan (hackercat) 799098b0e6
feat: add option for custom socket path (#698) 2021-05-23 14:43:09 +00:00
Josh Soref 29ea8cfc4e
Fix: GITHUB_PATH should prepend (#690)
* GITHUB_PATH is prepend

https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path

* Check for replacing system binaries

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-05-18 13:22:39 +00:00
Ryan (hackercat) f571290b25
refactor: remove `gotest.tools` (#688)
* refactor: remove `gotest.tools`

* remove all references to `gotest.tools` and replace it with
  `github.com/stretchr/testify` which was originally used for tests
* bump `golangci-lint` version
* add `depguard` and `importas` to prevent import of unwanted packages
* add custom schema and information about config since
  schemastore.org has broken schema for `golangci-lint` config

* fix: handle more error cases
2021-05-17 23:14:49 -07:00
Markus Wolf 3db50376aa
fix: hide masked value (#668)
* fix: hide masked value

The ::add-mask:: command output logs the value to be masked.
This does expose critical information which should be hidden from
the output.

* Add test to not output secret in add-mask command

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-05-15 21:11:16 +00:00
Justin Grote ef0da2ab9e
Hotfix: Skip Checkout Regression (#680)
* Fix: Skip Checkout Regression

* Fix test name

* Add newline to end of checkout push test

* Restore .gitignore from node12 test. Todo: Restore that file after the test

* Format workflow

* Test: Fix path slash direction for windows relative source path

* Add explicit nil test for newRemoteAction

* Regress .secrets during tests

Co-authored-by: Ryan (hackercat) <me@hackerc.at>
2021-05-10 15:12:57 +00:00
Ryan (hackercat) aa68181f6b
refactor: return more errors, add more tests (#679)
adding more tests
returns same message for short SHA format like GitHub Actions
refactor error checking
add more errors :)
2021-05-08 03:29:03 +00:00
Josh Soref a144e71a1b
Add various GitHub environment variables (#604)
* define GITHUB_ACTION_PATH #603

* Add more environment variables

* Add job name

Note: the job name gets a suffix for matrix builds, but this is not part of the env var

* fix: remove unnecessary variables

* feat: add `RepositoryOwner`

credit: @KnisterPeter

* feat: add test for `getGithubContext()`

Co-authored-by: Ryan (hackercat) <me@hackerc.at>
2021-05-06 20:02:29 +00:00
Torbjørn Vatn 92eec3a526
$GITHUB_PATH support (#566)
* Regression in the .golangci.yml file

* This looks like an even better fix to #451

The previous solution only prevented the `starting container process caused "exec: \"bash\"`
error when someone added an "extra" path in the workflow using `::add-path`

* Add support for >> $GITHUB_PATH

* The newRunCommand has too high cyclomatic complexity

* Add "linux/arm64" to new test

* The cyclop linter was complaining so I extracted some funcs

* Close some readers

* Fix typo

* fix: add missing composite function

* Fix regress from merging

* Keep the error messages as is

* consolidate with master

* Close the tar reader on defer

* New way to get ContainerWorkdir

* Remove arch from runner test

* Separate the UpdateFromEnv and UpdateFromPath

Co-authored-by: hackercat <me@hackerc.at>
2021-05-06 13:30:12 +00:00
Ryan (hackercat) 8153dc92e5
Fix environment variables and move `envs.txt`/`event.json` to fixed location (#667)
* fix: environment variables sourcing from `/etc/environment`

* fix: move `envs.txt` & `event.json` to `/tmp/`

Since #635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
2021-05-05 23:11:43 +00:00
Renstrom aba4fec0ee
Fixes #598 (#628)
* Potentially solved merge conflict

* Update pkg/model/planner.go

Based on feedback

Co-authored-by: Ryan (hackercat) <me@hackerc.at>

* Fixed compilation error

* added missed test

* Fixed spelling error to work with lint error

Co-authored-by: Ryan (hackercat) <me@hackerc.at>
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-05-05 13:04:03 -07:00
Björn Brauer 0c4374ec41
GitHub Enterprise support (#658)
* Add option to specify custom GitHub instance

* Use correct GHE API endpoint URLs

Co-authored-by: Markus Wolf <knister.peter@shadowrun-clan.de>

* Extract slug from GitHub Enterprise URLs

Co-authored-by: Markus Wolf <knister.peter@shadowrun-clan.de>

* Use GITHUB_TOKEN for clone authenticate if provided

This change will allow use authentication for cloning actions
from private repositories or github enterprise instances.

Co-Authored-By: Markus Wolf <knister.peter@shadowrun-clan.de>

* Add section about using act on GitHub Enterprise to README

Co-authored-by: Markus Wolf <knister.peter@shadowrun-clan.de>

* Set GitHubInstance in runnerConfig in runner_test

Co-authored-by: Markus Wolf <knister.peter@shadowrun-clan.de>

Co-authored-by: hackercat <me@hackerc.at>
Co-authored-by: Markus Wolf <knister.peter@shadowrun-clan.de>
2021-05-05 09:42:34 -07:00
Markus Wolf 710a3ac94c
Add custom docker registry authentication (#665)
* Add custom docker registry authentication

Uses DOCKER_USERNAME and DOCKER_PASSWORD as secrets provided into
the act cli.

Closes #527

Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>

* Add test to check if pull authentication is filled in

* Update debug message to be more descriptive

Co-authored-by: Ryan (hackercat) <me@hackerc.at>

Co-authored-by: Björn Brauer <zaubernerd@zaubernerd.de>
Co-authored-by: Ryan (hackercat) <me@hackerc.at>
2021-05-05 09:37:17 -07:00
Justin Grote 616d7fcaeb
Remove pwsh -login and add Pwsh test (#660)
* Remove pwsh -login and add Pwsh test

* Add Shell Command Test for coverage

* 🧪 Move PWSH Platform definition to inline test, it can always be expanded out later

Reference: https://github.com/nektos/act/pull/660#discussion_r626171728

* Test MacOS Build for transient failure

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-05-05 05:57:33 +00:00
Justin Grote 0f049426f6
Separate Container Workdir from host Workdir (#635)
* Separate Container Workdir from Host Workdir

* Add delegated component to MacOS Test

* Lint: Remove leading newline

* Fix trailing path issue
2021-05-04 14:50:35 -07:00
Josh Soref 020d6a6083
Composite action (#608)
* Refactor maybeCopyToActionDir

* Use maybeCopyToActionDir for model.ActionRunsUsingComposite
2021-05-03 14:57:46 -07:00
Ryan (hackercat) cec63488f3
Add `super-linter` + fix lint issues (#650)
* feat: bump `golangci-lint`, add `super-linter`, replace outdated linter

Bump `golangci-lint` version.
Add `super-linter` to lint other languages.
Go linter is disabled because it's currently broken:
https://github.com/github/super-linter/pull/370
Replacing `scopelint` with `exportloopref`: "[runner] The linter
'scopelint' is deprecated (since v1.39.0) due to: The repository of the
linter has been deprecated by the owner.  Replaced by exportloopref."
Fixed formatting in `.golangci.yml`
Add addtional linters:
  `misspell`: purely style, detects typos in comments
  `whitespace`: detects leading and trailing whitespace
  `goimports`: it's gofmt + checks unused imports

* fix: lint/fix `go` files

* fix: lint with `standardjs`

* fix: lint/fix with `markdownlint`, make template more verbose

* feat: add lint stuff to makefile

* fix: `UseGitIgnore` formatting

* fix: lint/fix `README.md`

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-05-03 09:52:03 -07:00
Renstrom 3db3d416e3
Fixes Issue #597 (#637)
* feat:(Changed order of events, to prevent enviroment to run before if statement is run

* changed issue597 to issue-597

* Added test for linux/amd64
2021-05-03 09:51:48 -07:00
Josh Soref cc3e7aeaf2
GitHub Event Path #542 (#605)
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-05-03 08:02:26 -07:00
Ryan (hackercat) 806bc4d999
refactor: `NewWorkflowPlanner` (#648)
feat: add flag `--no-recurse` to disable recursion when reading workflows from directories
feat: added more tests to `TestPlanner`, renamed `TestJobFileInfo` to more appropriate name `WorkflowPlanTest`
style: changed error message to lowercase, added single quotes for better visibility

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-05-03 07:57:24 -07:00
Ryan (hackercat) 7ae9916de0
Add option to allow files/directories in `.gitignore` to be copied to container (#537)
* disable gitignore for actions

* feat: Add option to allow/disallow paths specified in .gitignore

Co-authored-by: Alan Birtles <alan.birtles@eu.sony.com>
2021-05-03 07:37:20 -07:00
Ryan (hackercat) f32babb51d
fix: reworked container architecture (#619)
- Don't set architecture, let Docker host decide it's own platform,
  remove `runtime` dependency and don't show default in `--help`
- Remove most tests, we need to check only once if it works on
  different platform
- Rename `DeleteImage` to `RemoveImage` to conform to existing
  function in `docker` cli, added options to specify `force` and
  `pruneChildren`
2021-05-02 08:15:13 -07:00
hackercat 4125812a63
Refactor `.actrc` locations and default image survey (#600)
* refactor: move survey/cfgs into own funcs, read XDG base dirs for config

Moved actrc locations to own func since it can be reused.
Moved survey part to own func due to high cyclomatic complexity.
Added XDG config dir to config locations.
Replaced using HOME envvar with go-homedir module since it's already
an indirect dependency and handles home directories better
for each GOOS.

* refactor: use `go-homedir`, check if XDG var is not empty
2021-04-05 08:51:13 -07:00
Mark DeLillo b9a7bc6202
Add support for composite actions (#514)
* Add support for composite actions

* Fix to make more complex composite actions work

* Fix to make more complex composite actions work

* Let's validate the steps in the composite steps to fail on uses and run's without shell, like the real world

* Add support for composite actions

* Add workflow to test composite actions

* Log instead of panicing when output is mismatched

* Merge maps so environment variables are not lost

* Remove Debug

* Correect merge error

* Remove invalid composite tests.

* Fix composite test

Co-authored-by: Casey Lee <cplee@nektos.com>
Co-authored-by: monkers <mikem@msquaredconsulting.co.uk>
Co-authored-by: Mike Moncrieffe <69815687+mikemonkers@users.noreply.github.com>
2021-04-02 13:40:44 -07:00
hackercat 5044ec6c43
fix: remove HOME env var (#594) 2021-04-01 14:01:01 -07:00
hackercat 25779af4bf
fix: return error if both `run:`/`uses:` keys are used (#593)
fixes https://github.com/nektos/act/issues/536
2021-04-01 11:36:41 -07:00
Josh Soref 5752a03dcd
Support running commands in repositories without action.yaml (#293)
* Comment for public function

* Add git describe fallback

* spelling: github

* Set initial branch to satisfy tests for modern git

* Clarify -even- if

* Go 1.16

* Support running commands in repositories without action.yaml

Support runnings commands with only a Docker file

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-03-30 12:26:25 -07:00
Justin Grote 957b8ad76d
Update Shell Tasks to match ScriptHandlerHelpers (#575)
* Update Shell Tasks to match ScriptHandlerHelpers
Code: https://github.com/actions/runner/blob/main/src/Runner.Worker/Handlers/ScriptHandlerHelpers.cs

Docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell

Fixes #467

* 🩹 Remove old ps1 handler

* ♻️ gocritix fix

* 🐛 Powershell command must be a single entry to docker API
Fixes #467

* Remove Act Temp

* Remove additional Act Directories

* remove hard-coded workdir

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-03-29 10:06:51 -07:00
hackercat 29b3d43988
fix: hardcode `ubuntu-latest` for `ImageOS` envvar (#579)
Hardcode current `ubuntu-latest` since we have no way to check that 'on the fly'
2021-03-28 21:46:09 -07:00
hackercat f3b53d8eca
fix: pass `sc.Env` through `common.Logger` to hide secrets (#578)
Currently all secrets are exposed when running with `--verbose`/`-v` option
2021-03-28 21:45:07 -07:00
rockandska 6cde8f64dc
use project dir instead of /github/workspace (#567) 2021-03-28 21:32:45 -07:00
hackercat 6c258cf40d
Add option to run custom architecture (container platform) (#525)
* Add QEMU to run different architectures

* Update dependencies in `go.mod`

* Add `--container-architecture` flag to specify custom image architecture

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-03-28 21:08:40 -07:00
hackercat 41b03b581c
fix: add `ImageOS` env var based on running platform (#571) 2021-03-17 17:14:08 -07:00
hackercat 09679f0156
Update test workflows and improve `expression_test.go`/`run_context_test.go` (#560)
* fix: give case insensitive secret more meanigful name

* refactor: use `string` in generating `env:` and `steps:` for workflows

Smaller text generation is much better to read with normal strings than
raw string literals.

* feat: sort keys for `env:` so it's always in specific order

* fix: update test workflows
2021-03-12 16:25:10 -08:00
hackercat eb2774275f
Fix tests on Windows (#562)
* fix: replace `\` with `/` in git ref to fix `git_test.go` on windows

Paths on Windows use backslash (`\`) as directory separator and this breaks `TestGitFindRef()`.
Replacing `\` with `/` in git ref fixes that issue.

* fix: replace `gopkg.in/godo.v2/glob` with std library `path/filepath`

`github.com/go-godo/godo` lib has been last updated in 2016 and it also
depends on another outdated lib `github.com/MichaelTJones/walk` with
last update in 2016. This also fixes `permission_denied` errors on
Windows (and perhaps Linux in some specific cases). I'm not aware of
any performance improvement or drawback because of that change.
2021-03-12 16:23:03 -08:00
Hibariya 8de7b956b7
Add --userns flag to support Docker daemon that enables user namespace (#533)
I got an error like this after hitting `act` command.

> Error: Error response from daemon: cannot share the host's network namespace when user namespaces are enabled

According to the document, when user namespaces are enabled on the Docker daemon,
neither host network mode and --privileged work without --userns=host. Since `act`
uses host network mode to match GitHub Actions runners, it cannot run jobs when
user namespaces are enabled. So I added the flag.

https://docs.docker.com/engine/security/userns-remap/#user-namespace-known-limitations

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-02-27 08:31:25 -08:00
Horimatsu Takuya 6c118fe9ad
#534 feat: step continues when continue-on-error is ture (#544)
* feat: step continues when continue-on-error is ture

* fix: typo, logging and make bool continuable

Co-authored-by: Casey Lee <cplee@nektos.com>
2021-02-25 08:55:07 -08:00
hackercat 34dc2dc15c
Update Docker images (#524) 2021-02-23 09:49:24 -08:00
Kamil Domański 475a6aa1d0
properly parse arguments to Docker container steps (#539) 2021-02-23 09:47:06 -08:00
KADOTA, Kyohei 316b078f8c
Shouldn't rewrite dot in a string to index syntax (#502)
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-02-08 09:14:12 -08:00
Taiju Muto eca1b9c478
Add lacking environment variables. (#513) 2021-01-31 21:59:51 -08:00
Cat™ 8339f4b404
Interpolate `with:` inputs (#511) 2021-01-30 17:43:11 -08:00
KADOTA, Kyohei 2d1a946fb1
Throw an error if the steps has a invalid uses directive (#500)
* Throw an error if the steps has a invalid uses directive

* Refactor TestStepContextExecutor
2021-01-23 08:07:28 -08:00
Cat™ e37b42a333
Print error with workflow/job information when runs-on key is not defined (#494)
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-01-21 06:02:48 -08:00
KADOTA, Kyohei 719a077b7c
Stop current execution if there is the invalid syntax in the workflow (#495) 2021-01-21 06:00:33 -08:00
Ed c7b3869b2f
Report error when `if` expression is invalid (#485)
Co-authored-by: Ed Tan <edtan@users.noreply.github.com>
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-01-18 11:44:27 -08:00
KADOTA, Kyohei e6fcfed458
Format sources with gofmt (#472)
Co-authored-by: Casey Lee <cplee@nektos.com>
2021-01-14 21:37:38 -08:00
Cat™ 460ed2db04
Update parts of repo (#476)
* Update flags in README

* Add secrets and `.env` files examples

* Fix typo: environment

* Fix typo: returned

* Add --version back, since I've built act without ldflags
2021-01-14 21:21:44 -08:00
Wink Saville f2c15074ac
Fix issue 416 (#423)
This is a solution to issue #416 where environment variables created or
changed in the previous step are not usable in the next step because
the rc.ExprEval is from the beginning of the previous step.

This change refactors setupEnv so that before interpolating the environment
variables a NewExpressionEvaluator is created.


Fixes: 416
2021-01-12 16:02:54 -08:00
Cat™ 2811101dea
Make all secrets case insensitive by formatting them to uppercase (#470)
* Uppercase secrets, print error when secret with same name already exists

* Test lower-to-upper case formatting for secrets
2021-01-12 09:54:53 -08:00
Torbjørn Vatn 15eaa15a0e
GitHub env file support (#426)
* Upgrade to the official golangci-lint action and fix some issues it found

* Update deps

* Remove a shadow warning

* Initialize the splitPattern only once

* Initial attempt at supporting $GITHUB_ENV

Needs some polishing and tests

* Now it's actually working

* Replace golang.org/x/crypto/ssh/terminal with golang.org/x/term

* Disable the issue-228 test again

* The linter is picky

* Discovered that the workflow/envs.txt had to exist in certain cases

* Fix small linter issue
2021-01-11 22:39:43 -08:00
Cat™ 80a245652e
Add option to disable hiding of secrets (#460) 2021-01-11 22:28:45 -08:00
Cat™ a9b3d6426b
Use static initial PATH (#462) 2021-01-11 22:27:16 -08:00
Steffen Seckler e47a2395a5
Fixes include when using matrix and strategy build. (#415)
* fixes include directive of strategy build.

* Adds test for include and exclude in matrix builds.

* ubuntu-16.04 instead of 20.04

* Adds more platforms for runner_test

Prevent most "skipping unsupported platform messages".

* correct printing for unsupported platform

* fix merge
2020-12-08 10:13:07 -08:00
Wink Saville d784bce96a
Extract runTestJobFile from TestRunEvent (#429)
This will allow other tests to be created in runner_test.go that can
be tested individually.
2020-11-29 21:45:11 -08:00
Torbjørn Vatn b3299ecd30
Act env (#417)
* Test more if env variants

* The correct negation syntax is !=

* Make the Interpolate function support negated booleans from envs

* Move assert := a.New(t) into t.Run

This uncovered that some of the test premisses was wrong and the
Eval Bool function also had flaws

* Remove a stray logrus import

* Add an ACT env set to true

This can be used to skip certain steps that you don't want to run locally
when testing. E.g. steps that sends messages to Slack channels on successful
builds etc.

* Add a description about env.ACT to the readme

* A new attempt at Interpolation and EvalBool

* One small merge fix

* Remove some fmt.Printfs

* Fix some merge conflicts
2020-11-18 07:14:34 -08:00
Torbjørn Vatn 8ba3306aa4
EvalBool and Interpolation fixes (#424)
* A new attempt at Interpolation and EvalBool

* One small merge fix

* Remove some fmt.Printfs
2020-11-17 09:31:05 -08:00
Torbjørn Vatn 3f4998a4ed
envs in if: - take 2 (#412)
* Test more if env variants

* The correct negation syntax is !=

* Make the Interpolate function support negated booleans from envs

* Move assert := a.New(t) into t.Run

This uncovered that some of the test premisses was wrong and the
Eval Bool function also had flaws

* Remove a stray logrus import
2020-11-12 08:15:09 -08:00
Steffen Seckler 695c496684
Adds ability to use container images from matrices. (#413)
Uses rc.ExprEval.Interpolate on container image.
2020-11-10 14:55:27 -08:00
Peter Tissen d5b2d60c35
Add variadic version of hashFiles (#411) 2020-11-09 09:08:57 -08:00
Wink Saville 3f3de6e0b1
Use PathListSeparator (#408)
In PR #406 I used PathSeparator and I should have used PathListSeparator.
 See: https://golang.org/pkg/os/#pkg-constants
2020-11-04 11:54:48 -08:00
Wink Saville 8204ef4b82
Change handling of ExtraPath (#406)
To make the handling of ExtraPath portable append it to the front of the
PATH when it exists, instead of always changing the script.
2020-11-02 13:56:20 -08:00
Owen Young 92067eb1a5
fix: outputs espace (#404)
* fix: outputs espace

* refactor: move unescape to func

* refactor: fix ci lint

* refactor: unescape function
2020-11-02 05:40:46 -08:00
Taliesin Sisson 014d71af43
When running on Windows the correct path separator must be used (#386)
* When running on Windows the correct path separator must be used. filePath.join is OS aware, so when we want to use forward slash use path.join instead.

on windows docker cp should end with \. when copying a directory
when running npm modules we should pass in path with all forward slashes

This fixes #331

* When calculating relative folders on Windows for destination path on Linux, we need to change \ for /

* Reduce complexity by extracting methods

* V1 does not point to a file that does not exist

* Looks like something else is the cause of this test breaking. Last successful build is #371, builds after that are failing
2020-10-08 22:30:50 -07:00
Javier Romero 729adec5e5
Fix path for local node12 actions (#371)
Fixes #185

Signed-off-by: Javier Romero <root@jromero.codes>
2020-09-29 13:39:45 -07:00
Leonardo Dino 44151f208e
Add CI=true environment variable (#372)
fixes #333
see https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
2020-09-28 08:22:42 -07:00
Owen 1070c58538
feat: support custom GITHUB_RUN_ID, GITHUB_RUN_NUMBER (#369)
* feat: add fromJSON support

* feat: support custom runId and runNumber

* chore: manual update

* chore: lint
2020-09-22 14:13:29 -07:00
Tom Lazar 7d443c6520
Set the default branch inside the event data (#354)
* set ${{github.event.repository.default_branch}}

* change `ok == false` to `!ok`

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-09-02 07:56:44 -07:00
Owen d521fa5bba
feat: add fromJSON support (#352) 2020-09-01 13:55:29 -07:00
Yoan Blanc 3eef111e46
chore: upgrade docker v19.03.12 (#348)
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-08-29 22:55:22 -07:00
Julian Squires e698e8b324
Support setting shell via defaults.run (#343)
Note that we don't support the more general use of defaults, just its
run key for setting shell and working directory.

The documentation for defaults.run is here:
  https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#defaultsrun

Fixes #214.

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-08-28 11:52:25 -07:00
watiko 26e4270e41
fix file permission for non root user docker image (#334) 2020-08-08 13:31:26 -07:00
Casey Lee 0ccc867f30
Merge branch 'master' into feat/add-privileged-mode 2020-08-01 19:05:56 -07:00
Tachibana waita 9a661538e6
actions/hello-world-javascript-action@master moved to main, use stable tag (#326) 2020-08-01 19:05:25 -07:00
whywaita 24bdb024bf
add flag of privileged mode 2020-08-02 05:21:49 +09:00
Denys Vitali ae39a4b1d3
fix(test): adapt to sjw change 2020-07-20 21:43:36 +02:00
Denys Vitali cc369e2f73
fix: add default values in vmInput 2020-07-20 21:17:49 +02:00
Amit Mahbubani 0b9268ada7
Fix comments on StepType enum consts (#304) 2020-07-13 09:39:23 -07:00
Ayaz BADOURALY 7dcd0bc1bb
Rewrite contexts before evaluating them (#287)
* Rewrite contexts before evaluating them

* Precompile context and expression patterns

* Test trim before rewrite

The current contextPattern is quite constraining and would fail the
rewrite of a context with trailing spaces. Triming happens during the
execution of Interpolate, and these tests aim to detect future breaking
changes on this behavior.

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-06-24 07:08:45 -07:00
Josh Soref 64b8d2afa4
Properly pass format argument to avoid MISSING (#290)
#273
2020-06-24 07:05:05 -07:00
Jeremy Lempereur 7cc668707b
remove .gitignore before docker cp (#288)
* Test setup before I try to understand how things work

* Remove .gitignore before we run docker cp
2020-06-23 11:57:24 -07:00
Stan Wohlwend d4e41a90a2
Fix container volumes being reused sometimes (#283) 2020-06-18 08:21:55 -07:00
Josh Soref 5c850b5ba8
Fix using: node12 handling (#243)
Co-authored-by: Casey Lee <cplee@nektos.com>
2020-05-18 14:31:09 -07:00
Josh Soref 2097a3c017
Spelling (#240)
* spelling: cartesian

* spelling: deferring

* spelling: marshal
2020-05-18 09:53:42 -07:00
Michael Heap d3f25bac79
Mask secrets in job output (#231)
Previously secrets would be shown in log output as provided. This
commit updates the stepLogFormatter to replace any instance of the secret
string with "***", as GitHub Actions would

Known issues: If the secret is a generic string (such as "docker"), all
occurances of that string will be replaced in the output

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-05-13 15:22:31 -07:00
Michael Heap a5e86bd024
Add support for changing the GITHUB_ACTOR (#229)
This adds the `-a` flag when running `act` to change the username of the GITHUB_ACTOR environment variable

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-05-12 00:14:56 -07:00
Torbjørn Vatn a149cf8ca2
Make envs available in if conditionals (#225)
* Ignore .idea

* Add Env to the RunContext vm so we can Evaluate and Interpolate `env.xx`

* Make EvalBool support expressions more in line with the github runner

* Turns out Boolean(value) is what github is doing after all

* Add test for github context as well
2020-05-04 12:18:13 -07:00
Michael Heap 6d6ea7ac04
Implement UnmarshalYAML for ActionRunsUsing (#223)
In #222 I added case normalisation to ReadAction() to ensure that Docker and docker are interpreted the same way.

I realised that this was being done at the wrong level and required multiple type conversions. By implementing `func (a ActionRunsUsing) UnmarshalYAML` we can lowercase the string as it's being unserialized

This has an added benefit that any time this type is hydrated the `runs.using` key will be lowercased, rather than relying on `ReadAction()`
2020-05-04 05:40:11 -07:00
Michael Heap 195a6c9ffb
Add default error case for Runs.Using (#221)
The string comparison in `step_context.go` is currently case sensitive. This commit adds an error that returns the valid options and tells the user what value they passed
2020-05-03 20:55:20 -07:00
Casey Lee a48cce3a78
fix: #170 add RUNNER_TEMP 2020-04-23 08:18:36 -07:00
Casey Lee a9533b05ce
fix: #170 #171 - add RUNNER_OS and RUNNER_TEMP 2020-04-22 23:57:36 -07:00
Casey Lee 8c290994c1
fix: #182 - support symlinks in workspace 2020-04-22 23:24:31 -07:00
Juan Eugenio Abadie b95fdb896f
Use env variables in Action.Runs.Env (#201)
* Use env variables in Action.Runs.Env

* Use Action.Runs.Env in all the cases
2020-04-19 11:29:34 -07:00
jony montana 2f395475b0
feat: load every environment from --env-file to workflow (#184)
* feat: load every environment from --env-file to workflow

* fix: pass dotenv's environments through by context

* updates to support --secret-file

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-04-17 10:04:40 -07:00
Alberto Fernández 67542608a2
Remove length constraint (#190) 2020-04-16 16:05:00 -07:00
Aidan Steele 4a4bd36cf6
Add support for runs-on array form (closes #146) (#155)
* Add support for runs-on array form (closes #146)

* Fixed style issues

Co-authored-by: Casey Lee <cplee@nektos.com>
2020-03-16 14:58:10 -07:00
Aidan Steele b670173764
Add support for step.working-directory (closes #149) (#154) 2020-03-14 00:00:37 -07:00
Casey Lee c439a6ff14
support nested expressions 2020-03-12 17:22:33 -07:00
Casey Lee 16520bb277
fix #122 - support actions/checkout for repos other the one for this workflow (#143) 2020-03-09 17:45:42 -07:00
Casey Lee 143676fcfb
fix #141 - use host network to match GitHub Actions runners (#142) 2020-03-09 17:43:24 -07:00
Casey Lee 15fb58bf43
fix #134 - include base_ref and head_ref in github context from the event json 2020-03-06 14:17:57 -08:00
Casey Lee 87392c2ed7
fix #134 - support 'env' context in steps 2020-03-06 13:39:01 -08:00
Casey Lee 4fde7d8865
fix #121 and #123 - add support for reading env variables from .env (#133) 2020-03-06 12:30:24 -08:00
Casey Lee af970769d7
fix #127 - force eval as a boolean (#131) 2020-03-06 11:30:39 -08:00
Casey Lee c32a87c6dc
fix #128: guard against empty actionName when 'uses: ./' (#130)
* fix #128: guard against empty actionName when 'uses: ./'

* fix #129 - force image name to be lowercase
2020-03-06 10:17:20 -08:00
Casey Lee 59b9b8e97a
fix #108 - ensure container names are unique for matrix runs 2020-03-04 16:24:14 -08:00
Casey Lee e9de6ca2c0
fix #115 - support toJson and toJSON (#116) 2020-02-28 15:20:31 -08:00
Casey Lee 6e1da1a70d
fix #110 - support path in action (#111) 2020-02-27 14:17:01 -08:00
Casey Lee 21e2bb8657
fix #108 - support matrix expressions in job name (#109) 2020-02-26 23:29:43 -08:00
Casey Lee 8696b42178
gofmt 2020-02-25 16:58:26 -08:00
Casey Lee 9dd2428546
fix #100 - change RUNNER_TOOL_CACHE to /opt/hostedtoolcache (#103) 2020-02-25 08:52:04 -08:00
Casey Lee 51b6167606
fix 99: support string and map variants of container 2020-02-24 22:35:08 -08:00
Casey Lee 1121f6e132
run with copy of workingdir 2020-02-24 17:48:21 -08:00
Casey Lee 8f5918942d
move action cache to volume 2020-02-24 16:38:49 -08:00
Casey Lee 037e08a3a7
integration test 2020-02-24 12:48:12 -08:00
Casey Lee 6c632946be
unit tests pass 2020-02-24 10:56:49 -08:00
Casey Lee 88041afb87
cache dir for remote actions 2020-02-23 22:34:48 -08:00
Casey Lee 94591c58d7
local actions done 2020-02-23 16:36:44 -08:00
Casey Lee ac1bd0893e
shared container for job 2020-02-23 15:02:01 -08:00
Casey Lee 01876438c2
shared container for job 2020-02-23 15:01:25 -08:00
Casey Lee 9179d8924d
updates for tests 2020-02-21 22:19:59 -08:00
Casey Lee 2cb276ca05
unchecked error 2020-02-21 08:42:00 -08:00
Casey Lee 418b0db047
reuse containers to fix #86 2020-02-20 22:43:20 -05:00
Casey Lee 9511f5baf4
fix unit tsts for runner
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:16 -05:00
Casey Lee 543501a36a
add support to override platform
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:15 -05:00
Casey Lee 573f78e1b4
support for secrets
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:09 -05:00
Casey Lee 9651992584
code complexity of NewPlanExecutor
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:07 -05:00
Casey Lee 60be2d67c1
align name of job in output
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:05 -05:00
Casey Lee f8fb88816a
matrix is done
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:03 -05:00
Casey Lee 5b7019cd0b
skip unsupported platforms
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:06:01 -05:00
Casey Lee 73559207c7
initial support for expressons
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:59 -05:00
Casey Lee 09773f7c5c
fix tests
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:57 -05:00
Casey Lee e40ab0145f
expressions working
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:55 -05:00
Casey Lee fd6fe1872f
bug with local action
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:48 -05:00
Casey Lee 64562d41ab
test updates
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:44 -05:00
Casey Lee f7252cbcf9
add commands support
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:42 -05:00
Casey Lee 033168228b
cleanup logging
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:40 -05:00
Casey Lee a21d4bbd90
ignore actions/checkout locally
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:38 -05:00