Marc Kupietz | 3839007 | 2024-01-25 13:33:23 +0100 | [diff] [blame] | 1 | image: ubuntu:rolling |
| 2 | |
| 3 | stages: |
| 4 | - build |
| 5 | |
| 6 | build-job: |
| 7 | stage: build |
| 8 | |
| 9 | variables: |
| 10 | # Set `CCACHE_BASEDIR` and `CCACHE_DIR` to point `ccache` towards the cached |
| 11 | # path on the gitlab-runner. This enables to cache the output of `ccache` |
| 12 | # between various runs. |
| 13 | CCACHE_BASEDIR: ${CI_PROJECT_DIR} |
| 14 | CCACHE_DIR: ${CI_PROJECT_DIR}/ccache |
| 15 | # Set `ccache` to `content` to prevent rebuilding of the CI/CD containers to |
| 16 | # trigger a recreate of the cache. By using `content` the compiler's `mtime` |
| 17 | # is not considered as part of the hash. |
| 18 | CCACHE_COMPILERCHECK: "content" |
| 19 | # Enable caching for `apt-get`. |
| 20 | APT_CACHE_DIR: ${CI_PROJECT_DIR}/apt-cache |
| 21 | # Export `noninteractive` frontend to prevent requesting user input |
| 22 | DEBIAN_FRONTEND: noninteractive |
| 23 | R_LIBS_USER: ${CI_PROJECT_DIR}/rlib |
| 24 | |
| 25 | cache: |
| 26 | key: rkorapclient |
| 27 | paths: |
| 28 | - apt-cache/ |
| 29 | - ccache/ |
| 30 | - rlib/ |
| 31 | |
| 32 | artifacts: |
| 33 | paths: |
| 34 | - "target/*" |
| 35 | |
| 36 | before_script: |
| 37 | - source `find .. -name section_helper.sh` |
| 38 | |
| 39 | - start_section install_linux_packages "Installing missing Linux packages" |
| 40 | - mkdir -pv $APT_CACHE_DIR ccache $R_LIBS_USER /usr/local/sbin ~/.ccache ~/.R |
| 41 | - cp ci/Makevars ~/.R/Makevars |
| 42 | - cp ci/ccache.conf ${CI_PROJECT_DIR}/ccache/ccache.conf |
| 43 | - cp ci/ccache.conf ~/.ccache/ccache.conf |
| 44 | - echo "R_LIBS='$R_LIBS_USER'" > .Renviron |
| 45 | - echo "MAKEFLAGS=-j$(nproc)" >> ~/.R/Makevars |
| 46 | - echo "MAKE=make -j$(nproc)" >> ~/.R/Makevars |
| 47 | - apt-get update |
| 48 | - apt-get install -y -o dir::cache::archives="$APT_CACHE_DIR" --no-install-recommends software-properties-common dirmngr ccache wget |
| 49 | - wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc |
| 50 | - add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" |
| 51 | # - add-apt-repository ppa:c2d4u.team/c2d4u4.0+ |
| 52 | - 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 |
| 53 | - ln -s $(which ccache) /usr/local/sbin/gcc |
| 54 | - ln -s $(which ccache) /usr/local/sbin/g++ |
| 55 | - end_section install_linux_packages |
| 56 | |
| 57 | script: |
| 58 | - start_section installing "Installing RKorAPClient from CRAN" |
| 59 | - export PATH=/usr/local/sbin:$PATH |
| 60 | - R -q -e "install.packages(c('remotes', 'RKorAPClient'), dependencies = TRUE)" |
| 61 | - R -q -e "update.packages(ask = FALSE)" |
| 62 | - end_section installing |
| 63 | - start_section linstalling "Installing RKorAPClient from source" |
| 64 | - R -q -e 'remotes::install_local(force = TRUE, dependencies = TRUE)' |
| 65 | - ccache -s |
| 66 | - end_section linstalling |