Commit Graph
10 Commits
Author SHA1 Message Date
Björn BrauerGitHubmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
ff13844b86 refactor: default empty if: statement to if: success() in evaluator & remove FixIfStatement() (#990)
* 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>
2022-02-15 20:03:00 +00:00
Björn BrauerandGitHub 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
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 <[email protected]>

Co-authored-by: Markus Wolf <[email protected]>
2022-02-08 20:17:59 +00:00
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 <[email protected]>

Co-authored-by: Philipp Hinrichsen <[email protected]>
2022-01-21 08:10:00 -08:00
eba71f98fe Refactor expression evaluator to use parser from actionlint package (#908)
* feat: implement expression evaluator

Co-authored-by: Markus Wolf <[email protected]>
Co-authored-by: Philipp Hinrichsen <[email protected]>

* feat: integrate exprparser into act

Co-authored-by: Markus Wolf <[email protected]>
Co-authored-by: Philipp Hinrichsen <[email protected]>

* Escape { and }, do not fail on missing properties

* Fix empty inputs context

* fix: contains() comparison for complex values

Co-authored-by: Markus Wolf <[email protected]>
Co-authored-by: Philipp Hinrichsen <[email protected]>
Co-authored-by: Christopher Homberger <[email protected]>
2022-01-21 08:07:20 -08:00
Björn BrauerGitHubMarkus Wolfmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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 <[email protected]>

Co-authored-by: Markus Wolf <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-12-22 19:52:09 +00:00
Björn BrauerandGitHub 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
b910a42edf Docker auth (#891)
* feat: read docker credentials from local docker config

* fix: url.Parse requires protocol

Co-authored-by: Björn Brauer <[email protected]>

* fix: docker decides by the existence of . or : if...

... the image is in a custom registry or not.

Co-authored-by: Björn Brauer <[email protected]>

* 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 <[email protected]>

Co-authored-by: Markus Wolf <[email protected]>
2021-11-27 18:21:32 +00:00
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 <[email protected]>

Co-authored-by: Markus Wolf <[email protected]>
2021-11-27 17:45:56 +00:00
0c4374ec41 GitHub Enterprise support (#658)
* Add option to specify custom GitHub instance

* Use correct GHE API endpoint URLs

Co-authored-by: Markus Wolf <[email protected]>

* Extract slug from GitHub Enterprise URLs

Co-authored-by: Markus Wolf <[email protected]>

* 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 <[email protected]>

* Add section about using act on GitHub Enterprise to README

Co-authored-by: Markus Wolf <[email protected]>

* Set GitHubInstance in runnerConfig in runner_test

Co-authored-by: Markus Wolf <[email protected]>

Co-authored-by: hackercat <[email protected]>
Co-authored-by: Markus Wolf <[email protected]>
2021-05-05 09:42:34 -07:00