Skip to content

Commit

Permalink
Merge branch 'main' into repo-status
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm authored Apr 9, 2024
2 parents 3a2a783 + a0f26b1 commit 0d68555
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 22 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^\.Rproj\.user$
^assets$
^README\.Rmd$
^\.github$
5 changes: 5 additions & 0 deletions .github/workflows/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @jdhoffa will be requested for review when someone opens
# a pull request.
* @jdhoffa
22 changes: 22 additions & 0 deletions .github/workflows/R.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# This example file will enable R language checks on push or PR to the main
# branch.
# It will also run the checks every weeknight at midnight UTC
#
# Note the @main in `uses:` on the last line. This will call the latest version
# of the workflow from the `main` brnach in the RMI-PACTA/actions repo. You can
# also specify a tag from that repo, or a commit SHA to pin action versions.
on:
pull_request:
push:
branches: [main]
schedule:
- cron: '0 0 * * 1,2,3,4,5'
workflow_dispatch:

name: R

jobs:
R-package:
name: R Package Checks
uses: RMI-PACTA/actions/.github/workflows/R.yml@main
4 changes: 3 additions & 1 deletion DESCRIPTION
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.9000
Version: 0.0.0.9002
Authors@R:
person("Jackson", "Hoffart", , "jackson.hoffart@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-8600-5042"))
Expand All @@ -14,7 +14,9 @@ Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Imports:
dplyr,
gh,
glue,
purrr,
rlang,
tibble
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(generate_package_table)
importFrom(rlang,.data)
22 changes: 13 additions & 9 deletions R/generate_package_table.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Generate a table with R package information
#'
#' @param repo_paths A character vector with GH paths to the R package repositories
#' @param repo_paths A character vector with GH paths to the R package
#' repositories
#'
#' @return A tibble with the following columns:
#' * Repo
Expand All @@ -24,11 +25,11 @@ generate_package_table <- function(repo_paths) {

dplyr::transmute(
out,
Repo = format_repo_v(repo),
Lifecycle = format_lifecycle_v(lifecycle),
Status = format_status_v(repo, status),
Latest_SHA = format_latest_sha_v(repo, sha),
Maintainer = format_maintainer_v(maintainer)
Repo = format_repo_v(.data[["repo"]]),
Lifecycle = format_lifecycle_v(.data[["lifecycle"]]),
Status = format_status_v(.data[["repo"]], .data[["status"]]),
Latest_SHA = format_latest_sha_v(.data[["repo"]], .data[["sha"]]),
Maintainer = format_maintainer_v(.data[["maintainer"]])
)
}

Expand Down Expand Up @@ -59,7 +60,9 @@ format_status <- function(repo, r_cmd_check_status) {
}

desc <- "![R-CMD-check]"
link <- glue::glue("https://github.com/{repo}/actions/workflows/R-CMD-check.yaml")
link <- glue::glue(
"https://github.com/{repo}/actions/workflows/R-CMD-check.yaml"
)

glue::glue("[{desc}({r_cmd_check_status})]({link})")
}
Expand Down Expand Up @@ -114,8 +117,9 @@ table_lifecycle <- function(repo_path) {
}

table_status <- function(repo_path) {
r_cmd_check_status <- glue::glue(
"https://github.com/{repo_path}/actions/workflows/R-CMD-check.yaml/badge.svg"
r_cmd_check_status <- glue::glue(
"https://github.com/{repo_path}",
"/actions/workflows/R-CMD-check.yaml/badge.svg"
)

return(r_cmd_check_status)
Expand Down
2 changes: 2 additions & 0 deletions R/imports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#' @importFrom rlang .data
NULL
14 changes: 14 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ transition_monitor_repos <- c(
"RMI-PACTA/pacta.portfolio.import",
"RMI-PACTA/pacta.portfolio.audit",
"RMI-PACTA/pacta.portfolio.allocate",
"RMI-PACTA/pacta.portfolio.report",
"RMI-PACTA/pacta.executive.summary",
"RMI-PACTA/pacta.portfolio.utils"
)
Expand All @@ -60,6 +61,19 @@ knitr::kable(tm_table)
```

### PACTA for Supervisors

``` {r echo = FALSE, results = "asis"}
transition_monitor_repos <- c(
"RMI-PACTA/pacta.multi.loanbook.analysis",
"RMI-PACTA/pacta.multi.loanbook.plot"
)
tm_table <- pacta.sit.rep::generate_package_table(transition_monitor_repos)
knitr::kable(tm_table)
```

## Transition Monitor Docker Build Status

| Commit time | Git sha | Project code | Holdings date | Language | Peer group | Report | Image |
Expand Down
26 changes: 17 additions & 9 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion man/generate_package_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions tests/testthat/test-generate_package_table.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
test_that("multiplication works", {
expect_identical(2L * 2L, 4L)
library(testthat)

Check warning on line 1 in tests/testthat/test-generate_package_table.R

View workflow job for this annotation

GitHub Actions / R Package Checks / lintr / lint

file=tests/testthat/test-generate_package_table.R,line=1,col=1,[undesirable_function_linter] Function "library" is undesirable. As an alternative, use roxygen2's @importFrom statement in packages and `::` in scripts, instead of modifying the global search path.
library(dplyr)

Check warning on line 2 in tests/testthat/test-generate_package_table.R

View workflow job for this annotation

GitHub Actions / R Package Checks / lintr / lint

file=tests/testthat/test-generate_package_table.R,line=2,col=1,[undesirable_function_linter] Function "library" is undesirable. As an alternative, use roxygen2's @importFrom statement in packages and `::` in scripts, instead of modifying the global search path.

pacta_r_package_path <- "https://github.com/RMI-PACTA/pacta.r.package"

test_that("returns correct structure and data", {
result <- generate_package_table(pacta_r_package_path)
expected_names <- c("Repo", "Lifecycle", "Status", "Latest_SHA", "Maintainer")

expect_true(tibble::is_tibble(result))
expect_equal(ncol(result), 5)
expect_true(all(expected_names %in% names(result)))
})

test_that("handles empty input", {
empty_input <- character(0)
result <- generate_package_table(empty_input)

expect_true(tibble::is_tibble(result) && nrow(result) == 0)
})

0 comments on commit 0d68555

Please sign in to comment.