Continuous Integration for GNU Mailman
This page describes how to continuous integration server for GNU Mailman actually works. It uses gitlab-runner to run tests inside a docker container. The dockerfile for the container running the tests is here.
Testing Configurations
These are the configurations used for testing mailman with different databases. These are the two configuration files that are to be put up at /srv/gitlab-runner/config/
# mysql.cfg [database] class: mailman.database.mysql.MySQLDatabase url: mysql+mysqldb://root:<$mysql_root_passwd>@mysql/test_mailman?charset=utf8&use_unicode=1 # postgres.cfg [database] class: mailman.database.postgresql.PostgreSQLDatabase url: postgres://postgres:@postgres/mailman_test
Setup CI
First, spin up a mysql container, set the root password and set the default collate on the database we are trying to use.
$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=<$mysql_root_passwd> -e MYSQL_DATABASE=test_mailman --restart always -d mysql:latest $ docker exec mysql mysql -uroot -proot --database=test_mailman --execute="ALTER DATABASE test_mailman DEFAULT COLLATE utf8_unicode_ci;"
Now setup postgres database with a database and no password; default user is postgres without any password.
$ docker run --name postgres -e POSTGRES_DB=test_mailman --restart always -d postgres:latest
Start a container running the gitlab ci runner inside a docker container and mount the docker socket, configuration directory. More information about here can be found here: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/docker.md
$ docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:latest
Register the gitlab runner with the project. The following values should be filled up.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci ) https://gitlab.com/ci Please enter the gitlab-ci token for this runner xxx Please enter the gitlab-ci description for this runner docker-sqlite Please enter the gitlab-ci tags for this runner (comma separated): sqlite INFO[0034] fcf5c619 Registering runner... succeeded Please enter the executor: shell, docker, docker-ssh, ssh? docker-ssh Please enter the Docker image (eg. ruby:2.1): maxking/mailman-runner If you want to enable mysql please enter version (X.Y) or enter latest? If you want to enable postgres please enter version (X.Y) or enter latest? If you want to enable redis please enter version (X.Y) or enter latest? If you want to enable mongo please enter version (X.Y) or enter latest? Please enter the SSH user (eg. root): runner Please enter the SSH password (eg. docker.io): runner Please enter path to SSH identity file (eg. /home/user/.ssh/id_rsa): INFO[0091] Runner registered successfully.
Feel free to start it, but if it's running already the config should be automatically reloaded!
$ docker exec -it gitlab-runner gitlab-runner register
It would be nice if three different runners are started so that each one handles one kind of database. To do that, run the above command three times with different tags namely, "sqlite", "postgres" and "mysql".
After that edit the configuration file generated at /srv/gitlab-runner/config/config.toml to look something like below:
config.toml concurrent = 4 [[runners]] url = "https://gitlab.com/ci" token = "<token>" tls-skip-verify = false tls-ca-file = "" name = "docker-postgres" limit = 1 executor = "docker-ssh" [runners.ssh] user = "runner" password = "runner" [runners.docker] image = "maxking/mailman-runner" privileged = false volumes = ["/cache", "/srv/gitlab-runner/config:/data"] links = ["postgres:postgres"] [[runners]] url = "https://gitlab.com/ci" token = "<token>" tls-skip-verify = false tls-ca-file = "" name = "docker-sqlite" limit = 0 executor = "docker-ssh" [runners.ssh] user = "runner" password = "runner" [runners.docker] image = "maxking/mailman-runner" privileged = false volumes = ["/cache"] [[runners]] url = "https://gitlab.com/ci" token = "<token>" tls-skip-verify = false tls-ca-file = "" name = "docker-mysql" executor = "docker-ssh" [runners.ssh] user = "runner" password = "runner" [runners.docker] image = "maxking/mailman-runner" privileged = false volumes = ["/cache", "/srv/gitlab-runner/config:/data"] links = ["mysql:mysql"]
Update the CI runner
There are instructions here. Basically run these commands
$ docker stop gitlab-runner && docker rm gitlab-runner $ docker pull gitlab/gitlab-runner $ docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:latest
Common Problems
These are some common problems that I have seen while maintaining the CI server for mailman.
1. CI server is up but the builds are still not running.
There has been several occasions when this happened, sometimes it just worked after restarting the docker in the server using 'sudo service docker restart'. Other times it was because of some unknown updates from gitlab to the CI framework as we are using https://gitlab.com.