Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builder: GH releases + GHCR helper functions #311

Merged
merged 51 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
35bb000
Builder: GH releases + GHCR helper functions
gaborcsardi Apr 2, 2023
dd3b0a5
Builder: change file names
gaborcsardi Apr 4, 2023
27c583a
Add 'RemoteBuildPlatform' to installed metadata
gaborcsardi Apr 4, 2023
add3978
Repo functions, first PoC
gaborcsardi Apr 4, 2023
2bf75e2
Add `RemoteBuildPlatform` when building binary
gaborcsardi Apr 4, 2023
278f773
Fix adding metadata
gaborcsardi Apr 4, 2023
d5600b1
Encapsulate repo* & ghr*, add interanal docs for them
gaborcsardi May 1, 2023
2c661b1
Spelling fixes
gaborcsardi May 1, 2023
48366e9
Refactor ghr and repo docs
gaborcsardi May 2, 2023
4e210bf
Builder: add internals ids to package and repo
gaborcsardi May 2, 2023
3b104dd
pkg_build: allow extending the platform string
gaborcsardi May 2, 2023
4a30ef0
Update docs
gaborcsardi May 2, 2023
6eedcf0
Export pkg_build
gaborcsardi May 2, 2023
84afd50
Export ghr, repo, make pkg_build docs internal
gaborcsardi May 2, 2023
cfa9f38
US spelling
gaborcsardi May 2, 2023
89e1321
Add repo$list_gh()
gaborcsardi May 3, 2023
a08c364
Rebuild NAMESPACE
gaborcsardi Jun 16, 2023
01b3a4d
Support build number in pkg_build()
gaborcsardi Jun 16, 2023
64abc64
Code formatting
gaborcsardi Jun 16, 2023
eec5d5d
repo$update_gh() can update multiple files at once
gaborcsardi Jun 16, 2023
9b4d9de
First PoC of update for repo w/ GH releases
gaborcsardi Jun 21, 2023
06b8ca5
Use Config/Needs/builder
gaborcsardi Jun 21, 2023
bf6275e
Builder: handle a corner case
gaborcsardi Jun 21, 2023
a0925ea
repo: include `SystemRequirements` field as well
gaborcsardi Jun 23, 2023
da3f8b6
Remove acromine from pkg name check
gaborcsardi Jun 24, 2023
b4eab8c
Fix tests for pkg name check changes
gaborcsardi Jun 24, 2023
1b380aa
Fix repo typo
gaborcsardi Jun 24, 2023
687cfb0
Merge branch 'main' into feature/builder
gaborcsardi Jun 26, 2023
e8f55d1
Merge branch 'main' into feature/builder
gaborcsardi Jun 26, 2023
b18f716
repo: fix reop$update()
gaborcsardi Jul 9, 2023
18fc3e3
Merge branch 'main' into feature/builder
gaborcsardi Feb 10, 2024
cdb9378
Eliminate prettyunits dependency
gaborcsardi Feb 10, 2024
09f1541
Handle build failues
gaborcsardi Feb 10, 2024
3047b38
ghrepo: ignore build errors by default
gaborcsardi Feb 10, 2024
ef2589f
Need glue::glue now, glue is not imported
gaborcsardi Feb 11, 2024
4022675
Avoid jsonlite::toJSON, we don't import it now
gaborcsardi Feb 11, 2024
dca13de
ghrepo: fix filtering out failed builds
gaborcsardi Feb 11, 2024
949b6b0
Update test snapshots
gaborcsardi Feb 18, 2024
7de2712
Set $build_error to `FALSE` on success
gaborcsardi Feb 18, 2024
4943ca4
Fix gh-repo builder for $build_error being FALSE
gaborcsardi Feb 23, 2024
c57dec4
GH builder: support macOS binaries
gaborcsardi Mar 13, 2024
c01bf84
GHA repos: fix update check on non-Linux
gaborcsardi Mar 13, 2024
e0ab6cc
Fix build summary after update
gaborcsardi Mar 19, 2024
8fc70d2
Retry GH package upload on error
gaborcsardi Mar 19, 2024
178003b
GH release update: wait a bit between updates
gaborcsardi Mar 19, 2024
dc4ad6a
GH repo: make sure build_time is difftime
gaborcsardi Mar 19, 2024
5cfabff
format_time$pretty_dt better NAs
gaborcsardi Mar 19, 2024
2c68a1b
Retry another GH query
gaborcsardi Mar 19, 2024
ec8f44d
GH repo: sleep more between adding release assets
gaborcsardi Mar 27, 2024
4d7cf66
Merge branch 'main' into feature/builder
gaborcsardi Jul 29, 2024
a5801b5
Merge branch 'main' into feature/builder
gaborcsardi Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Suggests:
debugme,
fansi,
fs,
gh,
gitcreds,
glue,
htmlwidgets,
mockery,
Expand All @@ -54,6 +56,12 @@ Suggests:
testthat (>= 3.2.0),
tibble,
webfakes (>= 1.1.5.9000),
withr (>= 2.1.1),
Remotes:
r-lib/pkgcache
Config/Needs/builder:
gh,
pkgsearch,
withr (>= 2.1.1)
Config/Needs/coverage:
r-lib/asciicast,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export(as_pkg_dependencies)
export(current_config)
export(current_r_platform)
export(default_platforms)
export(ghr)
export(ghrepo)
export(install_package_plan)
export(is_valid_package_name)
export(lib_status)
Expand All @@ -41,6 +43,7 @@ export(new_pkg_installation_plan)
export(new_pkg_installation_proposal)
export(parse_pkg_ref)
export(parse_pkg_refs)
export(pkg_build)
export(pkg_dep_types)
export(pkg_dep_types_hard)
export(pkg_dep_types_soft)
Expand All @@ -50,6 +53,7 @@ export(pkg_installation_plan)
export(pkg_installation_proposal)
export(pkg_name_check)
export(pkg_rx)
export(repo)
export(sysreqs_check_installed)
export(sysreqs_db_list)
export(sysreqs_db_match)
Expand Down
86 changes: 86 additions & 0 deletions R/builder.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

#' Create a binary package from an installed package
#'
#' The built package will be in the current working directory.
#'
#' This function is currently experimental.
#'
#' @param pkg Package name.
#' @param library Library path.
#' @param flavor Platform flavor. Defaults to the `PKG_BUILD_FLAVOR`
#' environment variable. If not `NULL` or an empty string, then it is
#' appended to the platform string with a dash.
#' @param build_number An integer number that is added to the file name,
#' after the version number, to be able to have multiple builds for the
#' same package version.
#' @return Path to the built package.
#'
#' @export
#' @keywords internal

pkg_build <- function(pkg, library = .libPaths()[1],
flavor = Sys.getenv("PKG_BUILD_FLAVOR"),
build_number = 1L) {
pkgdir <- file.path(library, pkg)
if (!dir.exists(pkgdir)) {
throw(pkg_error(
"Cannot find package {.pkg {pkg}} in library at {.path {library}}."
))
}
platform <- pkgcache::current_r_platform()
if (nzchar(flavor %||% "")) {
platform <- paste0(platform, "-", flavor)
}
meta <- c(
RemoteBuildPlatform = platform,
GraphicsAPIVersion = pkgcache::get_graphics_api_version(),
InternalsId = pkgcache::get_internals_id()
)
add_metadata(pkgdir, meta)
dsc <- desc::desc(file = pkgdir)
version <- dsc$get_field("Version")
rversion <- get_minor_r_version(getRversion())

sys <- sysname()
if (sys == "windows") {
install_md5_sums(pkg)
fn <- paste0(
pkg, "_", version, "_",
"b", build_number, "_",
"R", rversion,
if (nzchar(flavor %||% "")) paste0("_", flavor),
".zip"
)
zip::zip(fn, pkgdir, mode = "cherry-pick")

} else {
ext <- if (sys == "mac") ".tgz" else ".tar.gz"
fn <- paste0(
pkg, "_", version, "_",
"b", build_number, "_",
"R", rversion, "_",
platform,
ext
)
ffn <- file.path(normalizePath("."), fn)
old <- getwd()
on.exit(setwd(old), add = TRUE)
setwd(dirname(pkgdir))
utils::tar(ffn, pkg, compression = "gzip", compression_level = 9)
}

fn
}

install_md5_sums <- function(pkgdir) {
old <- getwd()
on.exit(setwd(old), add = TRUE)

setwd(pkgdir)
fns <- setdiff(dir(".", recursive = TRUE), "MD5")
md5 <- cli::hash_file_md5(fns)
writeLines(
paste0(md5, " *", fns),
"MD5"
)
}
Loading
Loading