Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
language: r
cache:
- packages
- pip
sudo: required
dist: "trusty"
warnings_are_errors: false

addons:
apt:
packages:
- libgsl0-dbg
- libgsl0-dev
- libgsl0ldbl
- "python3"
- "python3-pip"
update: true
services:
- docker

before_install:
- sudo apt-get update -qq
- sudo apt-get install libudunits2-dev
- sudo apt-get install python3
- sudo pip3 install --upgrade pip
- sudo pip3 install git+https://git@github.com/weecology/retriever.git --user
# Set up environment and create required images
# If no error don't print output
- docker build . -t matss > /dev/null
script:
# Load packages and install the required packages
# Install retriever from source and run tests
# - docker run matss /bin/sh -c 'Rscript load_and_test.R'

- docker run matss Rscript load_and_test.R


matrix:
include:
- r: devel
- r: release
after_success:
- R CMD INSTALL .
- Rscript -e 'pkgdown::build_site()'
- Rscript -e 'covr::codecov()'
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_PAT
keep-history: true
local-dir: docs
on:
branch: master
# matrix:
# include:
# - r: devel
# - r: release
# after_success:
# - R CMD INSTALL .
# - Rscript -e 'pkgdown::build_site()'
# - Rscript -e 'covr::codecov()'
# deploy:
# provider: pages
# skip-cleanup: true
# github-token: $GITHUB_PAT
# keep-history: true
# local-dir: docs
# on:
# branch: master
17 changes: 10 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ Imports:
dplyr,
tidyr,
rdataretriever,
reticulate,
RSQLite,
forecast,
networkD3,
here,
tibble,
rlang
rlang,
usethis (>= 1.4.0.9000)
Suggests:
testthat,
knitr,
rmarkdown,
pkgdown,
covr,
reticulate
rmarkdown,
pkgdown,
covr
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Remotes:
Remotes:
weecology/LDATS,
weecology/portalr,
ropensci/drake
ropensci/drake,
ropensci/rdataretriever,
r-lib/usethis
63 changes: 63 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM rocker/tidyverse:latest

MAINTAINER Weecology "https://github.com/weecology/rdataretriever"

# Write enviromental options to config files
RUN echo "options(repos='https://cran.mtu.edu/')" >> ~/.Rprofile
RUN echo "options(repos='https://cran.mtu.edu/')" >> ~/.Renviron
RUN echo "R_LIBS=\"/usr/lib/R/library\"">> ~/.Rprofile
RUN echo "R_LIBS=\"/usr/lib/R/library\"">> ~/.Renviron
RUN echo "R_LIBS_USER=\"/usr/lib/R/library\"">> ~/.Renviron

RUN apt-get update
RUN apt-get install -y build-essential --allow-downgrades --allow-remove-essential --allow-change-held-packages
RUN apt-get install -y wget git locales locales-all --allow-downgrades --allow-remove-essential --allow-change-held-packages
RUN apt-get install -y postgresql-client mysql-client --allow-downgrades --allow-remove-essential --allow-change-held-packages

RUN apt-get install -y libgsl0-dbg libgsl0-dev
RUN apt-get install -y libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

# RUN apt-get install --allow libgsl0ldbl # not available

# Set encoding
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# Remove python2 and install python3
RUN apt-get remove -y python && apt-get install -y python3 python3-pip curl
RUN rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python
RUN rm -f /usr/bin/pip && ln -s /usr/bin/pip3 /usr/bin/pip



RUN echo "export PATH="/usr/bin/python:$PATH"" >> ~/.profile
RUN echo "export PYTHONPATH="/usr/bin/python:$PYTHONPATH"" >> ~/.profile
RUN echo "export PGPASSFILE="~/.pgpass"" >> ~/.profile

# Add permissions to config files
RUN chmod 0644 ~/.Renviron
RUN chmod 0644 ~/.Rprofile
RUN chmod 0644 ~/.profile

# Install retriever python package
RUN pip install git+https://git@github.com/weecology/retriever.git
RUN retriever ls > /dev/null
RUN pip install psycopg2 pymysql > /dev/null
RUN R_RETICULATE_PYTHON="/usr/bin/python" | echo $R_RETICULATE_PYTHON >> ~/.Renviron

COPY . ./MATSS
# Use entrypoint to run more configurations.
# set permissions.
# entrypoint.sh will set out config files
# RUN chmod 0755 MATSS/cli_tools/entrypoint.sh
# ENTRYPOINT ["/cli_tools/entrypoint.sh"]

WORKDIR ./MATSS

# Change permissions to config files
# Do not run these cmds before Entrypoint.
# RUN chmod 600 cli_tools/.pgpass
# RUN chmod 600 cli_tools/.my.cnf

CMD ["bash", "-c", "retriever -v"]
5 changes: 5 additions & 0 deletions cli_tools/.my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[client]
user="travis"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont mind the cli_tools folder, we shall remove it

password="Password12!"
host="mysqldb"
port="3306"
1 change: 1 addition & 0 deletions cli_tools/.pgpass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pgdb:*:testdb:postgres:Password12!
8 changes: 8 additions & 0 deletions cli_tools/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# #!/bin/sh
# set -e

# # Copy config files to $HOME
# cp -r /MATSS/cli_tools/.pgpass ~/
# cp -r /MATSS/cli_tools/.my.cnf ~/

# exec "$@"
41 changes: 41 additions & 0 deletions load_and_test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Used for continous testing platform
# Install analysis packages using pacman
# Pacman will load the packages and install
# the packaes not available

library(devtools)
# Install pacman if it isn't already installed
if ("pacman" %in% rownames(installed.packages()) == FALSE) install.packages("pacman")
# suppressMessages(install.packages("RMariaDB", quiet = TRUE))
suppressMessages(
pacman::p_load(devtools, RCurl, readr, rmarkdown,
testthat, tidyverse, RSQLite,
# DBI, RPostgreSQL,
magrittr, ggplot2, lubridate,
dplyr, tidyr, RSQLite, forecast,
networkD3, here, tibble, rlang)
)

# Install GitHub packages

devtools::install_github("weecology/portalr")
devtools::install_github("ropensci/drake")
devtools::install_github("rstudio/reticulate")
devtools::install_github("ropensci/rdataretriever")
devtools::install_github("r-lib/usethis")
devtools::install_github("weecology/LDATS")
library(devtools)
library(portalr)
library(drake)
library(reticulate)
library(rdataretriever)
library(usethis)
library(LDATS)
install.packages(".", repos = NULL, type="source")
# Test package
# test_dir("tests/testthat", reporter = c("check", "progress"))

# Try old way
# This will not work well for reporting and fail/pass
devtools::test()

6 changes: 3 additions & 3 deletions tests/testthat/test-02-datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ test_that("Jornada data is retrievable and works", {
test_that("Shortgrass Steppe data is retrievable and works", {
expect_error(sgs_data <- get_sgs_data(), NA)
expect_true(check_data_format(sgs_data))
expect_known_hash(sgs_data, "ccbdc633c1")
expect_known_hash(sgs_data, "08c3041cd4")
})

test_that("Maizuru data is retrievable and works", {
expect_error(maizuru_data <- get_maizuru_data(), NA)
expect_true(check_data_format(maizuru_data))
expect_known_hash(maizuru_data, "c93bd061db")
})
expect_known_hash(maizuru_data, "ccbdc633c1")
})
2 changes: 1 addition & 1 deletion tests/testthat/test-03-retriever-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("retriever downloading and importing work", {
expect_error(install_retriever_data("veg-plots-sdl"), NA)
expect_error(dat <- import_retriever_data("veg-plots-sdl"), NA)
expect_known_hash(dat$veg_plots_sdl_Count1906, "4f6b34f60a")
expect_known_hash(dat$veg_plots_sdl_Photo_info, "5fa488da2a")
expect_known_hash(dat$veg_plots_sdl_Photo_info, "5f85a913f4")
expect_known_hash(dat$veg_plots_sdl_Plot_corners, "53e7e72ee9")
expect_known_hash(dat$veg_plots_sdl_Plots, "b0c6ec4b6e")
expect_known_hash(dat$veg_plots_sdl_Seedling_counts, "dd0d14c55a")
Expand Down