|
| 1 | +# This workflow calls the GitHub API very frequently. |
| 2 | +# Can't be run as part of commits |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '5 0 * * *' |
| 6 | + push: |
| 7 | + paths: |
| 8 | + - ".github/workflows/R-CMD-check-dev.yaml" |
| 9 | + |
| 10 | +name: rcc dev |
| 11 | + |
| 12 | +jobs: |
| 13 | + matrix: |
| 14 | + runs-on: ubuntu-18.04 |
| 15 | + outputs: |
| 16 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 17 | + |
| 18 | + name: Collect deps |
| 19 | + |
| 20 | + env: |
| 21 | + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true |
| 22 | + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest |
| 23 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + # prevent rgl issues because no X11 display is available |
| 25 | + RGL_USE_NULL: true |
| 26 | + # Begin custom: env vars |
| 27 | + # End custom: env vars |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Check rate limits |
| 31 | + run: | |
| 32 | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit |
| 33 | + shell: bash |
| 34 | + |
| 35 | + - uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - uses: r-lib/actions/setup-r@v1 |
| 38 | + with: |
| 39 | + install-r: false |
| 40 | + |
| 41 | + - id: set-matrix |
| 42 | + run: | |
| 43 | + # Determine package dependencies |
| 44 | + # From remotes |
| 45 | + read_dcf <- function(path) { |
| 46 | + fields <- colnames(read.dcf(path)) |
| 47 | + as.list(read.dcf(path, keep.white = fields)[1, ]) |
| 48 | + } |
| 49 | +
|
| 50 | + re_match <- function(text, pattern, perl = TRUE, ...) { |
| 51 | +
|
| 52 | + stopifnot(is.character(pattern), length(pattern) == 1, !is.na(pattern)) |
| 53 | + text <- as.character(text) |
| 54 | +
|
| 55 | + match <- regexpr(pattern, text, perl = perl, ...) |
| 56 | +
|
| 57 | + start <- as.vector(match) |
| 58 | + length <- attr(match, "match.length") |
| 59 | + end <- start + length - 1L |
| 60 | +
|
| 61 | + matchstr <- substring(text, start, end) |
| 62 | + matchstr[ start == -1 ] <- NA_character_ |
| 63 | +
|
| 64 | + res <- data.frame( |
| 65 | + stringsAsFactors = FALSE, |
| 66 | + .text = text, |
| 67 | + .match = matchstr |
| 68 | + ) |
| 69 | +
|
| 70 | + if (!is.null(attr(match, "capture.start"))) { |
| 71 | +
|
| 72 | + gstart <- attr(match, "capture.start") |
| 73 | + glength <- attr(match, "capture.length") |
| 74 | + gend <- gstart + glength - 1L |
| 75 | +
|
| 76 | + groupstr <- substring(text, gstart, gend) |
| 77 | + groupstr[ gstart == -1 ] <- NA_character_ |
| 78 | + dim(groupstr) <- dim(gstart) |
| 79 | +
|
| 80 | + res <- cbind(groupstr, res, stringsAsFactors = FALSE) |
| 81 | + } |
| 82 | +
|
| 83 | + names(res) <- c(attr(match, "capture.names"), ".text", ".match") |
| 84 | + class(res) <- c("tbl_df", "tbl", class(res)) |
| 85 | + res |
| 86 | + } |
| 87 | +
|
| 88 | + dev_split_ref <- function(x) { |
| 89 | + re_match(x, "^(?<pkg>[^@#]+)(?<ref>[@#].*)?$") |
| 90 | + } |
| 91 | +
|
| 92 | + has_dev_dep <- function(package) { |
| 93 | + cran_url <- "https://cloud.r-project.org" |
| 94 | +
|
| 95 | + refs <- dev_split_ref(package) |
| 96 | + url <- file.path(cran_url, "web", "packages", refs[["pkg"]], "DESCRIPTION") |
| 97 | +
|
| 98 | + f <- tempfile() |
| 99 | + on.exit(unlink(f)) |
| 100 | +
|
| 101 | + utils::download.file(url, f) |
| 102 | + desc <- read_dcf(f) |
| 103 | +
|
| 104 | + url_fields <- c(desc$URL, desc$BugReports) |
| 105 | +
|
| 106 | + if (length(url_fields) == 0) { |
| 107 | + return(FALSE) |
| 108 | + } |
| 109 | +
|
| 110 | + pkg_urls <- unlist(strsplit(url_fields, "[[:space:]]*,[[:space:]]*")) |
| 111 | +
|
| 112 | + # Remove trailing "/issues" from the BugReports URL |
| 113 | + pkg_urls <- sub("/issues$", "", pkg_urls) |
| 114 | +
|
| 115 | + valid_domains <- c("github[.]com", "gitlab[.]com", "bitbucket[.]org") |
| 116 | +
|
| 117 | + parts <- |
| 118 | + re_match(pkg_urls, |
| 119 | + sprintf("^https?://(?<domain>%s)/(?<username>%s)/(?<repo>%s)(?:/(?<subdir>%s))?", |
| 120 | + domain = paste0(valid_domains, collapse = "|"), |
| 121 | + username = "[^/]+", |
| 122 | + repo = "[^/@#]+", |
| 123 | + subdir = "[^/@$ ]+" |
| 124 | + ) |
| 125 | + )[c("domain", "username", "repo", "subdir")] |
| 126 | +
|
| 127 | + # Remove cases which don't match and duplicates |
| 128 | +
|
| 129 | + parts <- unique(stats::na.omit(parts)) |
| 130 | +
|
| 131 | + nrow(parts) == 1 |
| 132 | + } |
| 133 | +
|
| 134 | + if (!requireNamespace("desc", quietly = TRUE)) { |
| 135 | + install.packages("desc") |
| 136 | + } |
| 137 | +
|
| 138 | + deps_df <- desc::desc_get_deps() |
| 139 | + deps_df <- deps_df[deps_df$type %in% c("Depends", "Imports", "LinkingTo", "Suggests"), ] |
| 140 | +
|
| 141 | + packages <- sort(deps_df$package) |
| 142 | + packages <- intersect(packages, rownames(available.packages())) |
| 143 | +
|
| 144 | + valid_dev_dep <- vapply(packages, has_dev_dep, logical(1)) |
| 145 | +
|
| 146 | + # https://github.com/r-lib/remotes/issues/576 |
| 147 | + valid_dev_dep[packages %in% c("igraph", "duckdb", "logging")] <- FALSE |
| 148 | +
|
| 149 | + deps <- packages[valid_dev_dep] |
| 150 | + if (any(!valid_dev_dep)) { |
| 151 | + msg <- paste0( |
| 152 | + "Could not determine development repository for packages: ", |
| 153 | + paste(packages[!valid_dev_dep], collapse = ", ") |
| 154 | + ) |
| 155 | + writeLines(paste0("::warning::", msg)) |
| 156 | + } |
| 157 | +
|
| 158 | + json <- paste0( |
| 159 | + '{"package":[', |
| 160 | + paste0('"', deps, '"', collapse = ","), |
| 161 | + ']}' |
| 162 | + ) |
| 163 | + writeLines(json) |
| 164 | + writeLines(paste0("::set-output name=matrix::", json)) |
| 165 | + shell: Rscript {0} |
| 166 | + |
| 167 | + check-matrix: |
| 168 | + runs-on: ubuntu-18.04 |
| 169 | + needs: matrix |
| 170 | + steps: |
| 171 | + - name: Install json2yaml |
| 172 | + run: | |
| 173 | + sudo npm install -g json2yaml |
| 174 | +
|
| 175 | + - name: Check matrix definition |
| 176 | + run: | |
| 177 | + matrix='${{ needs.matrix.outputs.matrix }}' |
| 178 | + echo $matrix |
| 179 | + echo $matrix | jq . |
| 180 | + echo $matrix | json2yaml |
| 181 | +
|
| 182 | + R-CMD-check-dev: |
| 183 | + needs: matrix |
| 184 | + |
| 185 | + runs-on: ubuntu-18.04 |
| 186 | + |
| 187 | + name: ${{ matrix.package }} |
| 188 | + |
| 189 | + # Begin custom: services |
| 190 | + # End custom: services |
| 191 | + |
| 192 | + strategy: |
| 193 | + fail-fast: false |
| 194 | + matrix: ${{fromJson(needs.matrix.outputs.matrix)}} |
| 195 | + |
| 196 | + env: |
| 197 | + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true |
| 198 | + RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest |
| 199 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 200 | + # prevent rgl issues because no X11 display is available |
| 201 | + RGL_USE_NULL: true |
| 202 | + # Begin custom: env vars |
| 203 | + # End custom: env vars |
| 204 | + |
| 205 | + steps: |
| 206 | + - name: Check rate limits |
| 207 | + run: | |
| 208 | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit |
| 209 | + shell: bash |
| 210 | + |
| 211 | + - uses: actions/checkout@v2 |
| 212 | + |
| 213 | + # Begin custom: before install |
| 214 | + # End custom: before install |
| 215 | + |
| 216 | + - uses: r-lib/actions/setup-r@v1 |
| 217 | + with: |
| 218 | + install-r: false |
| 219 | + |
| 220 | + - uses: r-lib/actions/setup-pandoc@v1 |
| 221 | + |
| 222 | + - name: Install remotes |
| 223 | + run: | |
| 224 | + if (!requireNamespace("curl", quietly = TRUE)) install.packages("curl") |
| 225 | + if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes") |
| 226 | + shell: Rscript {0} |
| 227 | + |
| 228 | + - name: Prepare cache keys |
| 229 | + if: runner.os != 'Windows' |
| 230 | + id: date |
| 231 | + run: echo "::set-output name=date::$(date -Ihours)" |
| 232 | + |
| 233 | + - name: Cache R packages |
| 234 | + if: runner.os != 'Windows' |
| 235 | + uses: actions/cache@v2 |
| 236 | + with: |
| 237 | + path: ${{ env.R_LIBS_USER }} |
| 238 | + key: ubuntu-18.04-r-dev-release-${{ matrix.package }}-${{steps.date.outputs.date}} |
| 239 | + restore-keys: ubuntu-18.04-r-dev-release-${{ matrix.package }}- |
| 240 | + |
| 241 | + - name: Install system dependencies |
| 242 | + if: runner.os == 'Linux' |
| 243 | + run: | |
| 244 | + sudo apt-get update -y |
| 245 | + while read -r cmd |
| 246 | + do |
| 247 | + eval sudo $cmd |
| 248 | + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "18.04"))') |
| 249 | +
|
| 250 | + - name: Add fake qpdf and checkbashisms |
| 251 | + if: runner.os == 'Linux' |
| 252 | + run: | |
| 253 | + sudo ln -s $(which true) /usr/local/bin/qpdf |
| 254 | + sudo ln -s $(which true) /usr/local/bin/checkbashisms |
| 255 | +
|
| 256 | + - name: Install dependencies |
| 257 | + run: | |
| 258 | + remotes::install_deps(dependencies = TRUE) |
| 259 | + update.packages(.libPaths()[[1]], ask = FALSE) |
| 260 | + remotes::install_dev("${{ matrix.package }}", "https://cloud.r-project.org", upgrade = "always") |
| 261 | + remotes::install_cran("rcmdcheck") |
| 262 | + shell: Rscript {0} |
| 263 | + |
| 264 | + - name: Session info |
| 265 | + run: | |
| 266 | + options(width = 100) |
| 267 | + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") |
| 268 | + pkgs <- installed.packages()[, "Package"] |
| 269 | + sessioninfo::session_info(pkgs, include_base = TRUE) |
| 270 | + shell: Rscript {0} |
| 271 | + |
| 272 | + # Begin custom: after install |
| 273 | + # End custom: after install |
| 274 | + |
| 275 | + - name: Check |
| 276 | + env: |
| 277 | + _R_CHECK_CRAN_INCOMING_: false |
| 278 | + _R_CHECK_SYSTEM_CLOCK_: false |
| 279 | + _R_CHECK_FUTURE_FILE_TIMESTAMPS_: false |
| 280 | + run: | |
| 281 | + options(crayon.enabled = TRUE) |
| 282 | + error_on <- "note" |
| 283 | + # Begin custom: rcmdcheck error_on |
| 284 | + # End custom: rcmdcheck error_on |
| 285 | + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = error_on, check_dir = "check") |
| 286 | + shell: Rscript {0} |
| 287 | + |
| 288 | + - name: Show test output |
| 289 | + if: always() |
| 290 | + run: | |
| 291 | + find check -name '*.Rout*' -exec head -n 1000000 '{}' \; || true |
| 292 | + shell: bash |
| 293 | + |
| 294 | + - name: Upload check results |
| 295 | + if: failure() |
| 296 | + uses: actions/upload-artifact@main |
| 297 | + with: |
| 298 | + name: ${{ matrix.package }}-results |
| 299 | + path: check |
| 300 | + |
| 301 | + - name: Check rate limits |
| 302 | + if: always() |
| 303 | + run: | |
| 304 | + curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit |
| 305 | + shell: bash |
0 commit comments