diff --git a/.github/workflows/R-CMD-check-HTML5.yaml b/.github/workflows/R-CMD-check-HTML5.yaml deleted file mode 100644 index 83753df03..000000000 --- a/.github/workflows/R-CMD-check-HTML5.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# 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: R-CMD-check-HTML5 - -jobs: - R-CMD-check: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - _R_CHECK_RD_VALIDATE_RD2HTML_: TRUE - steps: - - uses: actions/checkout@v2 - - - name: Install pdflatex - run: sudo apt-get install texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra - - - name: Install tidy - run: sudo apt install tidy - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: 'devel' - http-user-agent: 'release' - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - uses: r-lib/actions/check-r-package@v2 - with: - args: '"--as-cran"' - build_args: 'character()' - error-on: '"note"' diff --git a/.github/workflows/integration-tests-daily.yaml b/.github/workflows/integration-tests-daily.yaml new file mode 100644 index 000000000..60f679e38 --- /dev/null +++ b/.github/workflows/integration-tests-daily.yaml @@ -0,0 +1,73 @@ +on: + schedule: + # every morning at 8am UTC + # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onschedule + - cron: '0 8 * * *' + push: + branches: + - ci-tweaks + +name: integration-tests-daily + +jobs: + integration-tests: + runs-on: ubuntu-20.04 + env: + RSC_VERSION: 2022.09.0 + RSC_REPO_SUFFIX: -preview + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + RSC_LICENSE: ${{ secrets.RSC_LICENSE }} + CONNECTAPI_INTEGRATED: true + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck, local::. + needs: check + + - name: Session info + run: | + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - name: Setup test environment + run: | + connectapi:::build_test_env(rsc_version="daily") + shell: Rscript {0} + + - uses: r-lib/actions/check-r-package@v2 + + - name: Show testthat output + if: always() + run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check + + - name: Notify Slack on Failure + if: ${{ failure() && (startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')) }} + uses: 8398a7/action-slack@v3 + with: + author_name: 'GitHub Actions' + status: failure + fields: action,commit,repo,job,took + icon_emoji: ':sad_parrot:' + text: 'Build on ${{ github.ref }} failed' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_CONNECTAPI }} + GITHUB_TOKEN: ${{ github.token }} diff --git a/R/content.R b/R/content.R index 7b8b81595..0e2d85401 100644 --- a/R/content.R +++ b/R/content.R @@ -149,7 +149,7 @@ Content <- R6::R6Class( id = NA_character_, content_guid = guid, # TODO: what if groups can own content? - principal_guid = self$get_content()$owner, + principal_guid = self$get_content()$owner_guid, principal_type = "user", role = "owner" ) @@ -780,7 +780,8 @@ content_add_group <- function(content, guid, role = c("viewer", "owner")) { .content_add_permission_impl <- function(content, type, guid, role) { existing <- .get_permission(content, type, guid) - if (length(existing) > 0) { + message(existing) + if (length(existing) > 0 && !is.null(existing[[1]][["id"]]) && !is.na(existing[[1]][["id"]])) { message(glue::glue("Updating permission for {type} '{guid}' with role '{role}'")) res <- content$permissions_update( id = existing[[1]]$id, @@ -830,7 +831,7 @@ content_delete_group <- function(content, guid) { .get_permission <- function(content, type, guid, add_owner = TRUE) { res <- content$permissions(add_owner = add_owner) - purrr::keep(res, ~ .x$principal_type == type && .x$principal_guid == guid) + purrr::keep(res, ~.x$principal_type == type && .x$principal_guid == guid) } #' @rdname permissions diff --git a/R/utils-ci.R b/R/utils-ci.R index 361252d75..9a6750cbd 100644 --- a/R/utils-ci.R +++ b/R/utils-ci.R @@ -3,6 +3,28 @@ # TODO: A nicer way to execute these system commands... # - debug output... better error handling... etc. +toggle_integrated <- function(to=NULL) { + env_var <- "CONNECTAPI_INTEGRATED" + curr_val <- FALSE + if (is.null(to)) { + env_val <- Sys.getenv(env_var) + if (tolower(env_val) == "true") { + curr_val <- TRUE + } else { + curr_val <- FALSE + } + } else { + curr_val <- !to + } + + if (curr_val) { + do.call(Sys.setenv, as.list(rlang::set_names("false", env_var))) + } else { + do.call(Sys.setenv, as.list(rlang::set_names("true", env_var))) + } + return(!curr_val) +} + # set up test servers... find_compose <- function() { wh <- processx::process$new("which", "docker-compose", stdout = "|", stderr = "|") @@ -78,6 +100,7 @@ compose_start <- function(connect_license = Sys.getenv("RSC_LICENSE"), rsc_versi args <- c("-f", compose_file_path, "up", "-d") env_vars <- c( RSC_VERSION = rsc_version, + RSC_REPO_SUFFIX = Sys.getenv("RSC_REPO_SUFFIX"), PATH = Sys.getenv("PATH"), license_details$env_params ) diff --git a/inst/ci/test-connect-lic.yml b/inst/ci/test-connect-lic.yml index 9687983a4..ab66c3a1c 100644 --- a/inst/ci/test-connect-lic.yml +++ b/inst/ci/test-connect-lic.yml @@ -3,11 +3,13 @@ services: connect: hostname: connect - image: ghcr.io/rstudio/rstudio-connect:bionic-${RSC_VERSION} + image: ghcr.io/rstudio/rstudio-connect${RSC_REPO_SUFFIX}:bionic-${RSC_VERSION} scale: 2 ports: - 3939 privileged: true + environment: + - RSC_HASTE_ENABLED=true volumes: - "${RSC_LICENSE_FILE}:/etc/rstudio-connect/rstudio-connect.lic" platform: linux/amd64 diff --git a/inst/ci/test-connect.yml b/inst/ci/test-connect.yml index e38c3a075..50a6be3bd 100644 --- a/inst/ci/test-connect.yml +++ b/inst/ci/test-connect.yml @@ -3,7 +3,7 @@ services: connect: hostname: connect - image: ghcr.io/rstudio/rstudio-connect:bionic-${RSC_VERSION} + image: ghcr.io/rstudio/rstudio-connect${RSC_REPO_SUFFIX}:bionic-${RSC_VERSION} scale: 2 ports: - 3939