Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
^index\.md$
^README\.md$
^R/\.setup\.R
^\.github$
81 changes: 81 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on:
push:
branches:
- master
- main
- dev
pull_request:
branches:
- master
- main
- dev

name: R-CMD-check

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

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

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'oldrel'}
- {os: windows-latest, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
with:
r-version: ${{ matrix.config.r }}

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2)
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3-

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
push:
branches:
- main
- master
- dev

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
51 changes: 51 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
issue_comment:
types: [created]
name: Commands
jobs:
document:
if: startsWith(github.event.comment.body, '/document')
name: document
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
- name: Install dependencies
run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)'
- name: Document
run: Rscript -e 'roxygen2::roxygenise()'
- name: commit
run: |
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
style:
if: startsWith(github.event.comment.body, '/style')
name: style
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/pr-fetch@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@master
- name: Install dependencies
run: Rscript -e 'install.packages("styler")'
- name: Style
run: Rscript -e 'styler::style_pkg()'
- name: commit
run: |
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

name: test-coverage

jobs:
test-coverage:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master

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

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("covr")
shell: Rscript {0}

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

9 changes: 6 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: kwb.endnote
Title: Helper Functions for Analysing KWB Endnote Library
(Exported as .xml)
Version: 0.1.0
Version: 0.2.0
Authors@R:
c(person(given = "Michael",
family = "Rustler",
Expand All @@ -13,6 +13,8 @@ Authors@R:
role = "ctb",
email = "hauke.sonnenberg@kompetenz-wasser.de",
comment = c(ORCID = "0000-0001-9134-2871")),
person(given = "FAKIN",
role = "fnd"),
person(given = "Kompetenzzentrum Wasser Berlin gGmbH (KWB)",
role = "cph"))
Description: Helper Functions For Analysing KWB Endnote Library
Expand All @@ -35,7 +37,8 @@ Imports:
tibble,
tidyr,
wordcloud2,
xml2
xml2,
plotly
Suggests:
covr,
knitr,
Expand All @@ -46,5 +49,5 @@ Remotes:
github::kwb-r/kwb.utils
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# kwb.endnote 0.0.0.9000

* Move to GitHub Actions as CI (from Travis/Appveyor)
* Added a `NEWS.md` file to track changes to the package.

* see https://style.tidyverse.org/news.html for writing a good `NEWS.md`
Expand Down
4 changes: 2 additions & 2 deletions R/check_for_differences.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#' ### Check differences between two different versions of "KWB_documents.xml"
#' ############################################################################
#'
#' old_xml <- extdata_file("2019-01-14_KWB_documents.xml")
#' new_xml <- extdata_file("2019-07-09_KWB_documents.xml")
#' old_xml <- extdata_file("2020-05-25_KWB-documents.xml")
#' new_xml <- extdata_file("2020-06-17_KWB-documents.xml")
#' old_list <- kwb.endnote::create_endnote_list(old_xml)
#' new_list <- kwb.endnote::create_endnote_list(new_xml)
#' old_df <- kwb.endnote::create_references_df(old_list)
Expand Down
37 changes: 28 additions & 9 deletions R/create_references_df_from_list.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# colbind: Wrapper around dplyr::bind_cols(). Makes sure that no rows get lost
# if the data frame to add has no rows.
colbind <- function(df, df_2) {
if (nrow(df_2) == 0L) {
# Return the original data frame if the data frame to add has no columns
if (ncol(df_2) == 0L) {
return(df)
}
# Give the data frame to add one empty row (full of NA)
df_2 <- df_2[1L, ]
}
dplyr::bind_cols(df, df_2)
}

#' @noRd
#' @keywords internal
null_to_na <- function(x, na_fill = NA_character_) {
Expand Down Expand Up @@ -154,6 +168,11 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
collapse_val = "",
element = 1)
}

replace_newline_with_semicolon <- function(text) {
gsub("\r", ", ", text)
}

get_titles_style <- function(path) get_style(c("titles", path))
get_period_style <- function(path) get_style(c("periodical", path))
get_dates_style <- function(path) get_style(c("dates", path))
Expand All @@ -164,11 +183,11 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
ref_type_name = attr(get_record_entry("ref-type"), which = "name"),
abstract = get_abstract(record_list, collapse)
) %>%
dplyr::bind_cols(get_keywords(record_list, collapse = collapse)) %>%
dplyr::bind_cols(get_authors(record_list, collapse = collapse)) %>%
dplyr::bind_cols(get_secondary_authors(record_list, collapse = collapse)) %>%
dplyr::bind_cols(get_tertiary_authors(record_list, collapse = collapse)) %>%
dplyr::bind_cols(
colbind(get_keywords(record_list, collapse = collapse)) %>%
colbind(get_authors(record_list, collapse = collapse)) %>%
colbind(get_secondary_authors(record_list, collapse = collapse)) %>%
colbind(get_tertiary_authors(record_list, collapse = collapse)) %>%
colbind(
tibble::tibble(
database_name = get_record_entry("database")[[1]],
database_path = attr(get_record_entry("database"), which = "path"),
Expand All @@ -191,13 +210,13 @@ record_list_to_df <- function(record_list, collapse = FALSE) {
authaddress = get_style("auth-address"),
edition = get_style("edition"),
worktype = get_style("work-type"),
label = get_style("label"),
label = replace_newline_with_semicolon(get_style("label")),
isbn = get_style("isbn"),
language = get_style("language")
language = replace_newline_with_semicolon(get_style("language"))
)
) %>%
dplyr::bind_cols(get_pdfurls(record_list, collapse = collapse)) %>%
dplyr::bind_cols(tibble::tibble(
colbind(get_pdfurls(record_list, collapse = collapse)) %>%
colbind(tibble::tibble(
urls_related = get_style(c("urls", "related-urls", "url")),
electronic_resource_num = get_style("electronic-resource-num"),
custom1 = get_style("custom1"),
Expand Down
2 changes: 1 addition & 1 deletion R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ colname_i <- function(name, i) {
#' @export
#'
default_xml <- function() {
extdata_file("2019-07-09_KWB_documents.xml")
extdata_file("2020-06-17_KWB-documents.xml")
}

# first_of_element -------------------------------------------------------------
Expand Down
Loading