Commit graph

165 commits

Author SHA1 Message Date
Jason Song
7c1801b302
Config for container network (#96)
Fix #66

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/96
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-04-05 00:53:35 +02:00
Jason Song
c817236aa4
Refactor environment variables to configuration and registration (#90)
Close #21.

Refactor environment variables to configuration file (config.yaml) and registration file (.runner).

The old environment variables are still supported, but warning logs will be printed.

Like:

```text
$ GITEA_DEBUG=true ./act_runner -c config.yaml daemon
INFO[0000] Starting runner daemon
WARN[0000] env GITEA_DEBUG has been ignored because config file is used

$ GITEA_DEBUG=true ./act_runner daemon
INFO[0000] Starting runner daemon
WARN[0000] env GITEA_DEBUG will be deprecated, please use config file instead
```

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/90
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-04-05 00:53:35 +02:00
telackey
028451bf22
Add CLI flag for specifying the Docker image to use. (#83)
Since the `exec` command does not use labels from `.runner`, there is no existing way to specify which Docker image to use for task execution.

This adds an `--image` flag for specifying it manually.  The default remains `node:16-bullseye`.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/83
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: telackey <telackey@noreply.gitea.io>
Co-committed-by: telackey <telackey@noreply.gitea.io>
2023-04-05 00:53:35 +02:00
Lunny Xiao
0d33f8f520
handle possible panic (#88)
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/88
Reviewed-by: Jason Song <i@wolfogre.com>
2023-04-05 00:53:35 +02:00
Zettat123
63c1734bb5
Fix potential log panic (#82)
If a job uses a [reusable workflow](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-of-jobsjob_iduses), the job's steps sequence will be empty.

But in log reporter, we don't check the length of `r.state.Steps`, which may cause panic.

``` go
if v, ok := entry.Data["stepNumber"]; ok {
	if v, ok := v.(int); ok {
		step = r.state.Steps[v]
	}
}
```

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/82
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
2023-04-05 00:53:35 +02:00
Jason Song
3d78433564
Get outbound IP in multiple ways or disable cache server if failed to init (#74)
Fix #64 (incompletely).

It's still not ideal. It makes more sense to use the gateway IP address of container network as outbound IP of cache server. However, this requires act to cooperate, some think like:

- act creates the network for new container, and returns the network to runner.
- runner extracts the gateway IP in the network.
- runner uses the gateway IP as outbound IP, and pass it to act as cache server endpoint.
- act It continues to create the container with the created network.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/74
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-04-05 00:53:35 +02:00
Jason Song
3463f94119
Vet code (#73)
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/73
2023-04-05 00:53:35 +02:00
Jason Song
616ad7c96a
Clarify labels (#69)
The label will follow the format `label[:schema[:args]]`, and the schema will be `host` if it's omitted. So

- `ubuntu:docker://node:18`: Run jobs with label `ubuntu` via docker with image `node:18`
- `ubuntu:host`: Run jobs with label `ubuntu` on the host directly.
- `ubuntu`: Same as `ubuntu:host`.
- `ubuntu:vm:ubuntu-latest`: (Just a example, not Implemented) Run jobs with label `ubuntu` via virtual machine with iso `ubuntu-latest`.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/69
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io>
Reviewed-by: wxiaoguang <wxiaoguang@noreply.gitea.io>
2023-04-05 00:53:35 +02:00
earl-warren
8d8a11052a Merge pull request 'the test workflow is not meant to release' (#20) from earl-warren/runner:wip-release into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/20
Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
2023-04-04 12:44:31 +00:00
Earl Warren
bd439537ba
the test workflow is not meant to release 2023-04-04 14:39:53 +02:00
earl-warren
75c1f66a12 Merge pull request 'sync with act 1.3.0' (#19) from earl-warren/runner:wip-sync into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/19
Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
2023-04-04 10:42:35 +00:00
Earl Warren
0125f1302a
a change in dependencies requires and integration test 2023-04-04 12:28:37 +02:00
Earl Warren
45fcb8164f
remove restriction to run unit tests on main 2023-04-04 12:25:36 +02:00
Earl Warren
419989c422
sync with act 1.3.0 2023-04-04 12:20:22 +02:00
earl-warren
9a6cae89e7 Merge pull request 'keep .git on build to extract version from tag' (#15) from earl-warren/runner:wip-release into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/15
Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
2023-04-03 15:14:31 +00:00
Earl Warren
56909d2f20
keep .git on build to extract version from tag
Otherwise the version is empty and --version does not work

Fixes: https://code.forgejo.org/forgejo/runner/issues/14
2023-04-03 16:57:27 +02:00
earl-warren
0048a1dfbc Merge pull request 'workflows to publish the release' (#11) from earl-warren/runner:wip-release into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/11
2023-04-03 11:56:29 +00:00
Earl Warren
93978d8ec0
release integration tests 2023-04-03 10:50:36 +02:00
Earl Warren
8834728285
build static binaries 2023-04-03 01:13:33 +02:00
Earl Warren
70d68a491d
publish release 2023-04-03 01:13:33 +02:00
Earl Warren
a06bc05fd1
run tests on pull requests and when pushing to main 2023-04-02 21:04:24 +02:00
earl-warren
499ee80e57 Merge pull request 'Use go 1.19' (#6) from crystal/runner:pr-go119 into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/6
2023-03-23 07:05:12 +00:00
crystal
ceb20b868f
Use go 1.19 2023-03-23 00:12:43 -06:00
earl-warren
d8481f6b1d Merge pull request 'default actions URL is code.forgejo.org' (#2) from earl-warren/runner:wip-default-actions into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/2
2023-03-18 20:05:25 +00:00
Earl Warren
905fb5255d
default actions URL is code.forgejo.org 2023-03-18 13:21:54 +01:00
earl-warren
634846e944 Merge pull request 'cherry-pick some commits from gitea/act_runner' (#1) from earl-warren/runner:wip-sync into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1
2023-03-18 09:25:55 +00:00
Earl Warren
3601466dcf
upgrade act v1.2.0 2023-03-18 09:57:18 +01:00
Jason Song
df4bfdc0d3
Update act to v0.243 (#54)
- Update act to v0.243.1
- Disable artifacts server when run daemon.
- Adjust cmd.

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/54
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io>
2023-03-18 09:54:13 +01:00
Lunny Xiao
154555e912
check go version when build (#53)
Fix #51

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/53
2023-03-16 16:58:13 +01:00
Lunny Xiao
3cc7e8f052
Support cache on ci (#47)
Fix #46

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/47
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-16 16:56:03 +01:00
sillyguodong
0026306515
Print the kind of event that trigger the actions (#48)
![image](/attachments/28a866c6-3134-477d-a8c8-d624fa90db0b)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/48
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-committed-by: sillyguodong <gedong_1994@163.com>
2023-03-16 16:54:46 +01:00
Lunny Xiao
6c7b07be60
Fix make don't rebuild when go.mod changed (#49)
Fix #13

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/49
Reviewed-by: delvh <dev.lh@web.de>
2023-03-16 16:54:37 +01:00
sillyguodong
0445675a10
Inject version when building and report version to Gitea via log and header (#43)
close #42
1. Inject runner version when `make build`
After building, executing command line: `./act_runner -v` or `./act_runner --version`, the version of runner is printed.
![image](/attachments/e25efbd3-79b3-49a5-b93f-42646d42c707)

2. In `Actions` UI:
![image](/attachments/36c57470-2a1d-4796-9eb0-de3988ab88e1)

3. Set request header in http client interceptor.

Co-authored-by: sillyguodong <gedong_1994@163.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/43
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: sillyguodong <sillyguodong@noreply.gitea.io>
Co-committed-by: sillyguodong <sillyguodong@noreply.gitea.io>
2023-03-16 16:53:44 +01:00
earl-warren
b202c62bf7 Merge pull request 'upgrade to codeberg.org/forgejo/act v1.1.0' (#1) from wip-act-upgrade into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1
2023-03-11 14:51:11 +00:00
Earl Warren
49f9622eca
upgrade to codeberg.org/forgejo/act v1.1.0 2023-03-11 15:24:54 +01:00
Earl Warren
e160695183 Merge pull request 'run in daemon mode by default' (#8) from earl-warren/runner:wip-daemon into main
Reviewed-on: https://codeberg.org/forgejo/runner/pulls/8
2023-03-09 22:56:28 +00:00
Earl Warren
b685c432d4 Merge pull request 'define FORGEJO_RUNNER_FILE' (#7) from earl-warren/runner:wip-configfile into main
Reviewed-on: https://codeberg.org/forgejo/runner/pulls/7
2023-03-09 22:56:17 +00:00
Earl Warren
132b318d8b
run in daemon mode by default 2023-03-09 18:40:19 +01:00
Earl Warren
a02fbdc7af
define FORGEJO_RUNNER_FILE 2023-03-09 18:25:54 +01:00
Loïc Dachary
1bb87d0ebb Merge pull request 'cherry-pick some changes from the gitea repository' (#6) from earl-warren/runner:wip-sync into main
Reviewed-on: https://codeberg.org/forgejo/runner/pulls/6
2023-03-08 14:15:12 +00:00
HesterG
048b2e630f
Fix wrong last step duration when job failed (#41)
This PR is to fix the wrong last step duration when job failed like shown in the screenshot.
The reason is because when job failed, `Fire` function did not pass in Time, and `r.state.StoppedAt` is by default set to `0001-01-01 08:05:43 +0805 LMT`, which is later on reported to gitea by `UpdateTask`, which calls `UpdateTaskByState` to update the `task.Stopped`, and `task.Stopped` is used in `FullSteps`, resulting in wrong calcaulation of last step duration.

Co-authored-by: nickname <test@123.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/41
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: HesterG <hesterg@noreply.gitea.io>
Co-committed-by: HesterG <hesterg@noreply.gitea.io>
2023-03-08 15:07:09 +01:00
Earl Warren
40954c450d
.gitignore forgejo-runner 2023-03-08 15:02:28 +01:00
Earl Warren
4d5007a333
s/gitea/forgejo/ for exec 2023-03-08 15:01:49 +01:00
a1012112796
65d2485f58
Add exec subcommand for runner so that we can run the tasks locally(#39)
Most codes are copied from https://gitea.com/gitea/act/src/branch/main/cmd
and do some small changes to make it run again

examples:

```SHELL
./act_runner exec -l
./act_runner exec -j lint
./act_runner exec -j lint -n
```

some example result:

![屏幕截图 2023-03-06 135735](/attachments/547bd05c-ade2-41f7-ba60-c9937fa32d5f)

![屏幕截图 2023-03-06 140643](/attachments/e8f48dba-c7f3-4daa-a163-aa9b36b1dc32)

Signed-off-by: a1012112796 <1012112796@qq.com>

fix #32

Reviewed-on: https://gitea.com/gitea/act_runner/pulls/39
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-committed-by: a1012112796 <1012112796@qq.com>
2023-03-08 14:59:52 +01:00
Zettat123
ba181d4a50
Add runner name to log (#37)
User can get the name of the runner that executed the specified job.
![image](/attachments/61328f68-7223-4345-85c7-ac08781e81db)

Co-authored-by: Zettat123 <zettat123@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/37
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@noreply.gitea.io>
Co-committed-by: Zettat123 <zettat123@noreply.gitea.io>
2023-03-08 14:58:59 +01:00
ChristopherHX
cbf360f543
fix docker executor on windows and local actions (#34)
If the Workdir field doesn't ends with the filepath seperator,
bad things happen

Fixes #33

Sample for host mode on windows, needs be adjusted for linux e.g. replace pwsh with bash
Also fixes
```yaml
on: push
jobs:
  _:
    runs-on: self-hosted
    steps:
    - uses: actions/checkout@v3
      with:
        path: subdir/action
    - uses: ./subdir/action
```

with an action.yml in the same repo
```yaml
runs:
  using: composite
  steps:
    - run: |
        echo "Hello World"
      shell: pwsh
```

Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/34
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: ChristopherHX <christopherhx@noreply.gitea.io>
Co-committed-by: ChristopherHX <christopherhx@noreply.gitea.io>
2023-03-08 14:58:04 +01:00
Earl Warren
8833fca093
trigger the build 2023-03-01 00:32:50 +01:00
Earl Warren
7aaa64a648 Merge pull request 'run test from Actions' (#3) from earl-warren/runner:wip-test into main
Reviewed-on: https://codeberg.org/forgejo/runner/pulls/3
2023-02-28 23:24:31 +00:00
Earl Warren
9213f7dc62
run test from Actions 2023-03-01 00:10:02 +01:00
Earl Warren
af6fea7b97 Merge pull request 'Further rebranding to Forgejo' (#2) from crystal/runner:rebrand into main
Reviewed-on: https://codeberg.org/forgejo/runner/pulls/2
2023-02-28 23:09:48 +00:00