yunohost-ci/README.md

76 lines
3.3 KiB
Markdown
Raw Normal View History

2019-12-01 04:51:11 +01:00
# YunoHost-CI: Gitlab runner for YunoHost Core
## Introduction
`yunohost-ci` is a [custom executor](https://docs.gitlab.com/runner/executors/custom.html) for [Gitlab Runner](https://docs.gitlab.com/runner/).
It uses LXD/LXC environment to run tests on YunoHost Core. Tests must be written in file [`.gitlab-ci.yml`](https://docs.gitlab.com/ee/ci/yaml/) on each YunoHost Core repository to test.
## Setup `YunoHost-CI`
First you need to install the system dependencies.
`yunohost-ci` essentially requires Git and the LXD/LXC ecosystem.
For Gitlab Runner, you can find doc [here](https://docs.gitlab.com/runner/install/linux-repository.html). On Debian-based system, you can add GitLabs official repository:
2024-03-10 20:54:09 +01:00
2019-12-01 04:51:11 +01:00
```bash
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
```
Then install Gitlab Runner (min version: 12.1):
2024-03-10 20:54:09 +01:00
2019-12-01 04:51:11 +01:00
```bash
sudo apt-get install gitlab-runner
```
2024-03-10 20:54:09 +01:00
Then follow this doc to install incus on your system: <https://linuxcontainers.org/incus/docs/main/installing/#install-incus-from-a-package>
2019-12-01 04:51:11 +01:00
2024-03-10 20:54:09 +01:00
Then you shall initialize incus which will ask you several questions. Usually answering the default (just pressing enter) to all questions is fine. ([doc](https://linuxcontainers.org/incus/docs/main/howto/initialize/))
2019-12-01 04:51:11 +01:00
```bash
2024-03-10 20:54:09 +01:00
sudo incus admin init
2019-12-01 04:51:11 +01:00
```
## Register `YunoHost-CI`
To use this runner, you must register the Gitlab Runner that you just installed (you can register in on several projects, or on the group that contains all projects). But, you have to **disable the shared runner** to only use this runner and not "Official" that is using a docker executor.
You can follow this [official doc](https://docs.gitlab.com/runner/register/) to register it. The only think to change is the point number 6, where you have to choose `custom`.
After that, clone this repo where you want, and be sure that scripts `base.sh` `cleanup.sh` `prepare.sh` and `run.sh` have the execution permission.
Finally, edit the file `/etc/gitlab-runner/config.toml` to add `builds_dir`, `cache_dir`, and all the `[runners.custom]` section. Your file should looks like this:
```toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "yunohost-ci"
url = "https://gitlab.com/" # Gitlab URL
token = "[SECRET-TOKEN]" # Very private token
executor = "custom"
builds_dir = "/builds" # Will be created if doesn't exist
cache_dir = "/cache" # Will be created if doesn't exist
[runners.custom]
prepare_exec = "/opt/yunohost-ci/prepare.sh" # Path to a bash script to create lxd container and download dependencies.
run_exec = "/opt/yunohost-ci/run.sh" # Path to a bash script to run script inside the container.
cleanup_exec = "/opt/yunohost-ci/cleanup.sh" # Path to bash script to delete container.
[runners.custom_build_dir]
enabled = true
2019-12-01 04:51:11 +01:00
```
2019-12-23 13:38:26 +01:00
## Using images
2019-12-01 04:51:11 +01:00
2020-05-20 16:00:16 +02:00
Use the field `image` to switch between `before-install` or `after-install` (`after-install` by default) for example:
- `image: after-install` to use the image after the postinstall of Yunohost
2020-03-20 00:07:36 +01:00
- `image: before-install` to use the image before the installation of YunoHost
2019-12-01 04:51:11 +01:00
## TODO
2019-12-01 04:59:05 +01:00
- Support more YunoHost Core projects (for now only `yunohost` is supported, not `moulinette`...)
2019-12-01 04:51:11 +01:00
- Git pull this repo before running tests to keep these files up-to-date.