forgejo-runner

git clone git://git.lin.moe/forgejo-runner.git

 1# Forgejo Runner
 2
 3**WARNING:** this is [alpha release quality](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha) code and should not be considered secure enough to deploy in production.
 4
 5A daemon that connects to a Forgejo instance and runs jobs for continous integration. The [installation and usage instructions](https://forgejo.org/docs/next/admin/actions/) are part of the Forgejo documentation.
 6
 7# Reporting bugs
 8
 9When filing a bug in [the issue tracker](https://code.forgejo.org/forgejo/runner/issues), it is very helpful to propose a pull request [in the end-to-end tests](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions) repository that adds a reproducer. It will fail the CI and unambiguously demonstrate that the problem exists. In most cases it is enough to add a workflow ([see the echo example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-echo)). For more complicated cases it is also possible to add a runner config file as well as shell scripts to setup and teardown the test case ([see the service example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-service)).
10
11# Hacking
12
13The Forgejo runner depends on [a fork of ACT](https://code.forgejo.org/forgejo/act) and is a dependency of the [setup-forgejo action](https://code.forgejo.org/actions/setup-forgejo). See [the full dependency graph](https://code.forgejo.org/actions/cascading-pr/#forgejo-dependencies) for a global view.
14
15## Local debug
16
17The repositories are checked out in the same directory:
18
19- **runner**: [Forgejo runner](https://code.forgejo.org/forgejo/runner)
20- **act**: [ACT](https://code.forgejo.org/forgejo/act)
21- **setup-forgejo**: [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo)
22
23### Install dependencies
24
25The dependencies are installed manually or with:
26
27```shell
28setup-forgejo/forgejo-dependencies.sh
29```
30
31### Build the Forgejo runner with the local ACT
32
33The Forgejo runner is rebuilt with the ACT directory by changing the `runner/go.mod` file to:
34
35```
36replace github.com/nektos/act => ../act
37```
38
39Running:
40
41```
42cd runner ; go mod tidy
43```
44
45Building:
46
47```shell
48cd runner ; rm -f forgejo-runner ; make forgejo-runner
49```
50
51### Launch Forgejo and the runner
52
53A Forgejo instance is launched with:
54
55```shell
56cd setup-forgejo
57./forgejo.sh setup
58firefox $(cat forgejo-url)
59```
60
61The user is `root` with password `admin1234`. The runner is registered with:
62
63```
64cd setup-forgejo
65docker exec --user 1000 forgejo forgejo actions generate-runner-token > forgejo-runner-token
66../runner/forgejo-runner register --no-interactive --instance "$(cat forgejo-url)" --name runner --token $(cat forgejo-runner-token) --labels docker:docker://node:20-bullseye,self-hosted:host://-self-hosted,lxc:lxc://debian:bullseye
67```
68
69And launched with:
70
71```shell
72cd setup-forgejo ; ../runner/forgejo-runner --config runner-config.yml daemon
73```
74
75Note that the `runner-config.yml` is required in that particular case
76to configure the network in `bridge` mode, otherwise the runner will
77create a network that cannot reach the forgejo instance.
78
79### Try a sample workflow
80
81From the Forgejo web interface, create a repository and add the
82following to `.forgejo/workflows/try.yaml`. It will launch the job and
83the result can be observed from the `actions` tab.
84
85```yaml
86on: [push]
87jobs:
88  ls:
89    runs-on: docker
90    steps:
91      - uses: actions/checkout@v3
92      - run: |
93          ls ${{ github.workspace }}
94```