From ac237d5d270a5def6b3c67544b537f2ab51b4a2d Mon Sep 17 00:00:00 2001 From: Ivo Kwee Date: Sun, 12 Mar 2023 06:17:41 +0100 Subject: [PATCH 1/6] Add -it flag when run docker so ^C still works Add -it flag when run docker so ^C still works --- R/add_dockerfiles_renv.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/add_dockerfiles_renv.R b/R/add_dockerfiles_renv.R index 24afc09f..3039a7c1 100644 --- a/R/add_dockerfiles_renv.R +++ b/R/add_dockerfiles_renv.R @@ -206,7 +206,7 @@ add_dockerfile_with_renv <- function( out <- sprintf( "docker build -f Dockerfile_base --progress=plain -t %s . docker build -f Dockerfile --progress=plain -t %s . -docker run -p %s:%s %s +docker run -it -p %s:%s %s # then go to 127.0.0.1:%s", tolower(paste0(golem::get_golem_name(), "_base")), tolower(paste0(golem::get_golem_name(), ":latest")), From d0e034600871d149fb560de0bac92c75ea0ed087 Mon Sep 17 00:00:00 2001 From: Colin Fay Date: Tue, 4 Apr 2023 10:33:59 +0200 Subject: [PATCH 2/6] Revert "Add -it flag when run docker so ^C still works" This reverts commit ac237d5d270a5def6b3c67544b537f2ab51b4a2d. --- R/add_dockerfiles_renv.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/add_dockerfiles_renv.R b/R/add_dockerfiles_renv.R index 3039a7c1..24afc09f 100644 --- a/R/add_dockerfiles_renv.R +++ b/R/add_dockerfiles_renv.R @@ -206,7 +206,7 @@ add_dockerfile_with_renv <- function( out <- sprintf( "docker build -f Dockerfile_base --progress=plain -t %s . docker build -f Dockerfile --progress=plain -t %s . -docker run -it -p %s:%s %s +docker run -p %s:%s %s # then go to 127.0.0.1:%s", tolower(paste0(golem::get_golem_name(), "_base")), tolower(paste0(golem::get_golem_name(), ":latest")), From 996155bd1bcc381f87db46d5e3803ea12f606342 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 17 May 2023 09:16:11 +0200 Subject: [PATCH 3/6] ci: code coverage --- .github/workflows/test-coverage.yaml | 50 ++++++++++++++++++++++++++++ codecov.yml | 2 ++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 00000000..2c5bb502 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: test-coverage + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage + + - name: Test coverage + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/codecov.yml b/codecov.yml index 8f36b6cc..04c55859 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,7 +6,9 @@ coverage: default: target: auto threshold: 1% + informational: true patch: default: target: auto threshold: 1% + informational: true From 46cc53241d08f5e338f4dd647409eea7fd18672c Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 17 May 2023 09:26:25 +0200 Subject: [PATCH 4/6] ci: simpler pkgdown action --- .github/workflows/pkgdown.yaml | 53 +++++++++++++++------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 119130e4..023fbd70 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -3,48 +3,41 @@ on: branches: - main - master - - dev name: pkgdown jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - remotes::install_github("ThinkR-open/thinkrtemplate") - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Restore R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + extra-packages: any::pkgdown, local::. + needs: website - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Install package - run: R CMD INSTALL . - - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e 'options(pkgdown.internet = FALSE);pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs From 365a5cc303b189973abab0dd375c64be79bcf74a Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 24 May 2023 08:46:44 +0200 Subject: [PATCH 5/6] ci: installing thinkridentity in the pkgdown site --- .github/workflows/pkgdown.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 023fbd70..b55b3790 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -30,6 +30,10 @@ jobs: extra-packages: any::pkgdown, local::. needs: website + - name: Install thinkrtemplate + run: install.packages("remotes");remotes::install_github("ThinkR-open/thinkrtemplate") + shell: Rscript {0} + - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} From 2da4e72ba368883d2bc5deda2f6511e4494cf7aa Mon Sep 17 00:00:00 2001 From: Vincent Guyader Date: Thu, 27 Jul 2023 09:07:56 +0000 Subject: [PATCH 6/6] fix dockerfiler deps --- R/add_dockerfiles_renv.R | 64 ++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/R/add_dockerfiles_renv.R b/R/add_dockerfiles_renv.R index 24afc09f..42fac02d 100644 --- a/R/add_dockerfiles_renv.R +++ b/R/add_dockerfiles_renv.R @@ -13,28 +13,28 @@ add_dockerfile_with_renv_ <- function( document = FALSE, ... # build_golem_from_source = TRUE, - ) { +) { + check_dockerfiler_installed() if (is.null(lockfile)) { rlang::check_installed( c("renv", "attachment"), reason = "to build a Dockerfile with automatic renv.lock creation. Use the `lockfile` parameter to pass your own `renv.lock` file." ) } - - + # Small hack to prevent warning from rlang::lang() in tests # This should be managed in {attempt} later on x <- suppressWarnings({ rlang::lang(print) }) - + dir.create(output_dir) - + # add output_dir in Rbuildignore if the output is inside the golem if (normalizePath(dirname(output_dir)) == normalizePath(source_folder)) { usethis_use_build_ignore(output_dir) } - + if (is.null(lockfile)) { if (isTRUE(document)) { cli_cat_line("You set `document = TRUE` and you did not pass your own renv.lock file,") @@ -46,10 +46,10 @@ add_dockerfile_with_renv_ <- function( cli_cat_line("") cli_cat_line("In any case be sure to have no Error or Warning at `devtools::check()`") } - - - - + + + + lockfile <- attachment_create_renv_for_prod( path = source_folder, check_if_suggests_is_installed = FALSE, document = document, @@ -57,7 +57,7 @@ add_dockerfile_with_renv_ <- function( ... ) } - + # fs_file_copy( # path = lockfile, # new_path = output_dir, @@ -74,16 +74,16 @@ add_dockerfile_with_renv_ <- function( expand = expand, extra_sysreqs = extra_sysreqs ) - + socle$write(as = file.path(output_dir, "Dockerfile_base")) - - + + my_dock <- dockerfiler_Dockerfile()$new(FROM = tolower(tolower(paste0(golem::get_golem_name(), "_base")))) - + my_dock$COPY("renv.lock.prod", "renv.lock") - + my_dock$RUN("R -e 'renv::restore()'") - + if (update_tar_gz) { old_version <- list.files(path = output_dir, pattern = paste0(golem::get_golem_name(), "_*.*.tar.gz"), full.names = TRUE) # file.remove(old_version) @@ -100,7 +100,7 @@ add_dockerfile_with_renv_ <- function( ) ) } - + if ( isTRUE( requireNamespace( @@ -128,7 +128,7 @@ add_dockerfile_with_renv_ <- function( stop("please install {pkgbuild}") } } - + # we use an already built tar.gz file my_dock$COPY( from = @@ -202,7 +202,7 @@ add_dockerfile_with_renv <- function( ) base_dock base_dock$write(as = file.path(output_dir, "Dockerfile")) - + out <- sprintf( "docker build -f Dockerfile_base --progress=plain -t %s . docker build -f Dockerfile --progress=plain -t %s . @@ -215,9 +215,9 @@ docker run -p %s:%s %s tolower(paste0(golem::get_golem_name(), ":latest")), port ) - + cat(out, file = file.path(output_dir, "README")) - + open_or_go_to( where = file.path(output_dir, "README"), open_file = open @@ -308,7 +308,7 @@ add_dockerfile_with_renv_heroku <- function( ), ... ) - + apps_h <- gsub( "\\.", "-", @@ -318,34 +318,34 @@ add_dockerfile_with_renv_heroku <- function( golem::get_golem_version() ) ) - + readme_output <- fs_path( output_dir, "README" ) - + write_there <- function(...) { write(..., file = readme_output, append = TRUE) } - + write_there("From your command line, run:\n") - + write_there( sprintf( "docker build -f Dockerfile_base --progress=plain -t %s .", paste0(golem::get_golem_name(), "_base") ) ) - + write_there( sprintf( "docker build -f Dockerfile --progress=plain -t %s .\n", paste0(golem::get_golem_name(), ":latest") ) ) - + write_there("Then, to push on heroku:\n") - + write_there("heroku container:login") write_there( sprintf("heroku create %s", apps_h) @@ -360,11 +360,11 @@ add_dockerfile_with_renv_heroku <- function( sprintf("heroku open --app %s\n", apps_h) ) write_there("> Be sure to have the heroku CLI installed.") - + write_there( sprintf("> You can replace %s with another app name.", apps_h) ) - + # The open is deported here just to be sure # That we open the README once it has been populated open_or_go_to(