Skip to content

Commit

Permalink
Merge branch 'main' into ki/refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kweav authored Jul 8, 2024
2 parents 62c8ae6 + 88a03cb commit af2d370
Show file tree
Hide file tree
Showing 138 changed files with 5,307 additions and 6,249 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +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.

76 changes: 23 additions & 53 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,49 @@ on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

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@v3

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

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

- 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"))')
- uses: actions/checkout@v4

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_cran("devtools")
sessionInfo()
shell: Rscript {0}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

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

- name: Check testthat
id: check_check
run: |
error_num=$(Rscript --vanilla '.github/workflows/check_testthat.R')
echo "error_num=$error_num" >> $GITHUB_OUTPUT
- name: Stop if there are errors!
if: ${{ steps.check_check.outputs.error_num != '0' }}
run: exit 1

- name: Upload check results
if: failure()
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())
62 changes: 62 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Candace Savonen Jan 2024

name: Build Docker

on:
workflow_dispatch:
inputs:
dockerhubpush:
description: 'Push to Dockerhub?'
required: true
default: 'false'

jobs:
build-docker:
name: Build Docker image
runs-on: ubuntu-latest

steps:
- name: checkout repo
uses: actions/checkout@v3
with:
token: ${{secrets.GH_PAT}}
fetch-depth: 0

# Set up Docker build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Setup layer cache
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Get token
run: echo ${{ secrets.GH_PAT }} > ${{ github.workspace }}/inst/extdata/docker/git_token.txt

# Build docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: false
load: true
context: inst/extdata/docker
tags: cansav09/metricminer

# Login to Dockerhub
- name: Login to DockerHub
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Push the Docker image if set to true from a manual trigger
- name: Push Docker image if manual trigger set to true
if: ${{ github.event.inputs.dockerhubpush != 'false' }}
run: |
docker push cansav09/metricminer
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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:

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 }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

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

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

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

- 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
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 1.2.1
Date: 2024-01-09 15:20:24 UTC
SHA: 60a69efa2a507c472471cf7ffb7c8d7d370d66ab
6 changes: 3 additions & 3 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 @@ -41,7 +40,7 @@ Imports:
Suggests:
remotes,
cow,
testthat,
testthat (>= 3.0.0),
tibble,
utils
VignetteBuilder:
Expand All @@ -50,3 +49,4 @@ ByteCompile: true
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
Config/testthat/edition: 3
24 changes: 7 additions & 17 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,47 @@ 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(bookdown_to_leanpub)
export(check_all_questions)
export(check_question)
export(check_quiz)
export(check_quiz_attributes)
export(check_quiz_question_attributes)
export(check_quizzes)
export(convert_coursera_quizzes)
export(convert_footnotes)
export(convert_quiz)
export(convert_utube_link)
export(example_repo_cleanup)
export(example_repo_setup)
export(course_path)
export(course_to_book_txt)
export(download_ottr_template)
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_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(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)
import(bookdown_path)
import(cow)
Expand Down
1 change: 0 additions & 1 deletion R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ authorize <- function(token = NULL, cache = FALSE, ...) {
#' }
#'
auth_from_secret <- function(access_token = NULL, refresh_token = NULL) {

# If no tokens are specified, we'll grab the default ones.
if (is.null(access_token) | is.null(refresh_token)) {
decrypted <- openssl::aes_cbc_decrypt(
Expand Down
Loading

0 comments on commit af2d370

Please sign in to comment.