Skip to content

Commit

Permalink
Merge pull request #9 from roqua/ae-circleci-20
Browse files Browse the repository at this point in the history
move to circleci 20
emerencia authored Jul 11, 2018
2 parents 7384336 + eb4c910 commit 1d5f5b4
Showing 6 changed files with 173 additions and 27 deletions.
6 changes: 4 additions & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
^.*\.Rproj$
^\.Rproj\.user$
.git
.gitignore
^circle.yml$
^.gitignore$
.circleci
docker_configs
^Dockerfile$
129 changes: 129 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
defaults: &defaults
working_directory: /app
docker:
- image: docker:17.05.0-ce-git
environment:
R_LIBS_USER: ~/lib/R/library
_R_CHECK_FORCE_SUGGESTS_: FALSE
_R_CHECK_ASCII_DATA_: FALSE

version: 2
jobs:
run_tests:
<<: *defaults
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- checkout
- setup_remote_docker
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/app.tar | true
- run:
name: Build application Docker image
command: |
docker build --cache-from=app -t app -f Dockerfile .
- run:
name: Save Docker image layer cache
command: |
mkdir -p /caches
docker save -o /caches/app.tar app
- run:
name: Test the app
command: |
docker run app R CMD check /autovarCore/autovarCore_1.0-4.tar.gz --no-manual --no-build-vignettes --as-cran
- save_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /caches

coverage:
<<: *defaults
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- checkout
- setup_remote_docker
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/app.tar | true
- run:
name: Build application Docker image
command: |
docker build --cache-from=app -t app -f Dockerfile .
- run:
name: Save Docker image layer cache
command: |
mkdir -p /caches
docker save -o /caches/app.tar app
- run:
name: Codecov the app
command: |
docker run -e CODECOV_TOKEN app Rscript -e 'covr::codecov()'
check_syntax:
<<: *defaults
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- checkout
- setup_remote_docker
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/app.tar | true
- run:
name: Build application Docker image
command: |
docker build --cache-from=app -t app -f Dockerfile .
- run:
name: Save Docker image layer cache
command: |
mkdir -p /caches
docker save -o /caches/app.tar app
- run:
name: Check syntax
command: |
docker run app inst/bash/check_code_conventions.sh
deploy_to_docker:
<<: *defaults
steps:
- restore_cache:
key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- setup_remote_docker
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/app.tar | true
- run:
name: Build application Docker image
command: |
docker build --cache-from=app -t app -f Dockerfile .
- run: docker tag app roqua/autovarcore:staging
- run: docker tag app roqua/autovarcore:production
- run: docker tag app roqua/autovarcore:$(echo "$CIRCLE_TAG" | sed -e 's/v//g')
- run: docker login --email=$DOCKER_EMAIL -u "$DOCKER_USER" -p "$DOCKER_PASS"
- run: docker push roqua/autovarcore

workflows:
version: 2
commit:
jobs:
- run_tests
- coverage
- check_syntax
deploy:
jobs:
- deploy_to_docker:
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+(\.[0-9]+)*/
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How to test using OpenCPU:
# 1. docker build -t autovarCore .
# 2. docker run -p 80:80 autovarCore
# 3. Go to <docker IP>/ocpu/test

FROM compsy/opencpu-base

WORKDIR /autovarCore

RUN apt-get install -y git-core pandoc

ADD ./inst/bash/install-package-dependencies.sh /autovarCore/inst/bash/install-package-dependencies.sh
RUN /autovarCore/inst/bash/install-package-dependencies.sh

ADD ./docker_configs/opencpu_server.conf.patch /docker_configs/opencpu_server.conf.patch
RUN patch -p0 -d /etc/opencpu < /docker_configs/opencpu_server.conf.patch

ADD ./ /autovarCore

#RUN R -e 'library("devtools"); install.packages(build(".", path = "."));'
RUN R CMD INSTALL --no-multiarch --with-keep.source /autovarCore
RUN R CMD build /autovarCore
23 changes: 0 additions & 23 deletions circle.yml

This file was deleted.

16 changes: 16 additions & 0 deletions docker_configs/opencpu_server.conf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- server_old.conf 2015-02-16 18:54:47.066042000 +0100
+++ server.conf 2015-02-16 18:55:05.106042000 +0100
@@ -27,10 +27,10 @@
"appspaths": "/usr/local/lib/opencpu/apps-library",
"repos": "http://cran.rstudio.com",
"rlimit.as": 4e9,
"rlimit.fsize": 1e9,
"rlimit.nproc": 100,
- "timelimit.get": 60,
+ "timelimit.get": 4800,
- "timelimit.post": 90,
+ "timelimit.post": 4800,
"timelimit.webhook": 900,
"preload": ["lattice"]
}

4 changes: 2 additions & 2 deletions inst/bash/install-package-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env Rscript
options(repos = structure(c(CRAN = "http://cran-mirror.cs.uu.nl/")))
packages <- c("Amelia", "jsonlite", "urca", "vars", "testthat", "roxygen2", "Rcpp")
options(repos = structure(c(CRAN = "http://cran.uni-muenster.de/")))
packages <- c("Amelia", "jsonlite", "urca", "vars", "testthat", "roxygen2", "Rcpp", "covr")
new.packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if (length(new.packages))
install.packages(new.packages)

0 comments on commit 1d5f5b4

Please sign in to comment.