Skip to content

Commit

Permalink
Merge pull request #144 from NCEAS/gha-repair
Browse files Browse the repository at this point in the history
GitHub Action Repair
  • Loading branch information
njlyon0 authored Apr 16, 2024
2 parents cc10d1f + c0f8a63 commit e9d673e
Show file tree
Hide file tree
Showing 84 changed files with 458 additions and 5,440 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
^Meta$
^doc$
^docs$
^dev$
^_pkgdown\.yml$
^.*\.Rproj$
^\.Rproj\.user$
Expand Down
63 changes: 41 additions & 22 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,54 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- dev
- main
branches: [main, master]
pull_request:
branches:
- dev
- main
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: macOS-latest
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
PKG_SYSREQS: false

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-r@v1
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- name: Install udunits
run: brew install udunits
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}

- name: dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt-get install -y libcurl4-gnutls-dev libicu-dev libjq-dev libnode-dev librdf0-dev libssl-dev libxml2-dev make pandoc

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
42 changes: 29 additions & 13 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
Expand All @@ -12,27 +14,41 @@ name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
PKG_SYSREQS: false
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install udunit2
run: sudo apt-get install libudunits2-dev
- name: dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt-get install -y make libicu-dev libxml2-dev libssl-dev pandoc librdf0-dev libnode-dev libcurl4-gnutls-dev

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: pkgdown
extra-packages: any::pkgdown, local::.
needs: website

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
Rscript -e 'pkgdown::deploy_to_branch(github_pages = (branch == "gh-pages"), new_process = FALSE)'
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
14 changes: 11 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
Meta/
doc/
# Background R stuff
.Rproj.user
.Rhistory
.RData
.Ruserdata
.httr-oauth
.DS_Store

# R project
*.Rproj

# Certain folders
Meta/
doc/
docs/

# Ignore Mac file
.DS_Store
26 changes: 16 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Package: metajam
Type: Package
Title: Easily Download Data and Metadata from 'DataONE'
Version: 0.2.3
Date: 2020-10-14
Authors@R: c(
person("Julien", "Brun",
email = "[email protected]",
Expand All @@ -15,6 +14,11 @@ Authors@R: c(
person("Mitchell", "Maier",
comment= c(ORCID = "0000-0001-6955-0535"),
role = "aut"),
person("Nicholas", "Lyon",
email = "[email protected]",
comment = c(ORCID = "0000-0003-3905-1078",
"https://njlyon0.github.io/"),
role = "ctb"),
person("Nathan", "Hwangbo",
email = "[email protected]",
comment= c(ORCID = "0000-0002-3777-0821"),
Expand All @@ -32,13 +36,19 @@ Authors@R: c(
comment = c(ORCID = "0000-0002-6388-0901"),
role = "ctb")
)
Maintainer: Julien Brun <brun@nceas.ucsb.edu>
Maintainer: Julien Brun <jb160@ucsb.edu>
Description: A set of tools to foster the development of reproducible analytical workflow by simplifying the download of data and
metadata from 'DataONE' (<https://www.dataone.org>) and easily importing this information into R.
License: Apache License (== 2.0)
URL: https://github.com/nceas/metajam,
https://nceas.github.io/metajam/
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.2.3
SystemRequirements: Mac OSX: redland (>= 1.0.14) ; Linux: librdf0 (>= 1.0.14),
librdf0-dev (>= 1.0.14)
URL: https://nceas.github.io/metajam/
BugReports: https://github.com/nceas/metajam/issues
Depends:
R (>= 3.1.1)
Imports:
dataone,
dplyr,
Expand All @@ -51,13 +61,9 @@ Imports:
stringr,
tibble,
tidyr,
rlang
XML
Suggests:
testthat,
knitr,
rmarkdown,
udunits2
Encoding: UTF-8
testthat
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ importFrom(dataone,query)
importFrom(emld,as_emld)
importFrom(lubridate,ymd_hms)
importFrom(purrr,"%||%")
importFrom(rlang,.data)
importFrom(stats,setNames)
importFrom(stringr,str_detect)
importFrom(stringr,str_extract)
importFrom(stringr,str_trim)
importFrom(tibble,enframe)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,spread)
importFrom(tools,file_path_sans_ext)
importFrom(utils,URLdecode)
42 changes: 19 additions & 23 deletions R/check_version.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Check PID version
#' @title Check PID version
#'
#' This function takes an identifier and checks to see if it has been obsoleted.
#' @description This function takes an identifier and checks to see if it has been obsoleted.
#'
#' @param pid (character) The persistent identifier of a data, metadata, or resource map object on a DataONE member node.
#' @param formatType (character) Optional. The format type to return (one of data, metadata, or resource).
#' @param formatType (character) Optional. The format type to return (one of 'data', 'metadata', or 'resource').
#'
#' @return (data.frame) A data frame of object version PIDs and related information.
#'
Expand Down Expand Up @@ -32,28 +32,28 @@

check_version <- function(pid, formatType = NULL) {

if (!all(is.character(pid), all(nchar(pid) > 0))) {
stop("Argument 'pids' must be character class with non-zero number of characters.")
}
if (!is.null(formatType) && !all(is.character(formatType), length(formatType) == 1, formatType %in% c("data", "metadata", "resource"))) {
# Error out for missing pids
if(all(is.character(pid), nchar(pid) > 0) != TRUE)
stop("Argument 'pid' must be character class with non-zero number of characters.")

# Error out for missing / unsupported `formatType` specification
if(is.null(formatType) != TRUE & all(is.character(formatType), length(formatType) == 1, formatType %in% c("data", "metadata", "resource")) != TRUE)
stop("Argument 'formatType' should either be NULL or one of 'data', 'metadata', or 'resource'.")
}

# Query DataONE for the specified `pid`
while (nchar(pid) > 5) {
results <- suppressMessages(
dataone::query(dataone::CNode(),
list(q = sprintf('identifier:"%s"', pid),
fl = "identifier, dateUploaded, formatType, obsoletedBy, resourceMap"),
dataone::query(x = dataone::CNode(),
solrQuery = list(q = sprintf('identifier:"%s"', pid),
fl = "identifier, dateUploaded, formatType, obsoletedBy, resourceMap"),
as = "data.frame")
)
#if results is null or empty dataframe, remove part of the URI
# If results is null or empty dataframe, remove part of the URI
if (is.null(results) || nrow(results) == 0) {
pid <- gsub("^[^/=]+[/=]*", "", pid)
pid <- gsub(pattern = "^[^/=]+[/=]*", replacement = "", x = pid)

} else {
#what to do if multiple are returned
break
}
# If multiple are returned, break
} else { break }
}

# filter out extra types (resource map/etc with similar pid)
Expand All @@ -66,16 +66,12 @@ check_version <- function(pid, formatType = NULL) {
stop("No matching identifiers were found.")
} else if (nrow(results) == 1) {
if (is.null(results$obsoletedBy) || is.na(results$obsoletedBy)) {
message("\n",
results$identifier,
"\nis the latest version for identifier\n",
pid)
message(results$identifier, " is the latest version for the provided persistent identifier")
} else {
warning("The identifier has been obsoleted by ", results$obsoletedBy)
}
} else {
warning("Several identifiers are associated with ", pid)
}

return(results)
}
return(results) }
Loading

0 comments on commit e9d673e

Please sign in to comment.