1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-16 18:01:34 +00:00
Commit graph

119 commits

Author SHA1 Message Date
Earl Warren
e049c82d9c
chore: cancel context used in CI when running workflows (#831)
the context obtained from context.Background() may otherwise survive the test instead. It is equivalent to t.Context() which is only available in go >= v1.24

---

It is suspected to be the cause of

```
2025-08-10T13:01:08.5866723Z [services/Reproduction of failing Services interpolation] [DEBUG] Writing entry to tarball workflow/event.json len:2
2025-08-10T13:01:08.5866772Z [services/Reproduction of failing Services interpolation] [DEBUG] Writing entry to tarball workflow/envs.txt len:0
2025-08-10T13:01:08.5866818Z [services/Reproduction of failing Services interpolation] [DEBUG] Extracting content to '/var/run/act/'
2025-08-10T13:01:08.5866868Z [services/Reproduction of failing Services interpolation] service [postgres]: container health check a6b5d1443dd78f3d3aa244aeccabe72542f1c1ee33200f74a9ea33ae736f01f0 (code.forgejo.org/oci/postgres:16) is starting, waiting 10s
2025-08-10T13:01:08.5866919Z panic: test timed out after 10m0s
2025-08-10T13:01:08.5866984Z 	running tests:
2025-08-10T13:01:08.5867024Z 		TestRunner_RunWithService (2s)
2025-08-10T13:01:08.5867081Z
2025-08-10T13:01:08.5867142Z goroutine 55693 [running]:
2025-08-10T13:01:08.5867206Z testing.(*M).startAlarm.func1()
2025-08-10T13:01:08.5867250Z 	/go_path/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.12.linux-amd64/src/testing/testing.go:2373 +0x385
2025-08-10T13:01:08.5867300Z created by time.goFunc
2025-08-10T13:01:08.5867368Z 	/go_path/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.12.linux-amd64/src/time/sleep.go:215 +0x2d
...
2025-08-10T13:01:08.5878289Z goroutine 55692 [select]:
2025-08-10T13:01:08.5878350Z code.forgejo.org/forgejo/runner/v9/act/runner.waitForServiceContainer({0xf12e50, 0xc0006bbe30}, {0xf1e120, 0xc0003643c0})
2025-08-10T13:01:08.5878402Z 	/home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/runner/run_context.go:757 +0xd7
2025-08-10T13:01:08.5878460Z code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.1({0xf12e50?, 0xc0006bbe30?})
2025-08-10T13:01:08.5878524Z 	/home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/runner/run_context.go:770 +0x25
2025-08-10T13:01:08.5878592Z code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.NewParallelExecutor.2.1(0xc00015a5b0, 0xc00015a700)
2025-08-10T13:01:08.5878684Z 	/home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/common/executor.go:107 +0x52
2025-08-10T13:01:08.5878729Z created by code.forgejo.org/forgejo/runner/v9/act/runner.(*RunContext).waitForServiceContainers.func1.NewParallelExecutor.2 in goroutine 55682
2025-08-10T13:01:08.5878777Z 	/home/debian/.cache/act/7ffa26f4231b52fa/hostexecutor/act/common/executor.go:105 +0xf4
2025-08-10T13:01:08.5878821Z

...
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/831): <!--number 831 --><!--line 0 --><!--description Y2hvcmU6IGNhbmNlbCBjb250ZXh0IHVzZWQgaW4gQ0kgd2hlbiBydW5uaW5nIHdvcmtmbG93cyBbc2tpcCBjYXNjYWRlXQ==-->chore: cancel context used in CI when running workflows [skip cascade]<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/831
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-10 15:10:30 +00:00
earl-warren
e100e3084c
feat: log parsed commands and step summary (#824)
Refs https://github.com/nektos/act/pull/2761

---

* feat: log parsed command data in json logger

* Could be used to upload the GITHUB_STEP_SUMMARY by downstream Projects
* You can see the summary and other commands
* Access the raw line of most commands

* Update step.go

* Update step.go

* Update push.yml

* .

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit bb7db7b1c8a456d46907f3e65a6c4c2c1dcb6286)

```
Conflicts:
	act/runner/command.go
	act/runner/runner_test.go

  trivial context conflicts for both
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/824): <!--number 824 --><!--line 0 --><!--description ZmVhdDogbG9nIHBhcnNlZCBjb21tYW5kcyBhbmQgc3RlcCBzdW1tYXJ5-->feat: log parsed commands and step summary<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/824
Reviewed-by: Gusted <gusted@noreply.code.forgejo.org>
2025-08-07 21:03:44 +00:00
Earl Warren
96891ab314
feat: wait for services to be healthy before starting a job (#805)
If a --health-cmd is defined for a container, block until its status is healthy or unhealthy. The timeout is defined by the server internal logic based on associated --health-* defined delays. If it blocks indefinitely, the job timeout will eventually cancel it.

While waiting, the simplest solution would be to sleep 1 second until the container is healthy or unhealthy. To minimize log verbosity, the sleep interval is instead set to --health-interval and default to one second if it is not defined.

This logic does not apply to host containers as they do not support services. They are assumed to always be healthy.

If --health-cmd is set for the container running a job, the first step will start to run without waiting for the container to become healthy. There may be valid use cases for that but they are not the focus of this implementation.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/805): <!--number 805 --><!--line 0 --><!--description ZmVhdDogd2FpdCBmb3Igc2VydmljZXMgdG8gYmUgaGVhbHRoeSBiZWZvcmUgc3RhcnRpbmcgYSBqb2I=-->feat: wait for services to be healthy before starting a job<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/805
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-07 04:36:26 +00:00
Earl Warren
8b7e126c1c
fix: log the URL of the action when it fails schema validation (#810)
```
$ go test -v -run='TestRunner_RunEvent$/local-action-fails-schema-validation' ./act/runner
...
[fails-schema-validation/test]     Failure - Main ./local-action-fails-schema-validation/action
[fails-schema-validation/test] failed to validate action.y*ml from action './local-action-fails-schema-validation/action' with path '': Line: 2 Column 3: Failed to match null: Line: 2 Column 3: Expected a scalar got mapping
Line: 2 Column 3: Failed to match inputs-mapping: Line: 3 Column 5: Failed to match null: Line: 3 Column 5: Expected a scalar got mapping
Line: 3 Column 5: Failed to match input-mapping: Line: 3 Column 14: Unknown Variable Access secrets
...
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/810): <!--number 810 --><!--line 0 --><!--description Zml4OiBsb2cgdGhlIFVSTCBvZiB0aGUgYWN0aW9uIHdoZW4gaXQgZmFpbHMgc2NoZW1hIHZhbGlkYXRpb24=-->fix: log the URL of the action when it fails schema validation<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/810
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-04 13:20:22 +00:00
Earl Warren
79f6c54675
chore: replace docker hub with code.forgejo.org (#799)
<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/799): <!--number 799 --><!--line 0 --><!--description Y2hvcmU6IHJlcGxhY2UgZG9ja2VyIGh1YiB3aXRoIGNvZGUuZm9yZ2Vqby5vcmc=-->chore: replace docker hub with code.forgejo.org<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/799
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-02 21:55:57 +00:00
Earl Warren
a01cb5e6c5
chore(ci): autoremove when running a workflow in a test (#780)
Otherwise resources linger when tests are checking for conditions that
require a workflow to fail.

```sh
earl-warren:~/software/runner$ go test -count=1 -run='TestJobExecutorWorkflows/uses-github-short-sha' ./act/runner
ok  	code.forgejo.org/forgejo/runner/v9/act/runner	0.276s
earl-warren:~/software/runner$ docker network ls | grep WORKFLOW
2e57caeb514d   WORKFLOW-cc93880718786fef12c18e53feecee5c8ef1cc155840bf4c0275a2fca61b99b9_JOB-test-test-network   bridge    local
earl-warren:~/software/runner$
```

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/780): <!--number 780 --><!--line 0 --><!--description Y2hvcmUoY2kpOiBhdXRvcmVtb3ZlIHdoZW4gcnVubmluZyBhIHdvcmtmbG93IGluIGEgdGVzdA==-->chore(ci): autoremove when running a workflow in a test<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/780
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-08-01 14:06:32 +00:00
Earl Warren
ec99579451
chore: to allow the runner to be imported, v9 needs to be in the go module (#777)
It will be imported by Forgejo.

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- other
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/777): <!--number 777 --><!--line 0 --><!--description Y2hvcmU6IHRvIGFsbG93IHRoZSBydW5uZXIgdG8gYmUgaW1wb3J0ZWQsIHY5IG5lZWRzIHRvIGJlIGluIHRoZSBnbyBtb2R1bGU=-->chore: to allow the runner to be imported, v9 needs to be in the go module<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/777
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-31 10:35:11 +00:00
Earl Warren
a9ecd52de8
fix(ci): use code.forgejo.org instead of the docker hub (#762)
- use https://code.forgejo.org/forgejo/hello-world-docker-action/ that is a copy of https://github.com/actions/hello-world-docker-action/ with a patch to not use the docker hub
- node:16-buster-slim replaced with code.forgejo.org/oci/node:22 and checked that whatever is tested with it is not likely to be disturbed by the change in version
- change base images of Dockerfile to be from code.forgejo.org/oci/ equivalents
- use code.forgejo.org/forgejo/runner:8 instead of catthehacker/ubuntu:runner-latest

To test services:

- use code.forgejo.org/oci/bitnami/postgresql:16 instead of postgres:12
- use code.forgejo.org/oci/apache-git:1 instead of nginx:latest

Skip flaky test and [open an issue for it](https://code.forgejo.org/forgejo/runner/issues/763).

---

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- bug fixes
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/762): <!--number 762 --><!--line 0 --><!--description Zml4KGNpKTogdXNlIGNvZGUuZm9yZ2Vqby5vcmcgaW5zdGVhZCBvZiB0aGUgZG9ja2VyIGh1Yg==-->fix(ci): use code.forgejo.org instead of the docker hub<!--description-->
<!--end release-notes-assistant-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/762
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-29 15:37:16 +00:00
Earl Warren
ebc7758c1f
chore: s|github.com/nektos/act/pkg|code.forgejo.org/forgejo/runner/act| 2025-07-28 19:23:07 +02:00
Earl Warren
87d973b894 chore(tests): add coverage for ./pkg/runner (#202)
Only changes test files.

---

- remove tests specific to running on a host with no container
  they are the same as with the containers (TestRunEventHostEnvironment)
- prefix the name of the tests with a distinctive name to
  more easily run them together
- use code.forgejo.org/oci images whereever possible
- remove some tests that are either
  - difficult to understand (ancient bugs)
  - not yet well understood (related to reusable workflows)
  - depend on github (generation of workflows to be run on the fly
    e.g. updateTestIfWorkflow)
- fix the TestSanitizeNetworkAlias tests that were not run
  and make them easier to debug
- disable tests of options that are forbidden in Forgejo Actions
  (testdata/container-hostname/push.yml)

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/202
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-28 06:18:46 +00:00
Earl Warren
13ed94f5b7 feat!: add the validate argument to reading workflows (#180)
This is a followup of https://code.forgejo.org/forgejo/act/pulls/170 so that it is possible to read a workflow without validation. It is not uncommon for Forgejo to read a workflow just to extract a few information from it, knowing it has been validated before. It would be a performance regression if schema validation happened in these cases.

This is a port of https://github.com/nektos/act/pull/2717/files

It is a breaking change in the context of Forgejo and Forgejo runner because it will need to add the new `validate` argument when reading workflows.

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/180
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-16 08:46:36 +00:00
Earl Warren
6620cc1d18 fix: allow overriding RUNNER_TOOL_CACHE from the config file (#178)
- rc.getToolCache(ctx) is used to figure out RUNNER_TOOL_CACHE and  returns RUNNER_TOOL_CACHE if it is found in the runner config, e.g.
  ```yaml
  container:
    env:
	  RUNNER_TOOL_CACHE: /srv/toolcache
  ```
- store the value in the new `toolCache` data member for containers,  in the same way it is done for host
- GetRunnerContext for containers return `toolCache` instead of a  hard coded string
- add integration test

Closes forgejo/runner#184

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/178
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-13 21:55:02 +00:00
earl-warren
d2f668c880 fix!: fallback to sh if bash does not exist (#177)
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/177
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
2025-07-13 15:59:34 +00:00
Earl Warren
c1892b6398 fix!: fallback to sh if bash does not exist
It is a breaking change because it changes how the shell is
determined.

Before, if `jobs.<job_id>.container.image` is set and the shell is not
specified, it defaults to `sh` instead of `bash`.

After, regardless of `jobs.<job_id>.container.image`, if the shell is
not specified, it defaults to `bash` if available, otherwise it
defaults to `sh`.

Rework the shell integration tests:

- Remove container specific tests because the special behavior related
  to shell being set differently when a container image is present is
  removed
- Modify the defaults test case to verify the fallback logic
- Use container images from code.forgejo.org to escape rate limiting
  in the CI
- Add the missing node test
- Use
      container:
        image: code.forgejo.org/oci/node:22-bookworm
  instead of
      container: code.forgejo.org/oci/node:22-bookworm
  because it silently failed to run (with no exit code)
- Prefer `-z "${BASH}"` because `-z ${BASH+x}` reads obscure

Closes forgejo/runner#150
2025-07-12 19:01:14 +02:00
ChristopherHX
65ae238f17 feat: Validate GitHub Actions schema (#2416)
* feat: Validate GitHub Actions schema

**BREAKING** previously accepted workflows are now invalid

* update code

* fix tests

* Bump docker / fix lint

* fix test action due to moving the file

* remove unused function

* fix parsing additional functions

* fix allow int

* update docker dep, due to linter

(cherry picked from commit 64219df0f2155d75ffc4423dc93c1e80bb4740bc)

Conflicts:
	go.mod
	go.sum
	pkg/model/workflow.go

	trivial context conflict & go.mod upgrades
2025-07-11 14:12:22 +02:00
Earl Warren
7eb547faa5 fix: do not fail the job when if: false (#172)
- log job result as info not as debug
- add test

---

v6.4.0 regression introduced in 4880b091a2

It did not fail a test because the [original fix](https://code.forgejo.org/forgejo/act/pulls/67/files)  has tests only for the case where a step is skipped, not when a job is skipped.

Closes forgejo/runner#660

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/172
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-07-07 12:11:57 +00:00
Slatian
5cf8d53087 Feature: Added an action type for the action.yaml that uses sh (#141)
Currently the only way to get pre and post actions is to go through the nodejs mechanism, which is quite wasteful when all one wants to do is run a couple of shell commands, I'm trying to get around this with this patch.

It works similar to the node* actions in that it supports `pre`, `main` and `post`.

It is different in that these strings are passed to the system shell using `sh -c` and execute similar to the composite run action with the shell set to `sh`.

Example action to make use of this patch: https://codeberg.org/slatian/test-action/src/branch/main/action.yaml

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/141
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Slatian <baschdel@disroot.org>
Co-committed-by: Slatian <baschdel@disroot.org>
2025-06-14 15:31:32 +00:00
earl-warren
cade5051a8 Merge pull request 'chore: notify long delays in sync' (#93) from earl-warren/act:wip-cascade into main
Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/93
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
2025-05-27 05:51:58 +00:00
Earl Warren
1f85564111 fix: use code.forgejo.org/oci
Otherwise it may get rate limited in the CI verifying it works
2025-05-26 05:11:27 +00:00
ChristopherHX
ff13bafc55 Introduce LocalRepositoryCache for download remote actions, add them to ActionCache and execute as well 2025-04-28 08:42:10 +00:00
Earl Warren
ef243fbf2f fix: log skipped job and step result as info instead of debug
This allows the Forgejo runner to obtain the job result from the
logs even when it is not in debug mode.
2024-11-21 12:18:04 +00:00
Chongyi Zheng
a7c4e92822 Merge branch 'nektos/master' into bump-nektos 2024-02-17 13:19:51 -05:00
Sam Foo
2de6a8e3aa Add support for service containers (#1949)
* Support services (#42)

Removed createSimpleContainerName and AutoRemove flag

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/42
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Support services options (#45)

Reviewed-on: https://gitea.com/gitea/act/pulls/45
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Support intepolation for `env` of `services` (#47)

Reviewed-on: https://gitea.com/gitea/act/pulls/47
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Support services `credentials` (#51)

If a service's image is from a container registry requires authentication, `act_runner` will need `credentials` to pull the image, see [documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservicesservice_idcredentials).
Currently, `act_runner` incorrectly uses the `credentials` of `containers` to pull services' images and the `credentials` of services won't be used, see the related code: ba7ef95f06/pkg/runner/run_context.go (L228-L269)

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/51
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Add ContainerMaxLifetime and ContainerNetworkMode options

from: 1d92791718

* Fix container network issue (#56)

Follow: https://gitea.com/gitea/act_runner/pulls/184
Close https://gitea.com/gitea/act_runner/issues/177

- `act` create new networks only if the value of `NeedCreateNetwork` is true, and remove these networks at last. `NeedCreateNetwork` is passed by `act_runner`. 'NeedCreateNetwork' is true only if  `container.network` in the configuration file of the `act_runner` is empty.
- In the `docker create` phase, specify the network to which containers will connect. Because, if not specify , container will connect to `bridge` network which is created automatically by Docker.
  - If the network is user defined network ( the value of `container.network` is empty or `<custom-network>`.  Because, the network created by `act` is also user defined network.), will also specify alias by `--network-alias`. The alias of service is `<service-id>`. So we can be access service container by `<service-id>:<port>` in the steps of job.
- Won't try to `docker network connect ` network after `docker start` any more.
  - Because on the one hand,  `docker network connect` applies only to user defined networks, if try to `docker network connect host <container-name>` will return error.
  - On the other hand, we just specify network in the stage of `docker create`, the same effect can be achieved.
- Won't try to remove containers and networks berfore  the stage of `docker start`, because the name of these containers and netwoks won't be repeat.

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/56
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-committed-by: sillyguodong <gedong_1994@163.com>

* Check volumes (#60)

This PR adds a `ValidVolumes` config. Users can specify the volumes (including bind mounts) that can be mounted to containers by this config.

Options related to volumes:
- [jobs.<job_id>.container.volumes](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes)
- [jobs.<job_id>.services.<service_id>.volumes](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservicesservice_idvolumes)

In addition, volumes specified by `options` will also be checked.

Currently, the following default volumes (see f78a6206d3/pkg/runner/run_context.go (L116-L166)) will be added to `ValidVolumes`:
- `act-toolcache`
- `<container-name>` and `<container-name>-env`
- `/var/run/docker.sock` (We need to add a new configuration to control whether the docker daemon can be mounted)

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/60
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Remove ContainerMaxLifetime; fix lint

* Remove unused ValidVolumes

* Remove ConnectToNetwork

* Add docker stubs

* Close docker clients to prevent file descriptor leaks

* Fix the error when removing network in self-hosted mode (#69)

Fixes https://gitea.com/gitea/act_runner/issues/255

Reviewed-on: https://gitea.com/gitea/act/pulls/69
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>

* Move service container and network cleanup to rc.cleanUpJobContainer

* Add --network flag; default to host if not using service containers or set explicitly

* Correctly close executor to prevent fd leak

* Revert to tail instead of full path

* fix network duplication

* backport networkingConfig for aliaes

* don't hardcode netMode host

* Convert services test to table driven tests

* Add failing tests for services

* Expose service container ports onto the host

* Set container network mode in artifacts server test to host mode

* Log container network mode when creating/starting a container

* fix: Correctly handle ContainerNetworkMode

* fix: missing service container network

* Always remove service containers

Although we usually keep containers running if the workflow errored
(unless `--rm` is given) in order to facilitate debugging and we have
a flag (`--reuse`) to always keep containers running in order to speed
up repeated `act` invocations, I believe that these should only apply
to job containers and not service containers, because changing the
network settings on a service container requires re-creating it anyway.

* Remove networks only if no active endpoints exist

* Ensure job containers are stopped before starting a new job

* fix: go build -tags WITHOUT_DOCKER

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: ZauberNerd <zaubernerd@zaubernerd.de>
2023-10-19 09:24:52 +00:00
techknowlogick
b2f90e32b0 Merge remote-tracking branch 'upstream/master' into bump-nektos 2023-10-11 15:28:38 -04:00
ChristopherHX
02aa47db9e fix action_ref (composite action) (#2020)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-10-03 23:13:05 +00:00
techknowlogick
756db53bab Merge nektos/act/v0.2.51 2023-09-24 15:09:26 -04:00
ChristopherHX
fd5b21b7be 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
Jason Song
fc7b3c5c43 Merge tag 'nektos/v0.2.49'
Conflicts:
	cmd/input.go
	go.mod
	go.sum
	pkg/exprparser/interpreter.go
	pkg/model/workflow.go
	pkg/runner/expression.go
	pkg/runner/job_executor.go
	pkg/runner/runner.go
2023-08-02 11:52:14 +08:00
Sam Foo
19156ca8f6 Allow inputs for workflow_calls (#1845) 2023-06-27 17:32:04 +00:00
Jason Song
441bf3e1a7 Merge tag 'nektos/v0.2.45' 2023-05-04 17:45:53 +08:00
M.Yamashita
b7ebd96ec7 Remove the comment-out code. (#1691)
Co-authored-by: Jason Song <i@wolfogre.com>
2023-04-19 03:46:00 +00:00
Zettat123
06f19bc1da Support services (#42)
Replace #5

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/42
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
2023-04-19 11:23:28 +08:00
Shubh Bapna
b7905c0a84 feat: specify matrix on command line (#1675)
* added matrix option

* select the correct subset of matrix configuration after producing all the matrix configuration

* add tests

* update readme

* lint fix

* remove matrix from readme

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-03-19 17:25:55 +00:00
ChristopherHX
b2784e3104 test: Enshure ForcePull config doesn't break docker actions (1661) 2023-03-08 14:57:49 +00:00
ChristopherHX
606fd4bde1 fix: crash malformed composite action (#1616)
* fix: crash malformed composite action

* Add remote composite action test

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-02-23 22:16:07 +00:00
Josh Soref
bfe9d9f671 fix: tolerate workflow that needs a missing job (#1595) (#1619)
Change planner functions to return errors

This enables createStages to return `unable to build dependency graph`

Fix PlanEvent to properly report errors relating to events/workflows
2023-02-16 16:41:59 +00:00
ChristopherHX
02e21de560 refactor: GITHUB_ENV command / remove env.PATH (#1503)
* fix: GITHUB_ENV / PATH handling

* apply workaround

* add ctx to ApplyExtraPath

* fix: Do not leak step env in composite

See https://github.com/nektos/act/pull/1585 for a test

* add more tests

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-02-04 13:35:13 +00:00
ChristopherHX
4dd6cc3986 test: Do not leak step env in composite (#1585)
* test: Do not leak step env in composite

To prevent merging regressions.

* Update runner_test.go
2023-01-29 14:47:56 +00:00
Markus Wolf
67bb697055 feat: add remote reusable workflows (#1525)
* feat: add remote reusable workflows

This changes adds cloning of a remote repository to
run a workflow included in it.

Closes #826

* fix: defer plan creation until clone is done

We need wait for the full clone (and only clone once)
before we start to plan the execution for a remote workflow

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-19 20:49:11 +00:00
Shubh Bapna
409d161ed1 Input (#1524)
* added input flags

* added input as part of the action event and added test cases

* updated readme

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
2023-01-13 19:28:17 +00:00
ChristopherHX
fd250664e3 fix: extra path lost in composite actions (#1531)
* test: define test case of path issues

Test case for #1528

* test: add multi arch grep

* fix: Always use current ExtraPath

* replace setup-node with run step

* Update push.yml

* yaml mistake

Co-authored-by: Markus Wolf <mail@markus-wolf.de>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-10 21:55:05 +00:00
Markus Wolf
f4c69c8b84 fix: preserve job result state in case of failure (#1519)
* fix: preserve job result state in case of failure

There is just one job field for the job result. This is also true for
matrix jobs. We need to preserve the failure state of a job to
have the whole job failing in case of one permuation of the matrix failed.

Closes #1518

* test: remove continue-on-error on job level

This feature is not yet supported by act and if implemented
would make this test invalid

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-10 21:31:12 +00:00
Aaron Holmes
5f0cee8ce1 feat: Support "result" on "needs" context. (#1497)
* Support "result" on "needs" context.

This change adds "result" to a job's "needs" context, as documented [here](https://docs.github.com/en/actions/learn-github-actions/contexts#needs-context). `act` currently tracks the success/failure/cancelled status of a job, but does not include this value the `needs` context.

Fixes #1367

* Change `Needs` to use a new struct rather than the open type `interface{}`.

Related #1497
Fixes #1367

* Add integration test to "needs" context change.

Relates: #1497

* 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>

* refactor: fix savestate in pre steps (#1466)

* refactor: fix savestate in pre steps

* fix pre steps collision

* fix tests

* remove

* enable tests

* Update pkg/runner/action.go

* Rename InterActionState to IntraActionState

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* fix: tail (not absolute) as entrypoint of job container (#1506)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

* Fix conflict in merge.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-12-19 08:37:53 +00:00
Markus Wolf
67aa596008 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
ChristopherHX
84b6e863ef feat: JobLoggerFactory (#1496)
Remove overriding io.Stdout in TestMaskValues to prevent deadlock in GitHub Actions
2022-12-09 10:25:32 +00:00
ChristopherHX
68e74447c3 fix: step env is unavailable in with property expr (#1458)
* fix: step env is unavailable in with property expr

* don't run the test on windows

* fix: composite action add missing shell

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-12-06 16:46:20 +00:00
ChristopherHX
1441baa591 refactor: share UpdateFromEnv logic (#1457)
* refactor: share UpdateFromEnv logic

* Add test for GITHUB_OUTPUT

Co-authored-by: Ben Randall <veleek@gmail.com>

* Add GITHUB_STATE test

* Add test for the old broken parser

Co-authored-by: Ben Randall <veleek@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-12-06 16:19:27 +00:00
ChristopherHX
ab1deb20a5 feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
ChristopherHX
d72ce8baa1 fix: nil pointer access ( workflow_dispatch ) 2022-11-10 20:16:00 +00:00
Markus Wolf
9abdd7f050 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