Skip to content

Commit

Permalink
Merge pull request #33 from wlandau/main
Browse files Browse the repository at this point in the history
Implement staging
  • Loading branch information
wlandau authored Jul 25, 2024
2 parents 6c6d501 + 8b782fd commit 198738d
Show file tree
Hide file tree
Showing 37 changed files with 232 additions and 797 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: multiverse.internals
Title: Internal Infrastructure for R-multiverse
Description: R-multiverse requires this internal internal infrastructure
package to automate contribution reviews and populate universes.
Version: 0.2.8
Version: 0.2.9
License: MIT + file LICENSE
URL: https://github.com/r-multiverse/multiverse.internals
BugReports: https://github.com/r-multiverse/multiverse.internals/issues
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export(record_versions)
export(review_pull_request)
export(review_pull_requests)
export(try_message)
export(update_production)
export(update_staging)
importFrom(gh,gh)
importFrom(igraph,V)
importFrom(igraph,graph)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# multiverse.internals 0.2.9

* Implement community/staging idea from (@jeroen).

# multiverse.internals 0.2.8

* Only merge contributions created through the web interface.
Expand Down
3 changes: 1 addition & 2 deletions R/record_issues.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#' @section Package issues:
#' Functions like [issues_versions()] and [issues_descriptions()]
#' perform health checks for all packages in R-multiverse.
#' Only packages that pass these checks go to the production repository at
#' <https://production.r-multiverse.org>. For a complete list of checks, see
#' For a complete list of checks, see
#' the `issues_*()` functions listed at
#' <https://r-multiverse.org/multiverse.internals/reference/index.html>.
#' [record_versions()] updates the version number history
Expand Down
172 changes: 0 additions & 172 deletions R/update_production.R

This file was deleted.

73 changes: 73 additions & 0 deletions R/update_staging.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#' @title Update staging
#' @export
#' @description Update the staging universe.
#' @details [update_staging()] controls how packages enter and leave
#' the staging universe. It updates the staging `packages.json`
#' manifest depending on the contents of the community
#' universe and issues with package checks.
#' @return `NULL` (invisibly)
#' @inheritParams record_issues
#' @param path_staging Character string, directory path to the source
#' files of the staging universe.
#' @param path_community Character string, directory path to the source
#' files of the community universe.
#' @param repo_community Character string, URL of the community universe.
#' @examples
#' \dontrun{
#' url_staging = "https://github.com/r-multiverse/staging"
#' url_community = "https://github.com/r-multiverse/community"
#' path_staging <- tempfile()
#' path_community <- tempfile()
#' gert::git_clone(url = url_staging, path = path_staging)
#' gert::git_clone(url = url_community, path = path_community)
#' update_staging(
#' path_staging = path_staging,
#' path_community = path_community,
#' repo_community = "https://community.r-multiverse.org"
#' )
#' }
update_staging <- function(
path_staging,
path_community,
repo_community = "https://community.r-multiverse.org",
mock = NULL
) {
meta_community <- mock$community %||% meta_packages(repo_community)
packages <- promotions(path_community, meta_community)
file_staging <- file.path(path_staging, "packages.json")
file_community <- file.path(path_community, "packages.json")
json_staging <- jsonlite::read_json(file_staging, simplifyVector = TRUE)
json_community <- jsonlite::read_json(file_community, simplifyVector = TRUE)
index_promote <- json_community$package %in% packages
promote <- json_community[index_promote,, drop = FALSE] # nolint
meta_community <- meta_community[, c("package", "remotesha")]
promote <- merge(promote, meta_community, all.x = TRUE, all.y = FALSE)
promote$branch <- promote$remotesha
promote$remotesha <- NULL
replace <- !(json_staging$package %in% packages)
json_staging <- json_staging[replace,, drop = FALSE] # nolint
json_staging <- rbind(json_staging, promote)
json_staging <- json_staging[order(json_staging$package),, drop = FALSE ] # nolint
jsonlite::write_json(json_staging, file_staging, pretty = TRUE)
invisible()
}

promotions <- function(path_community, meta_community) {
promotion_checks <- c(
"descriptions",
"versions"
)
issues <- Filter(
x = list.files(file.path(path_community, "issues")),
f = function(package) {
json <- jsonlite::read_json(
path = file.path(path_community, "issues", package)
)
any(names(json) %in% promotion_checks)
}
)
file_community <- file.path(path_community, "packages.json")
json <- jsonlite::read_json(file_community, simplifyVector = TRUE)
candidates <- intersect(meta_community$package, json$package)
setdiff(candidates, issues)
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

`multiverse.internals` is an R package to support the internal infrastructure for the R-multiverse project.

To learn about specific pieces of the R-multiverse infrastructure for reviewing and checking packages, please visit <https://r-multiverse.org/multiverse.internals/reference>.
To learn about specific pieces of the R-multiverse infrastructure for reviewing and checking packages, please visit <https://r-multiverse.org/multiverse.internals/reference/index.html>.
4 changes: 2 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ reference:
contents:
- record_issues
- record_versions
- title: Production
- title: Staging
contents:
- update_production
- update_staging
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"_wasmbinary": ["none"],
"_winbinary": ["success"],
"_status": ["success"],
"_buildurl": ["https://github.com/r-universe/r-multiverse/actions/runs/9624562787"]
"_buildurl": ["https://github.com/r-universe/r-multiverse/actions/runs/12345"]
},
"date": ["1980-01-01"],
"version": ["2.0.2"],
"remote_hash": ["476886da2b41a4d937543278dc12044889c9d4ca"]
"remote_hash": ["abcdef1234567890abcdef"]
}
16 changes: 0 additions & 16 deletions inst/mock/community/issues/community-descriptions

This file was deleted.

13 changes: 0 additions & 13 deletions inst/mock/community/issues/community-notice

This file was deleted.

13 changes: 0 additions & 13 deletions inst/mock/community/issues/community-remove

This file was deleted.

8 changes: 8 additions & 0 deletions inst/mock/community/issues/descriptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"descriptions": {
"remotes": ["owner1/repo1", "owner2/repo2"]
},
"date": ["2024-06-21"],
"version": ["0.1.1"],
"remote_hash": ["abcdefabcdef1234567890"]
}
13 changes: 0 additions & 13 deletions inst/mock/community/issues/production-notice

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"hash_highest": ["hash_1.0.0"]
},
"date": ["2024-01-01"],
"version": [],
"remote_hash": []
"version": ["1.0.0"],
"remote_hash": ["abcdefabcdefabcdef123123123"]
}
Loading

0 comments on commit 198738d

Please sign in to comment.