README.md 2.63 KB
Newer Older
Jean-Francois Rey's avatar
Jean-Francois Rey committed
1
# MacOS, R environment, as GitLab CI/CD
Jean-Francois Rey's avatar
Jean-Francois Rey committed
2

Jean-Francois Rey's avatar
Jean-Francois Rey committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
If you want to develop and test your R packages, build R packages binaries under/for MacOS automatically, this is the right place.

> __This project is only for developpement and testing.  For other use you must have Apple equipment.__


> Create a VirtualBox under MacOS Catalina 10.15 with R (>= 4.0.0) and Rtools + some dependencies. And register it as a GitLab-Runner.

[[TOC]]

## Dependencies

A bare metal or a virtual machine (with nested virtualization on the hypervisor activated) as a server with dependencies installed. Apple equipement.

### Systems

* VirtualBox (>= 6.1.14)
* Vagrant (>= 2.2.10)
* Ansible (>=2.2.1.0)
* sshpass (1.06)
* GitLab-Runner (>= 10.0.0)

### GitLab Runner

Use GitLab-Runner to register a _shell_ runner. _gitlab-runner_ user have to get access to _vboxmanage_, _vagrant_ and _ansible_.  

To register the virtualbox runner create here, called _MACOSCR4_.  
```bash
gitlab-runner register \
  --non-interactive \
  --name MACOSCR4
  --url <Gitlab_URL> \
  --registration-token <registration-token> \
  --executor "virtualbox" \
  --tag-list MacOS,R4 \
  --ssh-user vagrant \
  --ssh-password vagrant \
  --virtualbox-base-name "MACOSCR4" \
  --virtualbox-disable-snapshots = false \
  --virtualbox-base-snapshot = "bootR4"
```

To use this runner, add in your .gitlab-ci.yml jobs:
```
tags:
  - MacOS
  - R4
```

## Principle

Every things happen in the [.gitlab-ci.xml](.gitlab-ci.xml) file.  

Mainly the [VagrantFile](VagrantFile) set up a virtual machine from Vagrant Cloud [GAEV/MacOS\_Catalina](https://app.vagrantup.com/GAEV/boxes/MacOS_Catalina) box.  
Files in [provisioning/](provisioning/) are playbooks for Ansible that will install/configure R, Rtools [https://mac.r-project.org/](https://mac.r-project.org/), packages and dependencies, MacTeX, Xquartz and GitLab-Runner.  
After the virtual machine creation and configuration, it registered as a new gitlab-runner (by replacing the existing virtualbox machine "MACOSCR4").

## Locally

To set up the VM (called _MacOSCR4_) locally (on your computer), you just need to run :  
```bash
vagrant up
vagrant snapshot bootR4
vagrant halt
```

## Customization

* To add R packages : edit file [ansible\_provisioning/files/install-r-library.sh](ansible\_provisioning/files/install-r-library.sh) and add systems libraries and R packages to install.  
* Make artifacts work on your GitLab instance : edit file [ansible\_provisioning/files/install-gitlabrunner.sh](ansible\_provisioning/files/install-gitlabrunner.sh) and change the gitlab URL and IP.
* Custom VirtualBox : edit file [VagrantFile](VagrantFile) and modify parameters in virtualbox provider.
Jean-Francois Rey's avatar
Jean-Francois Rey committed
73