Commit graph

57 commits

Author SHA1 Message Date
胖梁
8072a00a77
WorkflowDispatchConfig supports multiple yaml node kinds (#2123)
* WorkflowDispatchConfig supports ScalarNode and SequenceNode yaml node kinds

* Avoid using log.Fatal

* package slices is not in golang 1.20

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2024-01-20 14:07:36 +00:00
raffis
04011b6b78
feat: support runs-on labels and group (#2062)
Signed-off-by: Raffael Sahli <raffael.sahli@doodle.com>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
2023-11-12 19:46:38 +00:00
ChristopherHX
83140951bf
feat: cmd support for windows (#1941)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-08-08 15:44:25 +00:00
Josh McCullough
808cf5a2c3
throw when invalid uses key is provided (#1804)
* throw if `uses` is invalid

* update JobType to return error

* lint

* put //nolint:dupl on wrong test

* update error message to remove end punctuation

* lint

* update remote job type check

* move if statement

* rm nolint:dupl ... we'll see how that goes

---------

Co-authored-by: Casey Lee <cplee@nektos.com>
2023-07-10 21:27:43 -07:00
psa
3ac2b726f2
Fix bug in processing jobs on platforms without Docker (#1834)
* Log incoming jobs.

Log the full contents of the job protobuf to make debugging jobs easier

* Ensure that the parallel executor always uses at least one thread.

The caller may mis-calculate the number of CPUs as zero, in which case
ensure that at least one thread is spawned.

* Use runtime.NumCPU for CPU counts.

For hosts without docker, GetHostInfo() returns a blank struct which
has zero CPUs and causes downstream trouble.

---------

Co-authored-by: Paul Armstrong <psa@users.noreply.gitea.com>
Co-authored-by: Jason Song <i@wolfogre.com>
2023-06-06 03:00:54 +00:00
Zettat123
baf3bcf48b
avoid using log.Fatal (#1759) 2023-04-25 02:09:54 +00:00
Jason Song
816a7d410a
Avoid using log.Fatal in pkg/* (#1705)
* fix: common

* fix: in runner

* fix: decodeNode

* fix: GetMatrixes

* Revert "fix: common"

This reverts commit 6599803b6ae3b7adc168ef41b4afd4d89fc22f34.

* fix: GetOutboundIP

* test: fix cases

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-04-18 14:17:36 +00:00
ChristopherHX
d70b225e85
fix: reusable workflow panic (#1728)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-04-13 13:47:59 +00:00
Markus Wolf
89cb558558
fix: update output handling for reusable workflows (#1521)
* fix: map job output for reusable workflows

This fixes the job outputs for reusable workflows. There is
a required indirection. Before this we took the outputs from
all jobs which is not what users express with the workflow
outputs.

* fix: remove double evaluation

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-02-23 22:34:47 +00:00
Markus Wolf
a8e05cded6
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>
2022-12-15 16:45:22 +00:00
Markus Wolf
0f8861b9e3
fix: handle env-vars case sensitive (#1493)
Closes #1488
2022-12-07 15:31:33 +00:00
Lim Chun Leng
87327286d5
Fix shellcommand error on sh shell (#1464)
Co-authored-by: Lim Chun Leng <limchunleng@gmail.com>
2022-11-25 10:38:49 +00:00
Markus Wolf
9b95a728d8
feat: parse types of reusable workflows (#1414)
This change does parse the different types of workflow jobs.
It is not much by itself but the start to implement reusable
workflows.

Relates to #826

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-01 15:58:07 +00:00
Markus Wolf
1e0ef8ce69
Mapping workflow_dispatch inputs into the Expression inputs context (#1363)
* test: check workflow_dispatch inputs

This implements a test to check for `workflow_dispatch` inputs.
This will be a prerequisite for implementing the inputs.

* feat: map workflow_dispatch input to expression evaluator

This changes adds the workflow_dispatch event inputs
to the `inputs` context and maintaining the boolean type

* fix: coerce boolean input types

* fix: use step env if available, rc env otherwise
2022-10-17 16:25:26 +00:00
Markus Wolf
679cac1677
Fix composite input handling (#1345)
* test: add test case for #1319

* fix: setup of composite inputs

This change fixes the composite action setup handling of inputs.

All inputs are taken from the env now. The env is composed of
the 'level above'.
For example:
- step env -> taken from run context
- action env -> taken from step env
- composite env -> taken from action env

Before this change the env setup for steps, actions and composite
run contexts was harder to understand as all parts looked into
one of these: parent run context, step, action, composite run context.

Now the 'data flow' is from higher levels to lower levels which should
make it more clean.

Fixes #1319

* test: add simple remote composite action test

Since we don't have a remote composite test at all
before this, we need at least the simplest case.
This does not check every feature, but ensures basic
availability of remote composite actions.

* refactor: move ActionRef and ActionRepository

Moving ActionRef and ActionRepository from RunContext into the
step, allows us to remove the - more or less - ugly copy operations
from the RunContext.

This is more clean, as each step does hold the data required anyway
and the RunContext shouldn't know about the action details.

* refactor: remove unused properties
2022-10-06 21:58:16 +00:00
Alex Savchuk
d1daf2f28d
fix: support expression for step's continue-on-error field (#900) (#1331)
Co-authored-by: Markus Wolf <KnisterPeter@users.noreply.github.com>
2022-09-08 14:20:39 +00:00
Hisham Muhammad
91296bd5eb
fix: allow TimeoutMinutes to be expression in Jobs (#1247)
This change stops act from rejecting valid entries such as

```
    timeout-minutes: ${{ matrix.runtime == 'v8' && 30 || 15 }}
```

at the job level.

This change complements the fix that was already in place
for the Step struct, done in #1217. See:

52f5c4592c

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-08 00:31:19 +00:00
ChristopherHX
c30bc824b2
fix: processing of strategy.matrix.include (#1200)
* Update workflow.go

* Update workflow.go

* Update workflow.go

* Update workflow.go

* Update workflow.go

* Update workflow.go

* Add Tests

* Update workflow.go

* Modify Test

* use tabs

Co-authored-by: Casey Lee <cplee@nektos.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-20 15:33:07 -07:00
R
52f5c4592c
fix: allow TimeoutMinutes to be expression (#1217) 2022-06-16 20:57:19 +00:00
R
ebb408f373
fix: remove composite restrictions (#1128)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-23 20:27:12 +00:00
Markus Wolf
1e72c594ac
fix: return invalid step type (#1157)
If a step does not have either a `run` or `uses` directive it is
considered invalid.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 19:30:18 +00:00
Ryan
b3bd268e45
fix: return error on reusable workflows (#1093)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-03-30 17:20:45 +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
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
Ryan
37aaec81f4
feat: improve list (#786) 2021-08-30 15:38:03 +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
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)
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
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
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
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
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
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
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
b438b836ea
fix: invoke login shells to source /etc/environment (#570) 2021-03-28 21:35:01 -07:00
Andrew Gee
60669808a4
Removed pipefail from bash shell execution to match GitHub Actions (#529)
fixes #528

Co-authored-by: Hugh Lunt <hugh.lunt@itv.com>

Co-authored-by: Hugh Lunt <hugh.lunt@itv.com>
2021-02-12 08:28:26 -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
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
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
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
Amit Mahbubani
0b9268ada7
Fix comments on StepType enum consts (#304) 2020-07-13 09:39:23 -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
Casey Lee
ead2ab4d69
fix #95 - change ports to array of strings 2020-02-24 22:37:20 -08:00
Casey Lee
51b6167606
fix 99: support string and map variants of container 2020-02-24 22:35:08 -08:00
Casey Lee
01876438c2
shared container for job 2020-02-23 15:01:25 -08:00
Casey Lee
418b0db047
reuse containers to fix #86 2020-02-20 22:43:20 -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
73559207c7
initial support for expressons
Signed-off-by: Casey Lee <cplee@nektos.com>
2020-02-20 21:05:59 -05:00