Skip to content

Commit

Permalink
Fix clean step
Browse files Browse the repository at this point in the history
  • Loading branch information
nealrichardson committed Apr 12, 2024
1 parent b6d8947 commit 26317aa
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions R/utils-ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
# TODO: A nicer way to execute these system commands...
# - debug output... better error handling... etc.

# set up test servers...
clean_test_env <- function(compose_file_path = system.file("ci/test-connect.yml", package = "connectapi")) {
cat_line("docker compose: cleaning...")
system2("docker", c("compose", "-f", compose_file_path, "down"))
cat_line("docker compose: clean!")
invisible()
}

determine_license_env <- function(license) {
if (fs::file_exists(license) && fs::path_ext(license) == "lic") {
# Docker needs this to be an absolute path
Expand Down Expand Up @@ -46,24 +38,26 @@ compose_start <- function(connect_license = Sys.getenv("RSC_LICENSE"), rsc_versi
)

compose_file_path <- system.file(compose_file, package = "connectapi")
env_vars <- c(
RSC_VERSION = rsc_version,
PATH = Sys.getenv("PATH"),
license_details$env_params
)
# system2 needs a character vector of name=value
env_vars <- paste(names(env_vars), env_vars, sep = "=")
docker <- Sys.which("docker")

# stop compose
if (clean) {
clean_test_env(compose_file_path)
system2(docker, c("compose", "-f", compose_file_path, "down"), env = env_vars)
}

# start compose
cat_line("docker compose: starting...")
args <- c("compose", "-f", compose_file_path, "up", "-d")
env_vars <- c(
RSC_VERSION = rsc_version,
PATH = Sys.getenv("PATH"),
license_details$env_params
)
# do not show env_vars b/c need to handle license securely
docker <- Sys.which("docker")
cat_line(glue::glue("command: {docker} {paste(args, collapse=' ')}"))
system2(docker, args, env = paste(names(env_vars), env_vars, sep = "="))
system2(docker, args, env = env_vars)
cat_line("docker compose: started!")
invisible()
}
Expand All @@ -75,7 +69,7 @@ compose_find_hosts <- function(prefix) {
# get docker containers
cat_line("docker: getting list of containers...")
docker_ps_output <- system2("docker", "ps", stdout = TRUE)
cat_line("docker: got containers")
cat(docker_ps_output, sep = "\n")

containers <- grep(prefix, docker_ps_output, value = TRUE)
ports <- sub(".*0\\.0\\.0\\.0:([0-9]+)->3939.*", "\\1", containers)
Expand Down

0 comments on commit 26317aa

Please sign in to comment.