Skip to content
Snippets Groups Projects
Commit 571af779 authored by Noam Ross's avatar Noam Ross
Browse files

Merge branch 'metrics' into 'master'

Add metrics reporting

See merge request ecohealthalliance/drake-gitlab-docker-example!1
parents 5dd52147 9a7ed287
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,8 @@ run-drake:
name: "$CI_JOB_NAME"
paths:
- artifacts/
reports:
metrics: artifacts/metrics.txt
before_script:
- Rscript -e "remotes::install_deps()"
script:
......
......@@ -8,6 +8,8 @@ Some key features:
- 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.
- 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.
......
......@@ -2,5 +2,13 @@
library(drake)
r_make()
# 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"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment