Skip to content

Commit dfc553a

Browse files
authored
Merge pull request #25 from wlandau/dual-repo
Initial infrastructure for the dual repo approach
2 parents 1c58a2a + 8f0587c commit dfc553a

37 files changed

+1291
-233
lines changed

.github/workflows/check.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
- {os: windows-latest, r: 'release'}
1717
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
1818
- {os: ubuntu-latest, r: 'release'}
19-
- {os: ubuntu-latest, r: 'oldrel-1'}
2019

2120
env:
2221
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pkgdown.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
name: pkgdown
13+
14+
jobs:
15+
pkgdown:
16+
runs-on: ubuntu-latest
17+
concurrency:
18+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
19+
env:
20+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- uses: r-lib/actions/setup-pandoc@v2
25+
26+
- name: system dependencies
27+
if: runner.os == 'Linux'
28+
run: sudo apt-get install -y libmbedtls-dev
29+
30+
- uses: r-lib/actions/setup-r@v2
31+
with:
32+
use-public-rspm: true
33+
34+
- uses: r-lib/actions/setup-r-dependencies@v2
35+
with:
36+
extra-packages: any::pkgdown, local::.
37+
needs: website
38+
cache-version: 2
39+
40+
- name: Build site
41+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
42+
shell: Rscript {0}
43+
44+
- name: Deploy to GitHub pages
45+
if: github.event_name != 'pull_request'
46+
uses: JamesIves/github-pages-deploy-action@v4.6.1
47+
with:
48+
clean: false
49+
branch: gh-pages
50+
folder: docs

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: multiverse.internals
22
Title: Internal Infrastructure for R-multiverse
33
Description: R-multiverse requires this internal internal infrastructure
44
package to automate contribution reviews and populate universes.
5-
Version: 0.1.4
5+
Version: 0.2.0
66
License: MIT + file LICENSE
77
URL: https://github.com/r-multiverse/multiverse.internals
88
BugReports: https://github.com/r-multiverse/multiverse.internals/issues

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ export(assert_cran_url)
55
export(assert_package)
66
export(assert_release_exists)
77
export(get_current_versions)
8+
export(issues_checks)
9+
export(issues_descriptions)
10+
export(issues_versions)
11+
export(meta_checks)
12+
export(meta_packages)
813
export(record_issues)
914
export(record_versions)
1015
export(review_pull_request)

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# multiverse.internals 0.2.0
2+
3+
* Add more checks to `record_issues()`: results from the R-universe check API, plus specific results from package `DESCRIPTION` files.
4+
* Refactor and document specific checks in `check_checks()`, `check_descriptions()`, and `check_versions()`.
5+
* Add a `pkgdown` website.
6+
17
# multiverse.internals 0.1.4
28

39
* Do not write `version_issues.json` from `record_versions()`.

R/issues_checks.R

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#' @title Report issues from R-universe package check results.
2+
#' @export
3+
#' @family issues
4+
#' @description Check R-universe package check results.
5+
#' @details [issues_checks()] reads output from
6+
#' the R-universe check API
7+
#' to scan all R-multiverse packages for issues that may have
8+
#' happened during building and testing.
9+
#' @inheritSection record_issues Package issues
10+
#' @return A named list of information about packages which do not comply
11+
#' with `DESCRPTION` checks. Each name is a package name,
12+
#' and each element contains specific information about
13+
#' non-compliance.
14+
#' @param meta A data frame with R-universe package check results
15+
#' returned by [meta_checks()].
16+
#' @examples
17+
#' meta <- meta_checks(repo = "https://wlandau.r-universe.dev")
18+
#' issues <- issues_checks(meta = meta)
19+
#' str(issues)
20+
issues_checks <- function(meta) {
21+
fields_check <- c(
22+
"_linuxdevel",
23+
"_macbinary",
24+
"_wasmbinary",
25+
"_winbinary",
26+
"_status"
27+
)
28+
fields_info <- c(
29+
"_buildurl"
30+
)
31+
fields <- c(fields_check, fields_info)
32+
for (field in fields) {
33+
meta[[field]][is.na(meta[[field]])] <- "src-failure"
34+
}
35+
success <- rep(TRUE, nrow(meta))
36+
for (field in fields_check) {
37+
success <- success & (meta[[field]] %in% c("success", "skipped"))
38+
}
39+
meta <- meta[!success,, drop = FALSE] # nolint
40+
issues_list(meta[, c("package", fields)])
41+
}

R/issues_descriptions.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#' @title Report `DESCRIPTION` file issues.
2+
#' @export
3+
#' @family issues
4+
#' @description Report issues with the `DESCRIPTION` files of packages.
5+
#' @details [issues_descriptions()] scans downloaded metadata from the
6+
#' `PACKAGES.json` file of an R universe and reports issues with a
7+
#' package's description file, such as the presence of a
8+
#' `"Remotes"` field.
9+
#' @inheritSection record_issues Package issues
10+
#' @return A named list of information about packages which do not comply
11+
#' with `DESCRPTION` checks. Each name is a package name,
12+
#' and each element contains specific information about
13+
#' non-compliance.
14+
#' @param meta A data frame with R-universe package check results
15+
#' returned by [meta_checks()].
16+
#' @examples
17+
#' meta <- meta_packages(repo = "https://wlandau.r-universe.dev")
18+
#' issues <- issues_descriptions(meta = meta)
19+
#' str(issues)
20+
issues_descriptions <- function(meta) {
21+
meta <- issues_descriptions_remotes(meta)
22+
fields <- "remotes"
23+
meta <- meta[, c("package", fields)]
24+
issues_list(meta)
25+
}
26+
27+
issues_descriptions_remotes <- function(meta) {
28+
meta[["remotes"]] <- meta[["remotes"]] %||% replicate(nrow(meta), NULL)
29+
meta$remotes <- lapply(meta$remotes, function(x) x[nzchar(x)])
30+
meta[vapply(meta$remotes, length, integer(1L)) > 0L, ]
31+
}

R/issues_versions.R

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#' @title Check package versions.
2+
#' @export
3+
#' @family issues
4+
#' @description Check package version number history for compliance.
5+
#' @details This function checks the version number history of packages
6+
#' in R-multiverse and reports any packages with issues. The current
7+
#' released version of a given package must be unique, and it must be
8+
#' greater than all the versions of all the previous package releases.
9+
#' @inheritSection record_issues Package issues
10+
#' @return A named list of information about packages which do not comply
11+
#' with version number history checks. Each name is a package name,
12+
#' and each element contains specific information about version
13+
#' non-compliance: the current version number, the current version hash,
14+
#' and the analogous versions and hashes of the highest-versioned
15+
#' release recorded.
16+
#' @inheritParams record_versions
17+
#' @examples
18+
#' # See https://github.com/r-multiverse/checks/blob/main/versions.json
19+
#' # for the official versions JSON for R-multiverse.
20+
#' lines <- c(
21+
#' "[",
22+
#' " {",
23+
#' " \"package\": \"package_unmodified\",",
24+
#' " \"version_current\": \"1.0.0\",",
25+
#' " \"hash_current\": \"hash_1.0.0\",",
26+
#' " \"version_highest\": \"1.0.0\",",
27+
#' " \"hash_highest\": \"hash_1.0.0\"",
28+
#' " },",
29+
#' " {",
30+
#' " \"package\": \"version_decremented\",",
31+
#' " \"version_current\": \"0.0.1\",",
32+
#' " \"hash_current\": \"hash_0.0.1\",",
33+
#' " \"version_highest\": \"1.0.0\",",
34+
#' " \"hash_highest\": \"hash_1.0.0\"",
35+
#' " },",
36+
#' " {",
37+
#' " \"package\": \"version_incremented\",",
38+
#' " \"version_current\": \"2.0.0\",",
39+
#' " \"hash_current\": \"hash_2.0.0\",",
40+
#' " \"version_highest\": \"2.0.0\",",
41+
#' " \"hash_highest\": \"hash_2.0.0\"",
42+
#' " },",
43+
#' " {",
44+
#' " \"package\": \"version_unmodified\",",
45+
#' " \"version_current\": \"1.0.0\",",
46+
#' " \"hash_current\": \"hash_1.0.0-modified\",",
47+
#' " \"version_highest\": \"1.0.0\",",
48+
#' " \"hash_highest\": \"hash_1.0.0\"",
49+
#' " }",
50+
#' "]"
51+
#' )
52+
#' versions <- tempfile()
53+
#' writeLines(lines, versions)
54+
#' out <- issues_versions(versions)
55+
#' str(out)
56+
issues_versions <- function(versions) {
57+
history <- jsonlite::read_json(path = versions, simplifyVector = TRUE)
58+
aligned <- (history$version_current == history$version_highest) &
59+
(history$hash_current == history$hash_highest)
60+
aligned[is.na(aligned)] <- TRUE
61+
out <- history[!aligned,, drop = FALSE] # nolint
62+
issues_list(out)
63+
}

R/meta_checks.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#' @title List metadata about R-universe package checks
2+
#' @export
3+
#' @family list
4+
#' @description List package checks results reported by the
5+
#' R-universe package API.
6+
#' @return A data frame with one row per package and columns with
7+
#' package check results.
8+
#' @param repo Character of length 1, URL of the package repository.
9+
#' R-multiverse uses `"https://multiverse.r-multiverse.org"`.
10+
#' @examples
11+
#' meta_checks(repo = "https://wlandau.r-universe.dev")
12+
meta_checks <- function(repo = "https://multiverse.r-multiverse.org") {
13+
fields <- c(
14+
"_buildurl",
15+
"_linuxdevel",
16+
"_macbinary",
17+
"_wasmbinary",
18+
"_winbinary",
19+
"_status"
20+
)
21+
listing <- file.path(
22+
repo,
23+
"api",
24+
paste0("packages?stream=true&fields=", paste(fields, collapse = ","))
25+
)
26+
out <- jsonlite::stream_in(
27+
con = gzcon(url(listing)),
28+
verbose = FALSE,
29+
simplifyVector = TRUE,
30+
simplifyDataFrame = TRUE,
31+
simplifyMatrix = TRUE
32+
)
33+
colnames(out) <- tolower(colnames(out))
34+
out
35+
}

R/meta_packages.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#' @title List package metadata
2+
#' @export
3+
#' @family meta
4+
#' @description List package metadata in an R universe.
5+
#' @return A data frame with one row per package and columns with package
6+
#' metadata.
7+
#' @inheritParams meta_checks
8+
#' @examples
9+
#' meta_packages(repo = "https://wlandau.r-universe.dev")
10+
meta_packages <- function(repo = "https://multiverse.r-multiverse.org") {
11+
fields <- c("Version", "Remotes", "RemoteSha")
12+
listing <- file.path(
13+
contrib.url(repos = repo, type = "source"),
14+
paste0("PACKAGES.json?fields=", paste(fields, collapse = ","))
15+
)
16+
out <- jsonlite::stream_in(
17+
con = gzcon(url(listing)),
18+
verbose = FALSE,
19+
simplifyVector = TRUE,
20+
simplifyDataFrame = TRUE,
21+
simplifyMatrix = TRUE
22+
)
23+
colnames(out) <- tolower(colnames(out))
24+
out
25+
}

R/package.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#' multiverse.internals: Internal Infrastructure for R-multiverse.
2-
#' @description Internal Infrastructure for R-multiverse.
3-
#' @name multiverse.internals-package
4-
#' @family help
51
#' @importFrom gh gh
62
#' @importFrom jsonlite parse_json read_json stream_in write_json
73
#' @importFrom nanonext ncurl parse_url status_code

0 commit comments

Comments
 (0)