Skip to content

Commit

Permalink
Merge 3dc70c7 into d53aa9f
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy authored Oct 3, 2022
2 parents d53aa9f + 3dc70c7 commit fdda2e9
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 257 deletions.
286 changes: 30 additions & 256 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Candace Savonen Dec 2021
# Candace Savonen Aug 2022

name: Pull Request

Expand Down Expand Up @@ -57,92 +57,38 @@ jobs:
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
dockerfiles_changed: steps.verify-changed-files.outputs.files_changed

########################## Make the error reports ##############################
spell-check:
name: Check spelling
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}}
container:
image: jhudsl/course_template:main

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

- name: Configure git
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash

- name: Run spell check
id: spell_check_run
run: |
results=$(Rscript "scripts/spell-check.R")
echo "::set-output name=sp_chk_results::$results"
- name: Commit spell check errors
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
git add --force check_reports/spell_check_results.tsv || echo "No changes to commit"
git commit -m 'Add spell check file' || echo "No changes to commit"
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push --force origin $branch_name || echo "No changes to commit"
- name: Build components of the spell check comment
id: build-components
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
sp_error_url=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/check_reports/spell_check_results.tsv
echo ::set-output name=time::$(date +'%Y-%m-%d')
echo ::set-output name=commit_id::$GITHUB_SHA
echo ::set-output name=sp_error_url::$sp_error_url
uses: ./.github/workflows/report-maker.yml
with:
check_type: spelling
error_min: 3
gh_pat: secrets.GH_PAT

# Handle the commenting
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: spelling errors

- name: Spelling errors!
if: ${{ steps.spell_check_run.outputs.sp_chk_results >= 3 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:warning: There are spelling errors that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/Spell-check).
[Download the errors here.](${{ steps.build-components.outputs.sp_error_url }})
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

- name: Check spell check results - fail if too many errors
if: ${{ steps.spell_check_run.outputs.sp_chk_results >= 3 }}
run: exit 1

- name: No spelling errors
if: ${{ steps.spell_check_run.outputs.sp_chk_results < 3 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
No spelling errors! :tada:
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
url-check:
name: Check URLs
needs: yaml-check
if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}}
uses: ./.github/workflows/report-maker.yml
with:
check_type: urls
error_min: 0
gh_pat: secrets.GH_PAT

quiz-check:
name: Check quiz formatting
if: ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}}
needs: yaml-check
uses: ./.github/workflows/report-maker.yml
with:
check_type: quiz_format
error_min: 0
gh_pat: secrets.GH_PAT

############################# Style the code ###################################
style-code:
name: Style code
needs: yaml-check
Expand All @@ -166,181 +112,7 @@ jobs:
git commit -m 'Style Rmds' || echo "No changes to commit"
git push origin || echo "No changes to commit"
url-check:
name: Check URLs
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}}
container:
image: jhudsl/course_template:main

steps:
- name: checkout repo
uses: actions/checkout@v2

- name: Configure git
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash

- name: URLs checker
id: url_errors
run: |
chk_results=$(Rscript scripts/url-check.R)
echo $chk_results
echo "::set-output name=url_results::$chk_results"
- name: Commit URL check
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
git add --force check_reports/url_checks.tsv || echo "No changes to commit"
git commit -m 'Add URL check file' || echo "No changes to commit"
git fetch
git merge -s recursive --strategy-option=ours origin/${{ github.head_ref }} --allow-unrelated-histories
git push --force origin $branch_name || echo "No changes to commit"
- name: Build components of the spell check comment
id: build-components
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
url_errors=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/check_reports/url_checks.tsv
echo ::set-output name=time::$(date +'%Y-%m-%d')
echo ::set-output name=commit_id::$GITHUB_SHA
echo ::set-output name=url_errors::$url_errors
# Handle the commenting
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: broken URLs

- name: URL errors!
if: ${{ steps.url_errors.outputs.url_results > 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:warning: There are broken URLs that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/How-to-set-up-and-customize-GitHub-actions-robots#check-for-broken-urls).
[Download the errors here.](${{ steps.build-components.outputs.url_errors }})
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

- name: Check URL results - fail if too many errors
if: ${{ steps.url_errors.outputs.url_results > 0 }}
run: exit 1

- name: No URL errors
if: ${{ steps.url_errors.outputs.url_results == 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
No broken URLs detected! :tada:
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

check-quizzes:
name: Check Leanpub quizzes
needs: yaml-check
runs-on: ubuntu-latest
container:
image: jhudsl/course_template:main
if: ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}}
steps:
- name: Checkout files
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure git
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash

- name: Run quiz check
id: quiz_check_run
run: |
Rscript -e "ottrpal::check_quizzes(quiz_dir = 'quizzes', write_report = TRUE, verbose = TRUE)"
results=0
if [ -f question_error_report.tsv ]; then
results=$(wc -l < question_error_report.tsv >/dev/null)
fi
echo ::set-output name=quiz_chk_results::$results
- name: Commit quiz check errors
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
git add --force question_error_report.tsv || echo "No changes to commit"
git commit -m 'Add question error report file' || echo "No changes to commit"
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push origin $branch_name || echo "No changes to commit"
- name: Build components of the quiz check comment
id: build-components
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
quiz_error_url=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/question_error_report.tsv
echo ::set-output name=time::$(date +'%Y-%m-%d')
echo ::set-output name=commit_id::$GITHUB_SHA
echo ::set-output name=quiz_error_url::$quiz_error_url
# Handle the commenting
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: quiz errors

- name: Quiz errors!
if: ${{ steps.quiz_check_run.outputs.quiz_chk_results >= 2 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:warning: There are quiz errors that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/Publishing-on-Leanpub#setting-up-quizzes).
[Download the errors here.](${{ steps.build-components.outputs.quiz_error_url }})
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

- name: Check quiz check results - fail if too many errors
if: ${{ steps.quiz_check_run.outputs.quiz_chk_results >= 2 }}
run: exit 1

- name: No quiz errors
if: ${{ steps.quiz_check_run.outputs.quiz_chk_results < 2 }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
No quiz errors detected! :tada:
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
############################# Render Preview ###################################

render-preview:
name: Render preview
Expand Down Expand Up @@ -451,6 +223,8 @@ jobs:
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

############################## Build Docker ####################################

build-docker:
name: Build Docker image
needs: yaml-check
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/render-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ jobs:
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
git add --force manuscript/*
git add --force resources/*
git add --force docs/*
git commit -m 'Render Leanpub' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=ours
git push origin main || echo "No changes to push"
Expand Down Expand Up @@ -217,7 +218,9 @@ jobs:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
git add --force .
git add --force manuscript/*
git add --force resources/*
git add --force docs/*
git commit -m 'Render Coursera quizzes' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=ours
git push origin main || echo "No changes to push"
Loading

0 comments on commit fdda2e9

Please sign in to comment.