Files
ortools-clone/cmake/docs/ci.md

104 lines
2.3 KiB
Markdown
Raw Normal View History

2020-09-23 14:50:07 +02:00
# CI: Makefile/Docker/Vagrant testing
2022-03-24 17:19:17 +01:00
To test the build on various distro, I'm using docker containers and a Makefile
for orchestration.
2020-03-30 12:48:21 +02:00
pros:
2022-03-24 17:19:17 +01:00
2022-04-13 11:47:09 +02:00
* You are independent of third party CI runner VM images (e.g. [github actions/virtual-environments](https://github.com/actions/virtual-environments)).
* You can run it locally on any host having a linux docker image support.
* Most CI provide runner with docker and Makefile installed.
2020-03-30 12:48:21 +02:00
cons:
2022-03-24 17:19:17 +01:00
2020-03-30 12:48:21 +02:00
* Only GNU/Linux distro supported.
* Could take few GiB (~30 GiB for all distro and all languages)
* ~500MiB OS + C++/CMake tools,
* ~150 MiB Python,
* ~400 MiB dotnet-sdk,
* ~400 MiB java-jdk.
2022-03-24 17:19:17 +01:00
## Usage
2020-03-30 12:48:21 +02:00
To get the help simply type:
2022-03-24 17:19:17 +01:00
2020-03-30 12:48:21 +02:00
```sh
make
```
note: you can also use from top directory
2022-03-24 17:19:17 +01:00
2020-03-30 12:48:21 +02:00
```sh
make --directory=cmake
2020-03-30 12:48:21 +02:00
```
2022-03-24 17:19:17 +01:00
### Example
2020-03-30 12:48:21 +02:00
For example to test `Python` inside an `Alpine` container:
2022-03-24 17:19:17 +01:00
2020-03-30 12:48:21 +02:00
```sh
make alpine_python_test
2020-03-30 12:48:21 +02:00
```
2022-03-24 17:19:17 +01:00
## Docker
2020-09-23 17:42:01 +02:00
[Docker](https://www.docker.com/resources/what-container) is a set of platform
as a service products that use OS-level virtualization to deliver software in
packages called containers.
You can find official base image on the Docker registry [Docker Hub](https://hub.docker.com/search?type=image)
2020-03-30 12:48:21 +02:00
2022-03-24 17:19:17 +01:00
### Layers
Dockerfile is split in several stages.
2020-03-30 12:48:21 +02:00
![docker](docker.svg)
2020-09-23 14:50:07 +02:00
2022-03-24 17:19:17 +01:00
## Vagrant
[Vagrant](https://www.vagrantup.com/intro) is a tool for building and managing
virtual machine environments in a single workflow. It is currently used to test
FreeBSD inside a VirtualBox since we don't have any FreeBSD machine. \
Vagrant call a base image a *box*. \
2020-09-23 17:42:01 +02:00
Vagrant call a container a *vagrant machine*.
2020-09-23 14:50:07 +02:00
2020-09-23 17:42:01 +02:00
You can find official box on the Vagrant registry [Vagrant Cloud](https://app.vagrantup.com/boxes/search)
2020-09-23 14:50:07 +02:00
note: Currently only github MacOS runner provide virtualization support (i.e. [VirtualBox](https://www.virtualbox.org/)).
2022-03-24 17:19:17 +01:00
### Basic usage
Once `vagrant` and `VirtualBox` are installed, all commands must be run where
the `Vagrantfile` is located.
2020-09-23 14:50:07 +02:00
2020-09-23 17:42:01 +02:00
Generate a `Vagrantfile` skeleton, e.g. using the box `generic/freebsd12`:
2022-03-24 17:19:17 +01:00
2020-09-23 17:42:01 +02:00
```sh
vagrant init generic/freebsd12
```
Build and run a new *vagrant machine*:
2022-03-24 17:19:17 +01:00
2020-09-23 14:50:07 +02:00
```sh
vagrant up
```
note: If you run `virtualbox` you should see it.
2020-09-23 17:42:01 +02:00
Connect to a *vagrant machine*:
2022-03-24 17:19:17 +01:00
2020-09-23 14:50:07 +02:00
```sh
vagrant ssh
[vagrant@freebsd12 ~]$ ...
```
Execute few commands:
2022-03-24 17:19:17 +01:00
2020-09-23 14:50:07 +02:00
```sh
vagrant ssh -c "pwd; ls project ..."
```
2020-09-23 17:42:01 +02:00
Stop and delete a *vagrant machine*:
2022-03-24 17:19:17 +01:00
2020-09-23 14:50:07 +02:00
```sh
vagrant destroy -f
```