update hacking instructions

This commit is contained in:
username 2023-11-08 15:55:01 +01:00
parent b5c5c6b4d5
commit 2db61b4f50
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -12,25 +12,39 @@ versions compiled from designated repositories.
## Hacking
### Local testing
To run and debug workflows from `actions/example-*`, from the root of
the source directory, with docker and forgejo-curl.sh installed, mimic
what `.forgejo/workflows/actions.yml` does. There may be some manual
tweaking (such as creating temporary directories) because the tests
run as root in the context of Forgejo Actions and assume they have
admin permissions. But they do not need to run as root and must work
fine when run as a regular user.
To run and debug workflows from `actions/example-*`, from
the root of the source directory, with docker and forgejo-curl.sh
installed, mimic what `.forgejo/workflows/actions.yml` does. There
may be some manual tweaking (such as creating temporary directories)
because the tests run as root, but they do not need to run as root.
### Prepare the Forgejo instance and the runner
* `forgejo-curl.sh logout`
* `forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.21`
* `firefox http://$(cat forgejo-ip):3000`
* `forgejo-runner.sh setup`
* `export example=pull-request`
* `export EXAMPLE_DIR=$(pwd)/actions/example-$example`
* `$EXAMPLE_DIR/setup.sh` # if it exists
* `$EXAMPLE_DIR/run.sh` or
* `forgejo-test-helper.sh run_workflow actions/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)`
* `forgejo-runner.sh teardown`
* `forgejo.sh teardown`
```sh
git clone https://code.forgejo.org/actions/setup-forgejo
export PATH=$(pwd)/setup-forgejo:$PATH
git clone https://code.forgejo.org/forgejo/end-to-end
cd end-to-end
forgejo-curl.sh logout
forgejo-runner.sh teardown
forgejo.sh teardown
forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.21
forgejo-runner.sh setup
export url=http://root:admin1234@$(cat forgejo-ip):3000
export token=$(cat forgejo-token)
```
### Run a single test
```sh
export example=pull-request
export EXAMPLE_DIR=$(pwd)/actions/example-$example
sudo rm -fr /srv/example-$example ; mkdir /srv/example-$example
$EXAMPLE_DIR/setup.sh
$EXAMPLE_DIR/run.sh
forgejo-test-helper.sh run_workflow actions/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)
```
### Remote testing