Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from openpharma/add/labels
Browse files Browse the repository at this point in the history
Merge in issue labels function
  • Loading branch information
epijim authored Nov 8, 2021
2 parents d549d1d + 06d2aab commit 32d8e2f
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: R Package Validation report

on: # Run this action when a release is published
release:
types: [published]

jobs:
r-pkg-validation:
name: Create report 📃
runs-on: ubuntu-latest
# Set Github token permissions
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
packages: write
deployments: write
steps:
- name: Checkout repo 🛎
uses: actions/checkout@v2

- name: Build report 🏗
uses: insightsengineering/thevalidatoR@main
# see parameters above for custom templates and other formats

# Upload the validation report to the release
- name: Upload report to release 🔼
if: success()
uses: svenstaro/upload-release-action@v2
with:
file: ./validation_report.pdf
asset_name: validation-report.pdf
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
README-roche.Rmd
docs
README.html

.DS_Store
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ Imports:
tibble,
base64enc,
lubridate
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Suggests:
covr,
testthat (>= 3.0.0),
vcr,
tidyverse
Config/testthat/edition: 3

1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(gh_commits_get)
export(gh_file_get)
export(gh_issues_get)
export(gh_issues_labels_get)
export(gh_repo_files_get)
export(gh_repo_search)
export(gh_repos_clean)
Expand Down
67 changes: 67 additions & 0 deletions R/gh_issues_labels_get.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#' Get issues for a repo
#'
#' @param full_names Vector of repo names (format 'org/repo')
#' @param days_back How many days back to look for commits.
#' @param state Defaults to open. Search issues based on open, closed or all.
#' @param ... Pass down options to \code{gh::gh()}
#'
#' @importFrom magrittr "%>%"
#'
#' @export
#'
#' @details
#'
#' \strong{New Columns}
#'
#' \describe{
#'
#' \item{url}{URL for the issue}
#' \item{label_name}{Name of the label}
#' \item{label_color}{Hex colour}
#' \item{label_description}{Label description}
#' }
#'
gh_issues_labels_get <- function(
full_names,
days_back = 30,
state = c("open","closed","all"),
...
) {
since <- Sys.Date() - days_back

# Loop through full names
labels <- NULL
for (i_repo in full_names) {
i_issues <- gh::gh("GET /repos/:full_name/issues?state=:state",
full_name = i_repo,
since = since,
.limit = Inf,
state = state ,
.progress = FALSE,
...
)
urls <- i_issues %>%
purrr::map_chr(c("html_url"), .null = NA_character_)
# Loop through issues in a repo
for (i_issue_n in seq_along(i_issues)) {
i_issue <- i_issues[[i_issue_n]] # not this!

i_labels <- tibble::tibble(
url = urls[i_issue_n],
label_name = i_issue$labels %>%
purrr::map_chr(c("name"), .null = NA_character_),
label_color = i_issue$labels %>%
purrr::map_chr(c("color"), .null = NA_character_),
label_description = i_issue$labels %>%
purrr::map_chr(c("description"), .null = NA_character_)
)

labels <- dplyr::bind_rows(
i_labels, labels
)
}
}
labels
}


36 changes: 36 additions & 0 deletions man/gh_issues_labels_get.Rd

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

0 comments on commit 32d8e2f

Please sign in to comment.