README.md 2.58 KB
Newer Older
Jean-Francois Rey's avatar
Jean-Francois Rey committed
1
# Windows 10 Virtual Machine, R environment, as GitLab Runner
Jean-Francois Rey's avatar
Jean-Francois Rey committed
2

Jean-Francois Rey's avatar
Jean-Francois Rey committed
3
If you want to develop and test your R packages, build R packages binaries under/for windows automatically, this is the right place.  
Jean-Francois Rey's avatar
Jean-Francois Rey committed
4

Jean-Francois Rey's avatar
Jean-Francois Rey committed
5
6
7
> Create a VirtualBox under windows 10 with R (Version >= 4.0.0) and Rtools + some dependencies.  And register it as a GitLab Runner.

[[_TOC_]]
Jean-Francois Rey's avatar
Jean-Francois Rey committed
8
9
10

## Dependencies

11
12
A bare metal or a Virtual Machine with nested Virtualization on the hypervisor activated as a server with dependencies installed.  

Jean-Francois Rey's avatar
Jean-Francois Rey committed
13
### Systems
Jean-Francois Rey's avatar
Jean-Francois Rey committed
14

Jean-Francois Rey's avatar
Jean-Francois Rey committed
15
* VirtualBox (>=6.1.14) and extension Pack
Jean-Francois Rey's avatar
Jean-Francois Rey committed
16
17
18
* Vagrant (>=2.2.10)
* Ansible (>=2.2.1.0)
* pywinrm (>=0.3.0) compatible with Ansible Python version (defualt is 2)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
19
* GitLab-Runner (>= 10.0.0)
Jean-Francois Rey's avatar
Jean-Francois Rey committed
20
21
22

### GitLab Runner

Jean-Francois Rey's avatar
Jean-Francois Rey committed
23
24
25
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 _WIN10R4_.  
Jean-Francois Rey's avatar
Jean-Francois Rey committed
26
27
28
29
30
31
32
33
34
35
36
37
38
39
```bash
gitlab-runner register \
	--non-interactive \
	--name win10R4
	--url <Gitlab_URL> \
	--registration-token <registration-token> \
	--executor "virtualbox" \
	--tag-list windows,R4 \
	--ssh-user vagrant \
  --ssh-password vagrant \
	--virtualbox-base-name "WIN10R4" \
	--virtualbox-disable-snapshots = false \
	--virtualbox-base-snapshot = "bootR4"
```
40

Jean-Francois Rey's avatar
Jean-Francois Rey committed
41
42
43
44
45
46
To use this runner, add in your .gitlab-ci.yml jobs:
```
tags:
  - windows
  - R4
```
Jean-Francois Rey's avatar
Jean-Francois Rey committed
47

Jean-Francois Rey's avatar
update    
Jean-Francois Rey committed
48
## Principle
Jean-Francois Rey's avatar
Jean-Francois Rey committed
49
	
Jean-Francois Rey's avatar
Jean-Francois Rey committed
50
Every things happen in the [.gitlab-ci.xml](.gitlab-ci.xml) file.  
Jean-Francois Rey's avatar
update    
Jean-Francois Rey committed
51

Jean-Francois Rey's avatar
Jean-Francois Rey committed
52
53
Mainly the [VagrantFile](VagrantFile) set up a virtual machine from Vagrant Cloud [GAEV/win10](https://app.vagrantup.com/GAEV/boxes/win10) box (a windows10 professional evaluation version with vbBoxGuestAditions).  
Files in [provisioning/](provisioning/) are playbooks for Ansible that will install/configure R, Rtools, packages, MiKTeX, Pandoc and GitLab-Runner.  
Jean-Francois Rey's avatar
Jean-Francois Rey committed
54
After the virtual machine creation and configuration, it registered as a new gitlab-runner (by replacing the existing virtualbox machine "WIN10R4").
Jean-Francois Rey's avatar
update    
Jean-Francois Rey committed
55

Jean-Francois Rey's avatar
Jean-Francois Rey committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## Locally

To set up the VM (called windows10R4) 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-packages.sh](ansible\_provisioning/files/install-r-packages.sh) and add systems libraries and R packages to install.  
* Make artifacts work on your GitLab instance : edit file [ansible\_provisioning/files/install-gitlab-runner.sh](ansible\_provisioning/files/install-gitlab-runner.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
70