Skip to content

Commit

Permalink
add new entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Oct 18, 2022
1 parent ef814a1 commit 36a0f28
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
34 changes: 26 additions & 8 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ create_orderly_demo <- function(path = tempfile(), quiet = FALSE,
}


prepare_git_example_from_source <- function(source_path, path) {
temp <- file.path(tempfile(), "demo")
fs::dir_copy(source_path, temp)
generate_source_db(temp)
run_orderly_demo(temp)
build_git_demo(temp)
prepare_orderly_git_example(path, run_report = FALSE)
}


run_orderly_demo <- function(path, quiet = FALSE) {
if (quiet) {
oo <- options(orderly.nolog = TRUE)
Expand Down Expand Up @@ -79,6 +89,7 @@ run_orderly_demo <- function(path, quiet = FALSE) {
path
}


## This is a really rubbish set of test data. It requires an open
## "source" database and will write out two tables. This is used by
## the examples.
Expand Down Expand Up @@ -115,6 +126,17 @@ prepare_orderly_example <- function(name, path = tempfile(), testing = FALSE,
src_files <- dir(src, full.names = TRUE)
file_copy(src_files, path, overwrite = TRUE, recursive = TRUE)

generate_source_db(path)

if (git) {
prepare_basic_git(path, quiet = TRUE)
}

path
}


generate_source_db <- function(path) {
if (file.exists(file.path(path, "source.R"))) {
generator <- source(file.path(path, "source.R"), local = TRUE)$value
} else {
Expand All @@ -125,12 +147,6 @@ prepare_orderly_example <- function(name, path = tempfile(), testing = FALSE,
if (length(con) > 0L) {
generator(con)
}

if (git) {
prepare_basic_git(path, quiet = TRUE)
}

path
}


Expand Down Expand Up @@ -196,8 +212,10 @@ demo_change_time <- function(id, time, path) {
## extendable...
##
## After building this we have two branches 'master' with
build_git_demo <- function() {
path <- prepare_orderly_example("demo", file.path(tempfile(), "demo"))
build_git_demo <- function(path = NULL) {
if (is.null(path)) {
path <- prepare_orderly_example("demo", file.path(tempfile(), "demo"))
}
dir.create(file.path(path, "extra"))
move <- setdiff(dir(file.path(path, "src"), pattern = "^[^.]+$"),
c("minimal", "global"))
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ COPY . /orderly
RUN R CMD INSTALL /orderly && \
Rscript -e 'orderly:::write_script("/usr/bin")' && \
cp /orderly/inst/create_orderly_demo.sh /usr/bin/ && \
cp /orderly/inst/run_orderly_demo.sh /usr/bin/ && \
rm -rf /orderly

ENTRYPOINT ["/usr/bin/orderly"]
9 changes: 9 additions & 0 deletions inst/run_orderly_demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -ex
if [ "$#" -ne 2 ]; then
echo "Expected two arguments (source_path, dest_path)"
exit 1
fi
SRC=$1
DEST=$2
Rscript -e "orderly:::prepare_git_example_from_source(\"$SRC\", \"$DEST\")"

0 comments on commit 36a0f28

Please sign in to comment.