Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into url_check
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed Jul 19, 2024
2 parents e673aba + 3d56b9f commit 64ba71a
Show file tree
Hide file tree
Showing 107 changed files with 5,282 additions and 5,505 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ vignettes/.httr-oauth$
^package_bundles/leanbuild_0.1.2.tar.gz*
^package_bundles/leanbuild_0.1.2.tgz*
inst/extdata/tmp/default*
quarto-session*

^CRAN-SUBMISSION$
Binary file removed .github/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .github/.gitignore

This file was deleted.

31 changes: 0 additions & 31 deletions .github/check_testthat.R

This file was deleted.

58 changes: 10 additions & 48 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,33 @@ 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: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
container:
image: jhudsl/base_ottr

steps:
- uses: actions/checkout@v4

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

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

- 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: Restore R package cache
if: runner.os != 'Windows'
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 system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE, force = TRUE)
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("devtools")
sessionInfo()
shell: Rscript {0}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

- name: Check
run: |
options(crayon.enabled = TRUE)
devtools::document()
devtools::load_all()
rcmdcheck::rcmdcheck(args = c("--no-manual"), check_dir = "check")
shell: Rscript {0}
env:
GH_PAT: ${{ secrets.GH_PAT }}

- name: Check testthat
if: runner.os != 'Windows'
id: check_check
run: |
error_num=$(Rscript --vanilla '.github/workflows/check_testthat.R')
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/check_testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Check up on the testthat results
# C. Savonen
# Nov 2023

library(magrittr)


# Find .git root directory
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))

# Read in the testthat results
out_file <- list.files(pattern = "testthat.Rout$|Rout.fail$", file.path(root_dir, "check"),
recursive = TRUE, full.names = TRUE)

# Extract testhat results
testthat_check_content <- readLines(out_file)
testthat_result <- grep("\\[ FAIL", testthat_check_content, value = TRUE)[1]
testthat_result <- unlist(strsplit(testthat_result, "\\||\\[|\\]"))

# Read in standard check results
check_content <- readLines(file.path(root_dir, "check", "ottrpal.Rcheck", "00check.log"))

# Extract standard check results
check_result <- grep("Status\\:", check_content, value = TRUE)
check_result <- unlist(strsplit(check_result, ","))
check_result <- stringr::str_remove(check_result, "Status:| ")

# Format the data into a dataframe
testthat_result_df <- data.frame(result = trimws(testthat_result)) %>%
dplyr::filter(result != "") %>%
tidyr::separate(result, sep = " ", into = c("test_name", "num")) %>%
dplyr::mutate(num = as.numeric(num))

# Do the same for the check results
check_result_df <- data.frame(result = trimws(check_result)) %>%
tidyr::separate(result, sep = " ", into = c("num", "test_name")) %>%
dplyr::mutate(num = as.numeric(num)) %>%
dplyr::select("test_name", "num")

# We only want warnings or errors or fails
fail_num <- dplyr::bind_rows(check_result_df, testthat_result_df) %>%
dplyr::filter(test_name %in% c("FAIL", "WARN", "WARNINGs", "ERROR")) %>%
dplyr::summarize(total = sum(num))

fail_num <- as.character(fail_num$total)

# Spit the number out
writeLines(fail_num, con = stdout())
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: ottrpal
Title: Companion Tools for Open-Source Tools for Training Resources (OTTR)
Version: 1.2.1
Version: 1.3.0
Authors@R: c(
person("Candace", "Savonen", , c("[email protected]","[email protected]"), role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-6331-7070")),
Expand All @@ -23,7 +23,6 @@ Imports:
curl,
dplyr,
fs,
glue,
httr,
jsonlite,
knitr (>= 1.33),
Expand All @@ -36,16 +35,19 @@ Imports:
rprojroot,
rvest,
stringr,
webshot2,
xml2,
yaml
Suggests:
remotes,
testthat,
testthat (>= 3.0.0),
tibble,
utils
Remotes:
jhudsl/cow
VignetteBuilder:
knitr
ByteCompile: true
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
Config/testthat/edition: 3
28 changes: 12 additions & 16 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ export("%>%")
export(auth_from_secret)
export(authorize)
export(bad_quiz_path)
export(bookdown_destination)
export(bookdown_file)
export(bookdown_path)
export(bookdown_rmd_files)
export(bookdown_to_book_txt)
export(bookdown_to_embed_leanpub)
export(check_all_questions)
export(check_question)
export(check_quiz)
Expand All @@ -18,44 +12,43 @@ export(check_quiz_question_attributes)
export(check_quizzes)
export(convert_coursera_quizzes)
export(convert_quiz)
export(convert_utube_link)
export(course_path)
export(course_to_book_txt)
export(download_ottr_template)
export(example_repo_cleanup)
export(example_repo_setup)
export(extract_meta)
export(extract_object_id)
export(extract_quiz)
export(get_bookdown_spec)
export(get_chapters)
export(get_gs_pptx)
export(get_image_from_slide)
export(get_image_link_from_slide)
export(get_object_id_notes)
export(get_pages_url)
export(get_slide_id)
export(get_slide_page)
export(get_yaml_spec)
export(good_quiz_path)
export(gs_id_from_slide)
export(gs_png_download)
export(gs_png_url)
export(include_slide)
export(leanpub_check)
export(make_embed_markdown)
export(make_screenshots)
export(output_destination)
export(parse_q_tag)
export(parse_quiz)
export(parse_quiz_df)
export(pptx_notes)
export(pptx_slide_note_df)
export(pptx_slide_text_df)
export(remove_yaml_header)
export(qrmd_files)
export(render_without_toc)
export(replace_html)
export(replace_single_html)
export(set_knitr_image_path)
export(set_up_leanpub)
export(simple_references)
export(unzip_pptx)
export(website_to_embed_leanpub)
export(xml_notes)
importFrom(fs,dir_copy)
import(dplyr)
importFrom(httr,GET)
importFrom(httr,accept_json)
importFrom(httr,config)
Expand All @@ -67,10 +60,13 @@ importFrom(jsonlite,fromJSON)
importFrom(magrittr,"%>%")
importFrom(openssl,aes_cbc_decrypt)
importFrom(readr,write_tsv)
importFrom(rprojroot,find_root)
importFrom(rprojroot,has_dir)
importFrom(utils,download.file)
importFrom(utils,installed.packages)
importFrom(utils,menu)
importFrom(utils,unzip)
importFrom(webshot2,webshot)
importFrom(xml2,read_xml)
importFrom(xml2,xml_find_all)
importFrom(xml2,xml_text)
9 changes: 5 additions & 4 deletions R/coursera_and_leanpub.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ convert_coursera_quizzes <- function(input_quiz_dir = "quizzes",
)
}

#' Create TOC-less Bookdown for use in Coursera
#' Create TOC-less course website for use in Coursera or Leanpub
#'
#' Create a version of Leanpub that does not have a TOC and has quizzes in the Coursera yaml format. Requires Bookdown output files including "assets", "resources", and "libs".
#' Create a version of the course that does not have a TOC and has quizzes in the Coursera yaml format.
#' This is only needed to be used on Bookdown courses. Quarto has a simple command for this.
#'
#' @param output_dir A folder (existing or not) that the TOC-less Bookdown for Coursera files should be saved. By default is file.path("docs", "coursera")
#' @param output_yaml A output.yml file to be provided to bookdown. By default is "_output.yml"
Expand All @@ -220,8 +221,8 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
input_quiz_dir = "quizzes",
output_quiz_dir = "coursera_quizzes",
verbose = TRUE) {
# Find root directory by finding `_bookdown.yml` file
root_dir <- bookdown_path()
# Find root directory by finding `.git` folder
root_dir <- course_path()

# Output files:
output_dir <- file.path(root_dir, output_dir)
Expand Down
38 changes: 36 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ download_ottr_template <- function(dir = "inst/extdata", type = "rmd") {

url <- switch(type,
rmd = "https://github.com/jhudsl/OTTR_Template/archive/refs/heads/main.zip",
quarto = "https://github.com/fhdsl/ottr/archive/refs/heads/main.zip",
quarto = "https://github.com/fhdsl/OTTR_Quarto/archive/refs/heads/main.zip",
rmd_website = "https://github.com/jhudsl/OTTR_Template_Website/archive/refs/heads/main.zip",
quarto_website = "https://github.com/fhdsl/OTTR_Quarto_Website/archive/refs/heads/main.zip"
)
Expand All @@ -37,14 +37,48 @@ download_ottr_template <- function(dir = "inst/extdata", type = "rmd") {
download.file(url,
destfile = file_path
)
}
output_dir <- stringr::str_remove(file.path(dir, file_name), ".zip")

if (!dir.exists(output_dir)) {
unzip(file_path, exdir = dir)
}
output_dir <- stringr::str_remove(file.path(dir, file_name), ".zip")

return(output_dir)
}


#' Path to good example quiz
#'
#' @export
#' @return The file path to an example good quiz included in the package that should pass the quiz checks.
#'
good_quiz_path <- function() {
list.files(
pattern = "quiz_good.md$",
recursive = TRUE,
system.file("extdata", package = "ottrpal"),
full.names = TRUE
)
}

#' Path to bad example quiz
#'
#' @export
#' @return The file path to an example bad quiz included in the package that will fail the quiz checks.
#'
#' @examples
#'
#' quiz_path <- bad_quiz_path()
bad_quiz_path <- function() {
list.files(
pattern = "quiz_bad.md$",
recursive = TRUE,
system.file("extdata", package = "ottrpal"),
full.names = TRUE
)
}

#' Get file path to an key encryption RDS
key_encrypt_creds_path <- function() {
list.files(
Expand Down
Loading

0 comments on commit 64ba71a

Please sign in to comment.