Skip to content

Commit

Permalink
Add gitlab ci workflow
Browse files Browse the repository at this point in the history
Mainly to check if the installation on ubuntu rolling works.

Change-Id: I19f7fd847fdeaf4c683a40b6f240cde211913779
  • Loading branch information
kupietz committed Jan 25, 2024
1 parent fab6eaf commit 3839007
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
^CRAN-RELEASE$
^.*\.log$
^CRAN-SUBMISSION$
^ci
^.gitlab-ci
66 changes: 66 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
image: ubuntu:rolling

stages:
- build

build-job:
stage: build

variables:
# Set `CCACHE_BASEDIR` and `CCACHE_DIR` to point `ccache` towards the cached
# path on the gitlab-runner. This enables to cache the output of `ccache`
# between various runs.
CCACHE_BASEDIR: ${CI_PROJECT_DIR}
CCACHE_DIR: ${CI_PROJECT_DIR}/ccache
# Set `ccache` to `content` to prevent rebuilding of the CI/CD containers to
# trigger a recreate of the cache. By using `content` the compiler's `mtime`
# is not considered as part of the hash.
CCACHE_COMPILERCHECK: "content"
# Enable caching for `apt-get`.
APT_CACHE_DIR: ${CI_PROJECT_DIR}/apt-cache
# Export `noninteractive` frontend to prevent requesting user input
DEBIAN_FRONTEND: noninteractive
R_LIBS_USER: ${CI_PROJECT_DIR}/rlib

cache:
key: rkorapclient
paths:
- apt-cache/
- ccache/
- rlib/

artifacts:
paths:
- "target/*"

before_script:
- source `find .. -name section_helper.sh`

- start_section install_linux_packages "Installing missing Linux packages"
- mkdir -pv $APT_CACHE_DIR ccache $R_LIBS_USER /usr/local/sbin ~/.ccache ~/.R
- cp ci/Makevars ~/.R/Makevars
- cp ci/ccache.conf ${CI_PROJECT_DIR}/ccache/ccache.conf
- cp ci/ccache.conf ~/.ccache/ccache.conf
- echo "R_LIBS='$R_LIBS_USER'" > .Renviron
- echo "MAKEFLAGS=-j$(nproc)" >> ~/.R/Makevars
- echo "MAKE=make -j$(nproc)" >> ~/.R/Makevars
- apt-get update
- apt-get install -y -o dir::cache::archives="$APT_CACHE_DIR" --no-install-recommends software-properties-common dirmngr ccache wget
- wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
- add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# - add-apt-repository ppa:c2d4u.team/c2d4u4.0+
- grep "sudo apt install" Readme.md | sed -e 's/.*sudo apt install/apt-get install --no-install-recommends -o dir::cache::archives="$APT_CACHE_DIR" -y /g' | sh
- ln -s $(which ccache) /usr/local/sbin/gcc
- ln -s $(which ccache) /usr/local/sbin/g++
- end_section install_linux_packages

script:
- start_section installing "Installing RKorAPClient from CRAN"
- export PATH=/usr/local/sbin:$PATH
- R -q -e "install.packages(c('remotes', 'RKorAPClient'), dependencies = TRUE)"
- R -q -e "update.packages(ask = FALSE)"
- end_section installing
- start_section linstalling "Installing RKorAPClient from source"
- R -q -e 'remotes::install_local(force = TRUE, dependencies = TRUE)'
- ccache -s
- end_section linstalling
11 changes: 11 additions & 0 deletions ci/Makevars
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
VER=
CXX17=$(CCACHE) g++$(VER)
CCACHE=ccache
#CCACHE=
CC=$(CCACHE) gcc$(VER)
CXX=$(CCACHE) g++$(VER)
CXX11=$(CCACHE) g++$(VER)
CXX14=$(CCACHE) g++$(VER)
CXX17=$(CCACHE) g++$(VER)
FC=$(CCACHE) gfortran$(VER)
F77=$(CCACHE) gfortran$(VER)
3 changes: 3 additions & 0 deletions ci/ccache.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
max_size = 5.0G
sloppiness = include_file_ctime
hash_dir = false
20 changes: 20 additions & 0 deletions ci/section_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Reference: https://docs.gitlab.com/ee/ci/jobs/#custom-collapsible-sections

#
# Takes 2 Parameters a new section id and a heading/title
#
function start_section() {
id=$1
title=$2
echo -e "\e[0Ksection_start:$(date +%s):${id}[collapsed=true]\r\e[0K\e[36;1m${title}\e[0m"
}

#
# Takes 1 Parameter, the unique section id of the section that should end
#
function end_section() {
id=$1
echo -e "\e[0Ksection_end:$(date +%s):${id}\r\e[0K"
}

0 comments on commit 3839007

Please sign in to comment.