Skip to content

Commit

Permalink
Fix 944 and correct CI (#947)
Browse files Browse the repository at this point in the history
* fix #944

force lowercase for package name in Dockerfile

* check_is_installed is back again instead of fs_file_copy for dockerfile creation 

* set version to 0.3.5.9001
  • Loading branch information
VincentGuyader authored Dec 7, 2022
1 parent cc608c9 commit acc054b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# 0.3.5.9000+ (dev version)


add_dockerfile_with_renv now works well with uppercase in package name

## Soft deprecated

## Hard deprecated
Expand Down Expand Up @@ -30,6 +33,7 @@
## Internal changes



# golem 0.3.5

Update in the tests for CRAN (commented a test that made new version of testthat fail).
Expand Down
23 changes: 8 additions & 15 deletions R/add_dockerfiles_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ add_dockerfile_with_renv_ <- function(
)
}

fs_file_copy(
path = lockfile,
new_path = output_dir,
overwrite = TRUE
)
file.copy(from = lockfile, to = output_dir)
socle <- dockerfiler::dock_from_renv(

socle <- dockerfiler_dock_from_renv(
lockfile = lockfile,
distro = distro,
FROM = FROM,
Expand All @@ -56,12 +52,9 @@ add_dockerfile_with_renv_ <- function(

socle$write(as = file.path(output_dir, "Dockerfile_base"))

my_dock <- dockerfiler_Dockerfile()$new(
FROM = paste0(
golem::get_golem_name(),
"_base"
)
)

my_dock <- dockerfiler::Dockerfile$new(FROM = tolower(paste0(golem::get_golem_name(), "_base")))


my_dock$COPY("renv.lock.prod", "renv.lock")

Expand Down Expand Up @@ -186,11 +179,11 @@ add_dockerfile_with_renv <- function(
docker build -f Dockerfile --progress=plain -t %s .
docker run -p %s:%s %s
# then go to 127.0.0.1:%s",
paste0(golem::get_golem_name(), "_base"),
paste0(golem::get_golem_name(), ":latest"),
tolower(paste0(golem::get_golem_name(), "_base")),
tolower( paste0(golem::get_golem_name(), ":latest")),
port,
port,
paste0(golem::get_golem_name(), ":latest"),
tolower(paste0(golem::get_golem_name(), ":latest")),
port
)

Expand Down
42 changes: 42 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,48 @@ yesno <- function(...) {
menu(c("Yes", "No")) == 1
}


# Checking that a package is installed
check_is_installed <- function(
pak,
...
) {
if (
!requireNamespace(pak, ..., quietly = TRUE)
) {
stop(
sprintf(
"The {%s} package is required to run this function.\nYou can install it with `install.packages('%s')`.",
pak,
pak
),
call. = FALSE
)
}
}

required_version <- function(
pak,
version
) {
if (
utils::packageVersion(pak) < version
) {
stop(
sprintf(
"This function require the version '%s' of the {%s} package.\nYou can update with `install.packages('%s')`.",
version,
pak,
pak
),
call. = FALSE
)
}
}




add_sass_code <- function(where, dir, name) {
if (fs_file_exists(where)) {
if (fs_file_exists("dev/run_dev.R")) {
Expand Down

0 comments on commit acc054b

Please sign in to comment.