Skip to content

Commit

Permalink
Merge pull request #4 from jhudsl/cansavvy/script-handling
Browse files Browse the repository at this point in the history
Add copy over from github scripts
  • Loading branch information
cansavvy authored Mar 29, 2022
2 parents 3dd27a2 + 84186a6 commit 53cb45c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ RUN Rscript -e "options(warn = 2);install.packages( \
'optparse'), \
repos = 'https://cloud.r-project.org/')"

COPY scripts/ /scripts/
COPY main.sh ./main.sh
RUN chmod +x main.sh
COPY main.sh /ottr_report_scripts/main.sh
RUN chmod +x /ottr_report_scripts/main.sh

WORKDIR /github/workspace

ARG CHECK_TYPE
ENV CHECK_TYPE=${INPUT_CHECK_TYPE}

ENTRYPOINT ["/bin/bash", "/main.sh"]
ENTRYPOINT ["/bin/bash", "/ottr_report_scripts/main.sh"]
15 changes: 13 additions & 2 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -e
set -o pipefail

ver="v0.5"
printf "using version: $ver"

cd $GITHUB_WORKSPACE

# This script should always run as if it were being called from
Expand All @@ -11,7 +14,7 @@ script_directory="$(perl -e 'use File::Basename;
use Cwd "abs_path";
print dirname(abs_path(@ARGV[0]));' -- "$0")"

echo $script_directory
printf "running from: $script_directory"
echo $INPUT_CHECK_TYPE >> check_type.txt

if [ "${INPUT_CHECK_TYPE}" == "spelling" ];then
Expand All @@ -25,14 +28,22 @@ elif [ "${INPUT_CHECK_TYPE}" == "quiz_format" ];then
report_path='question_error_report.tsv'
fi

# Copy the scripts from this version
curl -o $script_directory/check_type.R https://raw.githubusercontent.com/jhudsl/ottr-reports/v0.5/scripts/check_type.R
curl -o $script_directory/spell-check.R https://raw.githubusercontent.com/jhudsl/ottr-reports/v0.5/scripts/spell-check.R
curl -o $script_directory/url-check.R https://raw.githubusercontent.com/jhudsl/ottr-reports/v0.5/scripts/url-check.R
curl -o $script_directory/quiz-check.R https://raw.githubusercontent.com/jhudsl/ottr-reports/v0.5/scripts/quiz-check.R

# Run the check
chk_results=$(Rscript $script_directory/scripts/check_type.R)
chk_results=$(Rscript $script_directory/check_type.R)

# Print out the output
printf $error_name
printf $report_path
printf $chk_results

rm -rf $script_directory/ottr_report_scripts

# Save output
echo ::set-output name=error_name::$error_name
echo ::set-output name=report_path::$report_path
Expand Down
8 changes: 3 additions & 5 deletions scripts/check_type.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env Rscript
# Written by Candace Savonen March 2022

library(optparse)

check_type <- readLines('check_type.txt')

print(paste("Check type specified:", 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")
if (check_type == "spelling") source("ottr_report_scripts/spell-check.R")
if (check_type == "urls") source("ottr_report_scripts/url-check.R")
if (check_type == "quiz_format") source("ottr_report_scripts/quiz-check.R")

0 comments on commit 53cb45c

Please sign in to comment.