Skip to content

Commit

Permalink
Merge pull request #1 from jhudsl/cansavvy/testing
Browse files Browse the repository at this point in the history
Testing if ottr-reports work
  • Loading branch information
cansavvy authored Mar 23, 2022
2 parents 501e15c + 0e288a4 commit 88756d0
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 96 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
# Candace Savonen Mar 2022

name: Testing ottr-reports
on: [pull_request]
on:
pull_request:
branches: [ main ]

jobs:
run:

spell-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2


- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check spelling
uses: ./
with:
check_type: "spelling"
check_type: spelling
error_min: 3

urls-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Check URLs
uses: ./
with:
check_type: "urls"
check_type: urls
error_min: 0

quiz-format:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Check quiz formatting
uses: ./
with:
check_type: "quiz_format"
check_type: quiz_format
error_min: 0
35 changes: 0 additions & 35 deletions .github/workflows/release-notes.yml

This file was deleted.

34 changes: 30 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Container image that runs your code
FROM jhudsl/course_template:main
COPY entrypoint.sh /entrypoint.sh
FROM rocker/r-base
LABEL maintainer="cansav09@gmail.com"

# Install apt-getable packages to start
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils dialog
RUN apt-get install -y --no-install-recommends \
libxt6 \
libpoppler-cpp-dev \
vim \
libglpk40 \
curl \
libxml2-dev \
libcurl4-openssl-dev \
libssl-dev

# Needed R packages
RUN Rscript -e "options(warn = 2);install.packages( \
c('tidyverse', \
'rprojroot', \
'spelling', \
'ottrpal', \
'optparse'), \
repos = 'https://cloud.r-project.org/')"

COPY scripts/* ./scripts/
WORKDIR /github/workspace
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

ARG CHECK_TYPE
ENV CHECK_TYPE=${INPUT_CHECK_TYPE}

ENTRYPOINT ["echo", "$CHECK_TYPE", ">>", "check_type.txt", ";", "Rscript", "scripts/check_type.R"]
17 changes: 0 additions & 17 deletions action.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'ottr-reports'
author: "Candace Savonen"
description: "Run OTTR checks for spelling, urls, and quiz formats"

inputs:
check_type:
description: "There are three types of reports that can be done and specified: 'spelling', 'urls', or 'quiz_format'."
required: true
type: string
error_min:
description: "What number of errors should make this check fail?"
default: 0
type: number

runs:
using: 'docker'
image: 'jhudsl/ottr-reports'
args:
- ${{ inputs.check_type }}
- ${{ inputs.error_min }}
29 changes: 0 additions & 29 deletions entrypoint.sh

This file was deleted.

53 changes: 53 additions & 0 deletions quizzes/quiz_ch1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

{quiz, id: quiz_name_here, attempts: 10}

## Template quiz

Put any other instructions your quiz takers need to know here like: Choose the best answer.

{choose-answers: 4}
? First question to ask goes here. (Note- you need a question mark at end like this. Just one is required if using a question mark in your question field)?

C) One correct answer here marked with a "C"
C) A second correct answer here
m) Mandatory incorrect answers have an "m"
m) A second mandatory incorrect answer
o) An optional incorrect answer here marked with an "o"
o) A second optional incorrect answer here

{choose-answers: 4}
? Question example with just a question mark?

C) One correct answer here marked with a "C"
C) A second correct answer here
m) Mandatory incorrect answers have an "m"
m) A second mandatory incorrect answer
o) An optional incorrect answer here marked with an "o"
o) A second optional incorrect answer here

{choose-answers: 4}
? Second question to ask goes here?

C) A correct answer here!
m) Mandatory incorrect answers have an "m"
m) A second mandatory incorrect answer
o) An optional incorrect answer here marked with an "o"
o) A second optional incorrect answer here


{choose-answers: 4}
? A more complicated example. Note the question mark at the end of the options! Which of the following are correct
1. An option described
2. A second option
3. A third option
4. A fourth option
5. A fifth option ?

C) All of the examples listed except 5
C) All of the listed examples except 5
m) 1, 3, and 5
m) 1, 2, and 3
o) All of the examples except 1 and 5
o) All of the examples listed

{/quiz}
22 changes: 22 additions & 0 deletions resources/dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
AnVIL
BIPOC
Bloomberg
Datatrail
DataTrail
dropdown
GDSCN
impactful
ITCR
itcrtraining
ITN
fyi
Leanpub
Markua
mentorship
NCI
NHGRI
UE
UE5
reproducibility
underserved
www
12 changes: 12 additions & 0 deletions scripts/check_type.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env Rscript
# Written by Candace Savonen March 2022

library(optparse)

check_type <- readLines('check_type.txt')

print(paste("Check type specified:", opt$check_type))

if (check_type == "spelling") source("scripts/spell-check.R")
if (check_type == "urls") source("scripts/url-check.R")
if (check_type == "quiz_format") source("scripts/quiz-check.R")
32 changes: 32 additions & 0 deletions scripts/quiz-check.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env Rscript

# Adapted for this jhudsl repository by Candace Savonen Mar 2022

# Run spell check and save results

library(magrittr)

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

ottrpal::check_quizzes(quiz_dir = file.path(root_dir, 'quizzes'), write_report = TRUE, verbose = TRUE)

if (file.exists("question_error_report.tsv")) {
quiz_errors <- readr::read_tsv("question_error_report.tsv")

# Print out how many quiz check errors
write(nrow(quiz_errors), stdout())
} else {
quiz_errors <- data.frame()

# Print out how many quiz check errors
write("1", stdout())
}

if (nrow(quiz_errors) > 0) {
if (!dir.exists("resources")) {
dir.create("resources")
}
# Save question errors to file
readr::write_tsv(quiz_errors, file.path("resources", "question_error_report.tsv"))
}
Loading

0 comments on commit 88756d0

Please sign in to comment.