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.