-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ generate_badge_tables
type functions now generate badges statically
#117
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
400d6ad
bump roxygen
jdhoffa 7506c10
fix typo
jdhoffa 9bc222e
adapt unit tests to new input format
jdhoffa 748bb0c
remove superfluous nightly action
jdhoffa 880924a
rework generate_badge_table functions
jdhoffa ee14e05
add format_badges util functions
jdhoffa f62fcf5
update and knit README
jdhoffa 16732c9
add switch for lifecycle types
jdhoffa 230698e
knit README
jdhoffa 6f08a6b
remove unused imports
jdhoffa 8db2607
document
jdhoffa 60e1a55
Merge branch 'main' into make_sitrep_static
jdhoffa 1f4215c
bump dev version
jdhoffa 7d5435b
bump dev version
jdhoffa 5be754f
Merge branch 'main' into make_sitrep_static
jdhoffa 07a8576
style
jdhoffa 010ff34
remove superfluous files
jdhoffa 92d30b8
satisfy the linter
jdhoffa ad40799
style
jdhoffa 23924f6
re-export functions from old generate_*_table
jdhoffa 3775676
document
jdhoffa b1263c3
revert removal of pak and basenc64
jdhoffa 0127f19
rename to build_markdown_link
jdhoffa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: pacta.sit.rep | ||
Title: What the Package Does (One Line, Title Case) | ||
Version: 0.0.0.9008 | ||
Version: 0.0.0.9009 | ||
Authors@R: | ||
person("Jackson", "Hoffart", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-8600-5042")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
build_markdown_link <- function(display, path) { | ||
glue::glue("[{display}]({path})") | ||
} | ||
|
||
format_name_badge <- function(repo_path) { | ||
repo_org <- strsplit(repo_path, "/", fixed = TRUE)[[1L]][[1L]] | ||
repo_name <- strsplit(repo_path, "/", fixed = TRUE)[[1L]][[2L]] | ||
|
||
build_markdown_link( | ||
display = repo_name, | ||
path = glue::glue("https://{tolower(repo_org)}.github.io/{repo_name}/") | ||
) | ||
} | ||
|
||
format_lifecycle_badge <- function(lifecycle) { | ||
stopifnot( | ||
lifecycle %in% c("experimental", "stable", "deprecated", "superseded") | ||
) | ||
|
||
lifecycle_badge_url <- switch( | ||
lifecycle, | ||
experimental = "https://lifecycle.r-lib.org/reference/figures/lifecycle-experimental.svg", # nolint: line_length_linter | ||
stable = "https://lifecycle.r-lib.org/reference/figures/lifecycle-stable.svg", # nolint: line_length_linter | ||
deprecated = "https://lifecycle.r-lib.org/reference/figures/lifecycle-deprecated.svg", # nolint: line_length_linter | ||
superseded = "https://lifecycle.r-lib.org/reference/figures/lifecycle-superseded.svg" # nolint: line_length_linter | ||
) | ||
|
||
build_markdown_link( | ||
display = glue::glue( | ||
"![]({lifecycle_badge_url})" | ||
), | ||
path = glue::glue( | ||
"https://lifecycle.r-lib.org/articles/stages.html#{lifecycle}" | ||
) | ||
) | ||
} | ||
|
||
format_status_badge <- function(repo_path, ci_check) { | ||
build_markdown_link( | ||
display = glue::glue( | ||
"![](https://github.com/{repo_path}/actions/workflows/{ci_check}/badge.svg?branch=main)" # nolint: line_length_linter | ||
), | ||
path = glue::glue( | ||
"https://github.com/{repo_path}/actions/workflows/{ci_check}?query=branch%3Amain" # nolint: line_length_linter | ||
) | ||
) | ||
} | ||
|
||
format_coverage_badge <- function(repo_path) { | ||
build_markdown_link( | ||
display = glue::glue( | ||
"![](https://img.shields.io/codecov/c/github/{tolower(repo_path)}/main)" | ||
), | ||
path = glue::glue("https://app.codecov.io/gh/{repo_path}?branch=main") | ||
) | ||
} | ||
|
||
format_version_badge <- function(repo_path) { | ||
build_markdown_link( | ||
display = glue::glue( | ||
"![](https://img.shields.io/github/r-package/v/{tolower(repo_path)}/main?label=version&labelColor=%23444d56&color=%2334d058)" # nolint: line_length_linter | ||
), | ||
path = glue::glue("https://github.com/{repo_path}/blob/main/DESCRIPTION") | ||
) | ||
} | ||
|
||
format_maintainer_badge <- function(repo_path) { | ||
repo_org <- strsplit(repo_path, "/", fixed = TRUE)[[1L]][[1L]] | ||
repo_name <- strsplit(repo_path, "/", fixed = TRUE)[[1L]][[2L]] | ||
|
||
build_markdown_link( | ||
display = glue::glue( | ||
"![](https://img.shields.io/badge/dynamic/json?label=codeowner&query=codeownerInfo.ownersForFile&url=https%3A%2F%2Fgithub.com%2F{tolower(repo_org)}%2F{tolower(repo_name)}%2Fdeferred-metadata%2Fmain%2F.github%2FCODEOWNERS)" # nolint: line_length_linter | ||
), | ||
path = glue::glue( | ||
"https://github.com/{repo_path}/blob/main/.github/CODEOWNERS" | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#' Generate a table with R package information | ||
#' | ||
#' @param repo_vectors A list of named character vectors. Each character vector | ||
#' should contain: | ||
#' * path - the shortpath to the GitHub repository, including organization | ||
#' (e.g. "RMI-PACTA/r2dii.data") | ||
#' * lifecycle - the lifecycle badge status (e.g. "stable", "experimental") | ||
#' * ci_check - the name of the CI check file (e.g. "R-CMD-check.yaml") | ||
# | ||
#' @return A formatted sitrep tibble. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' | ||
#' repos <- list( | ||
#' c( | ||
#' path = "RMI-PACTA/r2dii.data", | ||
#' lifecycle = "stable", | ||
#' ci_check = "R-CMD-check.yaml" | ||
#' ), | ||
#' c( | ||
#' path = "RMI-PACTA/r2dii.plot", | ||
#' lifecycle = "stable", | ||
#' ci_check = "R.yml" | ||
#' ) | ||
#' ) | ||
#' | ||
#' generate_package_table(repos) | ||
generate_package_table <- function(repo_vectors) { | ||
out <- parse_inputs(repo_vectors) | ||
|
||
out <- dplyr::rowwise(out) | ||
out <- dplyr::transmute( | ||
out, | ||
name = format_name_badge(.data[["path"]]), | ||
lifecycle = format_lifecycle_badge(.data[["lifecycle"]]), | ||
status = format_status_badge(.data[["path"]], .data[["ci_check"]]), | ||
coverage = format_coverage_badge(.data[["path"]]), | ||
version = format_version_badge(.data[["path"]]), | ||
maintainer = format_maintainer_badge(.data[["path"]]) | ||
) | ||
dplyr::ungroup(out) | ||
} | ||
|
||
#' Generate a table with workflow information | ||
#' | ||
#' @param repo_vectors A list of named character vectors. Each character vector | ||
#' should contain: | ||
#' * path - the shortpath to the GitHub repository, including organization | ||
#' (e.g. "RMI-PACTA/workflow.transition.monitor") | ||
#' * lifecycle - the lifecycle badge status (e.g. "stable", "experimental") | ||
#' * ci_check - the name of the CI check file | ||
#' (e.g. "build-Docker-image-triggers.yml") | ||
#' | ||
#' @return A formatted sitrep tibble. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' | ||
#' repos <- list( | ||
#' c( | ||
#' path = "RMI-PACTA/workflow.transition.monitor", | ||
#' lifecycle = "stable", | ||
#' ci_check = "build-Docker-image-triggers.yml" | ||
#' ), | ||
#' c( | ||
#' path = "RMI-PACTA/workflow.data.preparation", | ||
#' lifecycle = "stable", | ||
#' ci_check = "docker.yml" | ||
#' ) | ||
#' ) | ||
#' | ||
#' generate_workflow_table(repos) | ||
generate_workflow_table <- function(repo_vectors) { | ||
out <- parse_inputs(repo_vectors) | ||
|
||
out <- dplyr::rowwise(out) | ||
out <- dplyr::transmute( | ||
out, | ||
name = format_name_badge(.data[["path"]]), | ||
lifecycle = format_lifecycle_badge(.data[["lifecycle"]]), | ||
status = format_status_badge(.data[["path"]], .data[["ci_check"]]), | ||
maintainer = format_maintainer_badge(.data[["path"]]) | ||
) | ||
dplyr::ungroup(out) | ||
} | ||
|
||
check_inputs <- function(repo_vectors) { | ||
stopifnot( | ||
is.list(repo_vectors), | ||
all(purrr::map_lgl(repo_vectors, is.character)), | ||
all(purrr::map_lgl(repo_vectors, ~ length(.x) == 3L)), | ||
all( | ||
purrr::map_lgl( | ||
repo_vectors, | ||
~ all(names(.x) %in% c("path", "lifecycle", "ci_check")) | ||
) | ||
) | ||
) | ||
} | ||
|
||
parse_inputs <- function(repo_vectors) { | ||
check_inputs(repo_vectors) | ||
purrr::map_dfr(repo_vectors, ~ tibble::as_tibble(as.list(.))) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of the relevant repos use
main
notmaster
, so this is not a problem?