|
2 | 2 |
|
3 | 3 | A daemon that connects to a Forgejo instance and runs jobs for continuous integration. The [installation and usage instructions](https://forgejo.org/docs/next/admin/actions/) are part of the Forgejo documentation. |
4 | 4 |
|
5 | | -# Reporting bugs |
6 | | - |
7 | | -When 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)). |
| 5 | +# Reporting security-related issues |
8 | 6 |
|
9 | 7 | Sensitive security-related issues should be reported to [[email protected]](mailto:[email protected]) using [encryption ](https://keyoxide.org/[email protected]). |
10 | 8 |
|
11 | | - |
12 | 9 | ## License |
13 | 10 |
|
14 | 11 | The Forgejo runner source code is distributed under the terms of the following licenses: |
@@ -36,77 +33,37 @@ The Forgejo runner is a dependency of the [setup-forgejo action](https://code.fo |
36 | 33 | - Install [Go](https://go.dev/doc/install) and `make(1)` |
37 | 34 | - `make build` |
38 | 35 |
|
39 | | -The [test workflow](.forgejo/workflows/test.yml) is a full example that builds the binary, runs the tests and launches the runner binary against a live Forgejo instance. |
40 | | - |
41 | | -## Generate mocks |
42 | | - |
43 | | -- `make deps-tools` |
44 | | -- `make generate` |
45 | | - |
46 | | -If there are changes, commit them to the repository. |
47 | | - |
48 | | -## Local debug |
49 | | - |
50 | | -The repositories are checked out in the same directory: |
51 | | - |
52 | | -- **runner**: [Forgejo runner](https://code.forgejo.org/forgejo/runner) |
53 | | -- **setup-forgejo**: [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo) |
54 | | - |
55 | | -### Install dependencies |
56 | | - |
57 | | -The dependencies are installed manually or with: |
| 36 | +## Linting |
58 | 37 |
|
59 | | -```shell |
60 | | -setup-forgejo/forgejo-dependencies.sh |
61 | | -``` |
62 | | - |
63 | | -### Build the Forgejo runner |
64 | | - |
65 | | -```shell |
66 | | -cd runner ; rm -f forgejo-runner ; make forgejo-runner |
67 | | -``` |
68 | | - |
69 | | -### Launch Forgejo and the runner |
| 38 | +- `make lint-check` |
| 39 | +- `make lint` # will fix some lint errors |
70 | 40 |
|
71 | | -A Forgejo instance is launched with: |
| 41 | +## Testing |
72 | 42 |
|
73 | | -```shell |
74 | | -cd setup-forgejo |
75 | | -./forgejo.sh setup |
76 | | -firefox $(cat forgejo-url) |
77 | | -``` |
| 43 | +The [workflow](.forgejo/workflows/test.yml) that runs in the CI uses similar commands. |
78 | 44 |
|
79 | | -The user is `root` with password `admin1234`. The runner is registered with: |
| 45 | +### Without a Forgejo instance |
80 | 46 |
|
81 | | -``` |
82 | | -cd setup-forgejo |
83 | | -docker exec --user 1000 forgejo forgejo actions generate-runner-token > forgejo-runner-token |
84 | | -../runner/forgejo-runner register --no-interactive --instance "$(cat forgejo-url)" --name runner --token $(cat forgejo-runner-token) --labels docker:docker://node:22-bookworm,self-hosted:host,lxc:lxc://debian:bookworm |
85 | | -``` |
| 47 | +- Install [Docker](https://docs.docker.com/engine/install/) |
| 48 | +- `make test integration-test` |
86 | 49 |
|
87 | | -And launched with: |
88 | | - |
89 | | -```shell |
90 | | -cd setup-forgejo ; ../runner/forgejo-runner --config runner-config.yml daemon |
91 | | -``` |
| 50 | +### With a Forgejo instance |
92 | 51 |
|
93 | | -Note that the `runner-config.yml` is required in that particular case |
94 | | -to configure the network in `bridge` mode, otherwise the runner will |
95 | | -create a network that cannot reach the forgejo instance. |
96 | | - |
97 | | -### Try a sample workflow |
98 | | - |
99 | | -From the Forgejo web interface, create a repository and add the |
100 | | -following to `.forgejo/workflows/try.yaml`. It will launch the job and |
101 | | -the result can be observed from the `actions` tab. |
102 | | - |
103 | | -```yaml |
104 | | -on: [push] |
105 | | -jobs: |
106 | | - ls: |
107 | | - runs-on: docker |
108 | | - steps: |
109 | | - - uses: actions/checkout@v4 |
110 | | - - run: | |
111 | | - ls ${{ github.workspace }} |
| 52 | +- Run a Forgejo instance locally (for instance at http://0.0.0.0:8080) and create as shared secret |
| 53 | +```sh |
| 54 | +export FORGEJO_RUNNER_SECRET='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' |
| 55 | +export FORGEJO_URL=http://0.0.0.0:8080 |
| 56 | +forgejo forgejo-cli actions register --labels docker --name therunner --secret $FORGEJO_RUNNER_SECRET |
112 | 57 | ``` |
| 58 | +- `make test integration-test` # which will run addional tests because FORGEJO_URL is set |
| 59 | + |
| 60 | +### end-to-end |
| 61 | + |
| 62 | +- Follow the instructions from the end-to-end tests to [run actions tests locally](https://code.forgejo.org/forgejo/end-to-end#running-from-locally-built-binary). |
| 63 | +- `./end-to-end.sh actions_teardown` # stop the Forgejo and runner daemons running in the end-to-end environment |
| 64 | +- `( cd ~/clone-of-the-runner-repo ; make build ; cp forgejo-runner /tmp/forgejo-end-to-end/forgejo-runner )` # install the runner built from sources |
| 65 | +- `./end-to-end.sh actions_setup 13.0` # start Forgejo v13.0 and the runner daemon in the end-to-end environment |
| 66 | +- `./end-to-end.sh actions_verify_example echo` # run the [echo workflow](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-echo/.forgejo/workflows/test.yml) |
| 67 | +- `xdg-open http://127.0.0.1:3000/root/example-echo/actions/runs/1` # see the logs workflow |
| 68 | +- `less /tmp/forgejo-end-to-end/forgejo-runner.log` # analyze the runner logs |
| 69 | +- `less /tmp/forgejo-end-to-end/forgejo-work-path/log/forgejo.log` # analyze the Forgejo logs |
0 commit comments