Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • aurelien.ginolhac/drake-gitlab-docker
  • jacek.lebioda/drake-gitlab-docker
2 results
Show changes
Commits on Source (44)
......@@ -2,3 +2,5 @@
^.*\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^Makefile$
^CODE_OF_CONDUCT\.md$
services:
- name: docker:19.03.6-dind
command: ["--mtu=1458"]
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
stages:
- build-image
- fit
- build
- test
build-testing-image:
stage: build-image
image: docker:19.03.1
services:
- docker:19.03.1-dind
variables:
DOCKER_HOST: tcp://docker:2375/
build docker image:
stage: build
image: docker:19.03.6
tags:
- privileged
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- 'docker pull $CI_REGISTRY_IMAGE:latest || true'
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
only:
changes:
- "DESCRIPTION"
- "Dockerfile"
when: always
run-drake:
stage: fit
- Dockerfile
- DESCRIPTION
run drake:
stage: test
image: $CI_REGISTRY_IMAGE:latest
cache:
key: "$CI_PROJECT_PATH"
......@@ -33,11 +39,11 @@ run-drake:
name: "$CI_JOB_NAME"
paths:
- artifacts/
reports:
metrics: artifacts/metrics.txt
before_script:
- Rscript -e "remotes::install_deps()"
script:
- ./make.R
- zip -r artifacts/drake_cache.zip .drake
when: always
# Contributor Covenant Code of Conduct
[Bosnian](http://contributor-covenant.org/version/1/4/bs/)
| [Deutsch](http://contributor-covenant.org/version/1/4/de/)
| [ελληνικά](http://contributor-covenant.org/version/1/4/el/)
| [English](http://contributor-covenant.org/version/1/4/)
| [Español](http://contributor-covenant.org/version/1/4/es/)
| [Français](http://contributor-covenant.org/version/1/4/fr/)
| [Italiano](http://contributor-covenant.org/version/1/3/0/it/)
| [日本語](http://contributor-covenant.org/version/1/3/0/ja/)
| [Magyar](http://contributor-covenant.org/version/1/3/0/hu/)
| [Nederlands](http://contributor-covenant.org/version/1/4/nl/)
| [Polski](http://contributor-covenant.org/version/1/4/pl/)
| [Português](http://contributor-covenant.org/version/1/4/pt/)
| [Português do Brasil](http://contributor-covenant.org/version/1/4/pt_br/)
| [Pусский](http://contributor-covenant.org/version/1/3/0/ru/)
| [Română](http://contributor-covenant.org/version/1/4/ro/)
| [Svenska](http://contributor-covenant.org/version/1/4/sv/)
| [Slovenščina](http://contributor-covenant.org/version/1/4/sl/)
| [Türkçe](http://contributor-covenant.org/version/1/4/tr/)
| [Українська](http://contributor-covenant.org/version/1/4/uk/)
| [한국어](http://contributor-covenant.org/version/1/4/ko/)
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at noam.ross@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
\ No newline at end of file
Package: repel-drake
Package: drake-gitlab-docker-example
Title: Drake pipeline example for model-fitting
Version: 0.0.0.9000
Authors@R:
person(given = "Noam",
c(person(given = "Noam",
family = "Ross",
role = c("aut", "cre"),
email = "first.last@example.com",
comment = c(ORCID = "0000-0002-2136-0000""))
Description: What the package does (one paragraph).
comment = c(ORCID = "0000-0002-2136-0000"")),
person("EcoHealth Alliance", role="cph"))
Description: Example project repository for building Drake projects
with Docker and Gitlab-CI.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Imports:
txtq,
drake,
tidyverse,
knitr,
rmarkdown,
visNetwork,
here
here,
gitlabr
Remotes:
ropensci/drake,
wlandau/txtq
FROM rocker/verse:3.6.1
RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated --no-install-recommends --no-upgrade \
curl
curl \
zip
## Install packages
## Install packages
RUN install2.r -s remotes
COPY DESCRIPTION /pkg/DESCRIPTION
RUN Rscript -e "remotes::install_deps(pkgdir = '/pkg/', dependencies=TRUE, upgrade = 'always', force = FALSE, quiet = FALSE)"
CI_REGISTRY_IMAGE ?= registry.gitlab.com/ecohealthalliance/drake-gitlab-docker-example
all: docker
docker:
docker build --cache-from $(CI_REGISTRY_IMAGE):latest -t $(CI_REGISTRY_IMAGE):latest . && docker run -v `pwd`:/repo -w /repo $(CI_REGISTRY_IMAGE):latest ./make.R
import_ci_drake_cache <- function(tag = "master", gitlab_pat = Sys.getenv("GITLAB_PAT"),
cache_zipfile = "drake_cache.zip",
project = "14475381",
job = "run-drake") {
td <- tempfile()
dir.create(td)
zippath <- file.path(td, cache_zipfile)
cache_zip <- httr::GET(
paste0("https://gitlab.com/api/v4/projects/", project, "/jobs/artifacts/", tag, "/raw/artifacts/", "drake_cache.zip?job=", job),
httr::add_headers(`PRIVATE-TOKEN` = Sys.getenv("GITLAB_PAT")),
httr::config(followlocation = 1),
httr::write_disk(zippath, overwrite = TRUE)
)
zip::unzip(zippath, exdir = file.path(td))
if (!dir.exists(".drake")) drake::new_cache()
my_cache <- drake::drake_cache(path = ".drake")
ci_cache <- drake::drake_cache(path = file.path(td, ".drake"))
my_cache$import(ci_cache)
my_cache$history$import(ci_cache$history)
}
\ No newline at end of file
# drake-gitlab-docker-example
# repel-drake
This is an example/template repository for building `drake` R projects on GitLab CI using Docker. It builds off the drake [`mtcars` example](https://github.com/wlandau/drake-examples/tree/master/mtcars).
Template repo for model-fitting for the REPEL project
Some key features:
- The main build script is `make.R`, which builds the project in the local environment.
- The build environment is defined in the project `Dockerfile` and packages required are in `DESCRIPTION`.
- Two jobs are defined in `.gitlab-ci.yml`. The first builds or updates the Docker image and is run only when `Dockerfile` or `DESCRIPTION` change. The image is stored in GitLab's project-level image registry. The second job builds the drake pipeline.
- Outputs from the drake pipeline (model objects, compiled reports, and a drake network graph) go into `artifacts` when built. This directory is stored as an artifact with each GitLab build job, but `.gitignore`'d.
- A [metrics file](https://docs.gitlab.com/ee/ci/metrics_reports.html) is saved
on each run which can be read and reported by GitLab.
- The `.drake` directory is `.gitignore`'d but cached on GitLab between jobs so as to minimize build times. It is also stored as a an artifact (`artifacts/drake_cache.zip) so it may be downloaded and re-used.
- An experimental function in `R/get_cache.R` imports the drake cache from GitLab CI into the local drake cache. It requires a GitLab access token to be set a `GITLAB_PAT` in the environment (e.g., in `.Renviron`).
- A `Makefile` defines a docker command so that `make` builds the Docker environment and runs the `drake` pipeline inside it. This facilitates running the dockerized pipeline locally.
- The RStudio project file (`.Rproj`) is configured so that `make.R` is run using "Build All" (Cmd+Shift+B) in the Rstudio build pane.
---
Please note that this project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.
\ No newline at end of file
# This file serves the r_*() functions (e.g. r_make()) documented at
# https://ropenscilabs.github.io/drake-manual/projects.html#safer-interactivity # nolint
# and
# https://docs.ropensci.org/drake/reference/r_make.html
# Load your packages and supporting functions into your session.
# If you use supporting scripts like the ones below,
# you will need to supply them yourself. Examples:
# https://github.com/wlandau/drake-examples/tree/master/main/R
source("R/packages.R") # Load your packages, e.g. library(drake).
source("R/functions.R") # Define your custom code as a bunch of functions.
source("R/plan.R") # Create your drake plan.
# _drake.R must end with a call to drake_config().
# The arguments to drake_config() are basically the same as those to make().
drake_config(my_plan, verbose = 2L)
File moved
#!/usr/bin/env Rscript
# Walkthrough: https://ropenscilabs.github.io/drake-manual/walkthrough.html
# Download the code: drake_example("main") # nolint
library(drake)
r_make()
# Load your packages and supporting functions into your session.
# If you use supporting scripts like the ones below,
# you will need to supply them yourself. Examples:
# https://github.com/wlandau/drake-examples/tree/master/main/R
source("R/packages.R") # Load your packages, e.g. library(drake).
source("R/functions.R") # Define your custom code as a bunch of functions.
source("R/plan.R") # Create your drake plan.
set.seed(42)
# Call make() to run your work.
# Your targets will be stored in a hidden .drake/ cache,
# and you can read them back into memory with loadd() and read().
make(my_plan)
config <- drake_config(my_plan)
my_graph <- drake::vis_drake_graph(config)
visNetwork::visSave(my_graph, here::here("artifacts", "drake_graph.html"))
# Save a network graph
visNetwork::visSave(r_vis_drake_graph(), here::here("artifacts", "drake_graph.html"))
print(build_times(), n=50)
# Save relevant metrics in OpenMetricc format
# See https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
# https://docs.gitlab.com/ee/ci/metrics_reports.html
cat("build_time_seconds ", round(sum(build_times()$elapsed), 2),
file = here::here("artifacts", "metrics.txt"))