Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔄 Synced file(s) with jhudsl/AnVIL_Template #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/check-url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ jobs:
run: |
echo ${{ steps.check-report.outputs.error_url }}
echo ${{ steps.check-report.outputs.error_num }}

# Commit file
- name: Commit tocless bookdown files
if: ${{ steps.check-report.outputs.error_num >= 1 }}
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git add --force check_reports/url_checks.tsv
git commit -m 'Add spell check file' || echo "No changes to commit"
git push --set-upstream origin preview-spell-error || echo echo branch exists remotely

- name: Find issues
id: find-issue
Expand Down
106 changes: 68 additions & 38 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Candace Savonen 2021
# Updated Jan 2023
# Updated May 2024

name: Pull Request

Expand All @@ -17,7 +17,6 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}

# Use the yaml-env-action action.
- name: Load environment from YAML
Expand All @@ -39,28 +38,22 @@ jobs:
branch_name='preview-${{ github.event.pull_request.number }}'
echo branch doesnt exist
git checkout -b $branch_name || echo branch exists
git push --set-upstream origin $branch_name || echo echo branch exists remotely
git push --set-upstream origin $branch_name || echo branch exists remotely
shell: bash


outputs:
toggle_website: "${{ env.RENDER_WEBSITE }}"
toggle_spell_check: "${{ env.SPELL_CHECK }}"
toggle_style_code: "${{ env.STYLE_CODE }}"
toggle_url_check: "${{ env.URL_CHECKER }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
toggle_feedback_link: "${{ env.FEEDBACK_LINK }}"
toggle_md_linter: "${{ env.MARKDOWN_LINTER }}"
toggle_readability: "${{ env.READABILITY_REPORT }}"
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
toggle_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
render_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"

build-portal-events:
name: Gather Portal Events
needs: yaml-check
uses: ./.github/workflows/gather-portal-events.yml
with:
render-type: 'preview'
repository: $GITHUB_REPOSITORY
secrets:
gh_pat: ${{ secrets.GH_PAT }}

########################## Make the error reports ##############################
spell-check:
Expand All @@ -71,8 +64,9 @@ jobs:
with:
check_type: spelling
error_min: 3
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}
secrets:
gh_pat: ${{ secrets.GH_PAT }}

url-check:
name: Check URLs
Expand All @@ -82,8 +76,9 @@ jobs:
with:
check_type: urls
error_min: 0
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}
secrets:
gh_pat: ${{ secrets.GH_PAT }}

quiz-check:
name: Check quiz formatting
Expand All @@ -93,8 +88,9 @@ jobs:
with:
check_type: quiz_format
error_min: 0
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}
secrets:
gh_pat: ${{ secrets.GH_PAT }}

############################# Style the code ###################################
style-code:
Expand All @@ -112,15 +108,35 @@ jobs:
fetch-depth: 0

- name: Run styler
run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()"
run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, full.names = TRUE));warnings()"

- name: Commit styled files
run: |
git config --system --add safe.directory "$GITHUB_WORKSPACE"
git add \*.Rmd
git commit -m 'Style Rmds' || echo "No changes to commit"
git add \*md
git commit -m 'Style *mds' || echo "No changes to commit"
git push origin || echo "No changes to commit"

############################# Readability Report ###################################

readability-report:
name: Readability report
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_readability == 'yes'}}

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Readability report
uses: Rebilly/lexi@v2
with:
github-token: ${{ secrets.GH_PAT }}
glob: '**/*.md'

############################# Render Preview ###################################

render-preview:
Expand Down Expand Up @@ -153,18 +169,29 @@ jobs:
# Make sure the link for AnVIL feedback is prepopulated for the specific course
- name: Set up feedback link
id: feedback
run: bash scripts/AnVIL_Feedback_Script.sh
if: ${{needs.yaml-check.outputs.toggle_feedback_link == 'yes'}}
run: |
bash scripts/AnVIL_Feedback_Script.sh
git add _output.yml
git commit -m 'Set up feedback link' || echo "No changes to commit"

# Run bookdown rendering
- name: Run bookdown render
id: bookdown
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"

# Run quarto rendering
- name: Render quarto version
id: quarto
if: ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
run: Rscript -e "quarto::quarto_render('.')"

# Render a student guide if specified. This is a bit clunky because
# Bookdown does not work well if the files aren't named as such in the
# root directory
- name: Run student guide render
if: ${{needs.yaml-check.outputs.render_student_guide == 'yes'}}
if: ${{needs.yaml-check.outputs.toggle_student_guide == 'yes'}}
id: student_guide
run: |
mkdir tmp1
Expand All @@ -174,22 +201,26 @@ jobs:
mv _bookdown.yml _output.yml student-guide
mv tmp1/_bookdown.yml tmp1/_output.yml .
rm -r tmp1

# Run TOC-less version
# Rendered content for Leanpub and Coursera is very similar.
# This job creates a shared scaffold for both.
- name: Run TOC-less version of render
id: tocless
run: Rscript -e "ottrpal::render_without_toc()"
git add student-guide/*
git commit -m 'Create student guide' || echo "No changes to commit"

# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
- name: Check on render steps
if: steps.bookdown.outcome != 'success' || steps.tocless.outcome != 'success'
- name: Check on Rmd render steps
if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }}
run: |
echo Bookdown status ${{steps.bookdown.outcome}}
echo Toc-less status ${{steps.tocless.outcome}}
exit 1
if [${{steps.bookdown.outcome}} != 'success']; then
exit 1
fi

- name: Check on quarto render steps
if: ${{needs.yaml-check.outputs.toggle_website == 'quarto' }}
run: |
echo Quarto status ${{steps.quarto.outcome}}
if [${{steps.quarto.outcome}} != 'success']; then
exit 1
fi

- name: Website preview for download
run: zip website-preview.zip docs/* -r
Expand Down Expand Up @@ -220,12 +251,11 @@ jobs:
run: |
course_name=$(head -n 1 student-guide/_bookdown.yml | cut -d'"' -f 2| tr " " "-")
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
student_docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/student-guide/$course_name.docx") zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
student_guide=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/student-guide/Student_Guide.docx")
zip_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip")
echo "zip_link=$zip_link" >> $GITHUB_OUTPUT
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
echo "student_docx_link=$student_docx_link" >> $GITHUB_OUTPUT
echo "student_guide=$student_guide" >> $GITHUB_OUTPUT
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo ${{steps.commit.outputs.changes}}
Expand All @@ -240,7 +270,7 @@ jobs:
Re-rendered previews from the latest commit:
- :eyes: Quick [preview of course website here](${{ steps.build-components.outputs.bookdown_link }}) \*
- :microscope: Comprehensive [download of the course website here](${{ steps.build-components.outputs.zip_link }})
- Download the [.docx file](${{ steps.build-components.outputs.docx_link }})
- Download the Student Guide [.docx file](${{ steps.build-components.outputs.student_guide }})

\* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea.

Expand Down
Loading
Loading