Commit ae0974e1 authored by Jean-Francois Rey's avatar Jean-Francois Rey
Browse files

add CI/CD

update README
parent eb809571
stages:
- build
- stock
- deploy
Gen-VM:
tags:
- "virtualbox"
- "ansible"
- "vagrant"
stage: build
script:
- vboxmanage controlvm MacOSCR4 poweroff || true
- vboxmanage unregistervm --delete MacOSCR4 || true
- vagrant box update
#- vagrant up > vagrantup.log
- vagrant up
- vagrant snapshot save bootR4
after_script:
- vagrant halt
artifacts:
paths:
- vagrantup.log
Stock-S3-box:
tags:
- "virtualbox"
- "ansible"
- "vagrant"
stage: stock
when: manual
script:
- time vagrant package --base MacOSCR4 --output MacOS_Catalina_R4_virtualbox.box
- time s3cmd --access_key=$EC2_ACCESS_KEY --secret_key=$EC2_SECRET_KEY --host=$S3_HOST --host-bucket="%(bucket)s.$S3_HOST" --region="inra-tls" -v put MacOS_Catalina_R4_virtualbox.box s3://gaev-stock/
- rm MacOS_Catalina_R4_virtualbox.box || true
Deploy-VM:
tags:
- "virtualbox"
- "ansible"
- "vagrant"
stage: deploy
when: manual
script:
- vboxmanage controlvm MACOSCR4 poweroff || true
- vboxmanage unregistervm --delete MACOSCR4 || true
- vboxmanage modifyvm MacOSCR4 --name MACOSCR4
- sudo vboxmanage unregistervm MACOSCR4 || true
- sudo vboxmanage registervm "/home/gitlab-runner/VirtualBox VMs/MACOSCR4/MACOSCR4.vbox"
# MacOs, R environment and GitLab CI/CD # MacOS, R environment, as GitLab CI/CD
## 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.
apt-get install sshpass
...@@ -14,7 +14,7 @@ Vagrant.configure("2") do |config| ...@@ -14,7 +14,7 @@ Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |vb| config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine # Display the VirtualBox GUI when booting the machine
vb.gui = true vb.gui = true
vb.name = "MacOS_C_R4" vb.name = "MacOSCR4"
vb.customize ["modifyvm", :id, "--memory", 4096] vb.customize ["modifyvm", :id, "--memory", 4096]
vb.customize ["modifyvm", :id, "--cpus", 4] vb.customize ["modifyvm", :id, "--cpus", 4]
vb.customize ["modifyvm", :id, "--vram", 128] vb.customize ["modifyvm", :id, "--vram", 128]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment