2023-10-28 22:29:04 +02:00
|
|
|
# Forgejo end-to-end tests
|
|
|
|
|
|
|
|
A series of tests scenarios and assertions covering
|
|
|
|
[Forgejo](https://codeberg.org/forgejo/forgejo) and the [Forgejo
|
2024-05-22 11:07:45 +02:00
|
|
|
runner](https://code.forgejo.org/forgejo/runner).
|
2023-10-28 22:29:04 +02:00
|
|
|
|
|
|
|
They are designed to run using Forgejo releases and development
|
|
|
|
versions compiled from designated repositories.
|
2023-10-29 17:03:25 +01:00
|
|
|
|
2024-04-25 12:38:58 +02:00
|
|
|
# Removing legacy tests
|
|
|
|
|
2024-05-22 11:07:45 +02:00
|
|
|
End-to-end tests cover the supported range of releases and when one of
|
2024-04-25 12:38:58 +02:00
|
|
|
them is EOL, it must be removed as well as the tests that target it
|
|
|
|
specifically. Otherwise the test suite would grow indefinitely.
|
|
|
|
|
|
|
|
When a release is EOL, a branch is cut with a name following the
|
|
|
|
pattern `legacy/vX.Y-vA.B`. For instance when `v8.0` is published and
|
|
|
|
`v1.21` is EOL, the branch `legacy/v8.0-v1.21` is cut.
|
|
|
|
|
2024-01-24 00:03:34 +01:00
|
|
|
# Hacking
|
2023-10-29 17:03:25 +01:00
|
|
|
|
2024-01-24 00:03:34 +01:00
|
|
|
docker and sudo must be installed with insecure registries allowed in
|
|
|
|
/etc/docker/daemon.json for the IP that will be used for forgejo such
|
|
|
|
as:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-03-14 10:36:19 +07:00
|
|
|
"insecure-registries": [ "10.0.0.0/8" ]
|
2024-01-24 00:03:34 +01:00
|
|
|
}
|
2024-08-07 09:38:32 +02:00
|
|
|
```
|
2023-11-08 15:55:01 +01:00
|
|
|
|
2024-01-24 00:03:34 +01:00
|
|
|
Use setup-forgejo from source.
|
2023-11-08 15:55:01 +01:00
|
|
|
|
2024-02-03 19:40:42 +01:00
|
|
|
The [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo)
|
|
|
|
repository is a [Forgejo
|
2024-08-07 09:38:32 +02:00
|
|
|
Action](https://forgejo.org/docs/v7.0/user/actions/) which is meant
|
2024-02-03 19:40:42 +01:00
|
|
|
to be used in workflows. However, it is implemented as shell scripts that
|
|
|
|
can also be used to create Forgejo instances and runners locally. This
|
|
|
|
is convenient for testing and the reason why it needs to be added to the PATH.
|
2024-03-20 11:51:46 +01:00
|
|
|
For instance, it is a dependency of the `end-to-end.sh` script.
|
2024-02-03 19:40:42 +01:00
|
|
|
|
2023-11-08 15:55:01 +01:00
|
|
|
```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
|
|
|
|
```
|
2023-12-20 16:59:50 +01:00
|
|
|
|
2024-03-20 11:51:46 +01:00
|
|
|
## Running from locally built binary
|
2024-01-24 00:03:34 +01:00
|
|
|
|
|
|
|
```sh
|
|
|
|
make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo
|
2024-10-06 06:22:58 +02:00
|
|
|
cp -a forgejo /srv/forgejo-binaries/forgejo-10.0
|
2024-01-24 00:03:34 +01:00
|
|
|
```
|
|
|
|
|
2024-10-06 06:22:58 +02:00
|
|
|
It will be used whenever the version `10.0` is specified in a test.
|
2024-03-20 11:51:46 +01:00
|
|
|
|
2024-01-24 00:03:34 +01:00
|
|
|
## Running actions locally
|
|
|
|
|
|
|
|
To run and debug workflows from `actions/example-*`, from the root of
|
|
|
|
the source directory, with docker and forgejo-curl.sh installed, mimic
|
2024-10-06 06:22:58 +02:00
|
|
|
what `.forgejo/workflows/end-to-end.yml` does. There may be some manual
|
2024-01-24 00:03:34 +01:00
|
|
|
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.
|
|
|
|
|
2023-11-08 15:55:01 +01:00
|
|
|
```sh
|
2024-10-06 06:22:58 +02:00
|
|
|
./end-to-end.sh run dependencies
|
|
|
|
./end-to-end.sh actions_setup 10.0
|
2024-03-20 11:51:46 +01:00
|
|
|
firefox 0.0.0.0:3000 # user root / admin1234
|
2024-10-06 06:22:58 +02:00
|
|
|
./end-to-end.sh actions_verify_example echo
|
2024-03-20 11:51:46 +01:00
|
|
|
./end-to-end.sh actions_teardown
|
2023-11-08 15:55:01 +01:00
|
|
|
```
|
2024-03-15 14:34:55 +07:00
|
|
|
## Running other tests locally
|
2024-01-24 00:03:34 +01:00
|
|
|
|
2024-03-15 14:34:55 +07:00
|
|
|
To run and debug tests, from the root of the source directory.
|
2024-01-24 00:03:34 +01:00
|
|
|
|
2024-03-15 14:34:55 +07:00
|
|
|
Run one test. When the test fails the instance can be inspected at http://0.0.0.0:3000
|
2024-01-24 00:03:34 +01:00
|
|
|
|
|
|
|
```sh
|
2024-03-20 11:51:46 +01:00
|
|
|
./end-to-end.sh test_packages_alpine
|
|
|
|
./end-to-end.sh test_storage_stable_s3 minio
|
2024-01-24 00:03:34 +01:00
|
|
|
```
|
|
|
|
|
2024-03-15 14:34:55 +07:00
|
|
|
Cleanup. It will teardown the Forgejo instance.
|
2024-01-24 00:03:34 +01:00
|
|
|
|
|
|
|
```sh
|
2024-03-20 11:51:46 +01:00
|
|
|
./end-to-end.sh stop
|
2024-01-24 00:03:34 +01:00
|
|
|
```
|