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

Add a "no quizzes" handling ability as well as some merge conflict resolutions #480

Merged
merged 29 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6e6965e
Add docker image as option
cansavvy Feb 16, 2022
a5eed01
Add a "no quizzes" option
cansavvy Feb 16, 2022
d203fd7
Add some ${{ }}
cansavvy Feb 16, 2022
d483307
Missed one
cansavvy Feb 16, 2022
2bc17d5
Fix typo
cansavvy Feb 16, 2022
6a6a137
Merge branch 'cansavvy/docker_manage' into cansavvy/no-quiz-option
cansavvy Feb 16, 2022
3373729
Merge branch 'main' into cansavvy/no-quiz-option
cansavvy Feb 17, 2022
025ac9d
Test no quiz render
cansavvy Feb 17, 2022
3a50880
Skip quiz_dir
cansavvy Feb 17, 2022
5381673
Update Leanpub/Coursera handling
cansavvy Feb 17, 2022
de548df
Fix file path
cansavvy Feb 17, 2022
781f37b
Polish up screenshot making
cansavvy Feb 18, 2022
ea273ba
Make it not a force push
cansavvy Feb 18, 2022
a4174f0
Update file path
cansavvy Feb 18, 2022
4628456
git set-remote with PAT
cansavvy Feb 18, 2022
5b9213f
Merge branch 'main' into cansavvy/no-quiz-option
cansavvy Feb 18, 2022
dd1de98
Add git set remote
cansavvy Feb 18, 2022
1742602
Merge remote-tracking branch 'origin/cansavvy/no-quiz-option' into ca…
cansavvy Feb 18, 2022
b8a78e7
git pull settings
cansavvy Feb 18, 2022
2f4d818
git add all for coursera
cansavvy Feb 18, 2022
b917cb2
Update trigger for transfer
cansavvy Feb 18, 2022
7ca5342
set output_dir
cansavvy Feb 18, 2022
19dc0b8
Update file handling
cansavvy Feb 18, 2022
560ea2c
add runs-on
cansavvy Feb 18, 2022
c4f9354
Update folders that are transferred
cansavvy Feb 18, 2022
b575d76
Update PR comment too
cansavvy Feb 18, 2022
898d2ba
return defaults
cansavvy Feb 18, 2022
6713136
Restore quizzes
cansavvy Feb 18, 2022
225a09e
switch theirs -> ours
cansavvy Feb 18, 2022
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
2 changes: 0 additions & 2 deletions .github/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

group:
- files:
- source: config_automation.yml
dest: config_automation.yml
- source: .github/workflows/
dest: .github/workflows/
deleteOrphaned: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
branch_name='preview-${{ github.event.pull_request.number }}'
git add --force resources/spell_check_results.tsv
git commit -m 'Add spell check file' || echo "No changes to commit"
git pull --set-upstream origin $branch_name --allow-unrelated-histories
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=theirs
cansavvy marked this conversation as resolved.
Show resolved Hide resolved
git push --force origin $branch_name || echo "No changes to commit"

- name: Build components of the spell check comment
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
if $changes == true; then
git add --force question_error_report.tsv
git diff-index --quiet HEAD || git commit -m 'Add question error report file'
git pull --set-upstream origin $branch_name --allow-unrelated-histories
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=theirs
git push origin $branch_name
fi
fi
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:
echo ::set-output name=changes::$changes
git add . --force
git commit -m 'Render preview' || echo "No changes to commit"
git pull --set-upstream origin $branch_name --allow-unrelated-histories
git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=theirs
git push --force || echo "No changes to commit"
shell: bash

Expand Down
49 changes: 37 additions & 12 deletions .github/workflows/render-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
toggle_coursera: "${{ env.RENDER_COURSERA }}"
toggle_leanpub: "${{ env.RENDER_LEANPUB }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"

render-bookdown:
name: Render bookdown
Expand Down Expand Up @@ -73,11 +74,13 @@ jobs:

# Commit the rendered bookdown files
- name: Commit rendered bookdown files
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives the render permission to push straight to main

git add --force docs/*
git commit -m 'Render bookdown' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=theirs
git push origin main || echo "No changes to push"

render-tocless:
Expand Down Expand Up @@ -108,11 +111,13 @@ jobs:

# Commit the TOC-less version files
- name: Commit tocless bookdown files
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
git add --force docs/no_toc*
git commit -m 'Render toc-less' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=theirs
git push origin main || echo "No changes to push"

render-leanpub:
Expand All @@ -138,15 +143,30 @@ jobs:
# Create screenshots
- name: Run the screenshot creation
run: |
# Remove old folder
rm -rf resources/chapt_screen_images
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures a refresh of the images each time so no old files hang around


# Make new screenshots
chapt_urls=$(Rscript --vanilla scripts/make_screenshots.R \
--git_pat ${{ secrets.GH_PAT }} \
--repo $GITHUB_REPOSITORY)
--repo $GITHUB_REPOSITORY \
--output_dir resources/chapt_screen_images)

# We want a fresh run of the renders each time
- name: Delete old manuscript/
run: rm -rf manuscript/

- name: Run ottrpal::bookdown_to_embed_leanpub
if: needs.yaml-check.outputs.toggle_quiz_check == 'no'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If quizzes aren't being checked here, we can set quiz_dir = NULL and assume there are not quizzes here.

run: |
Rscript -e "ottrpal::bookdown_to_embed_leanpub(
render = FALSE, \
chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \
make_book_txt = TRUE, \
quiz_dir = NULL)"

- name: Run ottrpal::bookdown_to_embed_leanpub
if: needs.yaml-check.outputs.toggle_quiz_check == 'yes'
run: |
Rscript -e "ottrpal::bookdown_to_embed_leanpub(
render = FALSE, \
Expand All @@ -155,12 +175,15 @@ jobs:

# Commit the rendered leanpub files
- name: Commit rendered leanpub files
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
git add --force manuscript/*
git add --force resources/*
git commit -m 'Render Leanpub' || echo "No changes to commit"
git push --force origin main || echo "No changes to push"
git pull --allow-unrelated-histories --strategy-option=theirs
cansavvy marked this conversation as resolved.
Show resolved Hide resolved
git push origin main || echo "No changes to push"

render-coursera:
name: Finish Coursera prep
Expand All @@ -184,15 +207,17 @@ jobs:

# Run Coursera version
- name: Convert Leanpub quizzes to Coursera
if: needs.yaml-check.outputs.toggle_leanpub == 'yes'
if: needs.yaml-check.outputs.toggle_leanpub == 'yes' && needs.yaml-check.outputs.toggle_quiz_check == 'yes'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step for coursera is really only needed if there's quizzes AND if Leanpub is being published.

id: coursera
run: Rscript -e "ottrpal::convert_coursera_quizzes()"

# Commit the rendered bookdown files
- name: Commit rendered Coursera files
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add --force docs/coursera/*
git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}
git add --force .
git commit -m 'Render Coursera quizzes' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=theirs
git push origin main || echo "No changes to push"
4 changes: 3 additions & 1 deletion .github/workflows/transfer-rendered-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
toggle_leanpub: "${{ env.RENDER_LEANPUB }}"


file-bookdown-pr:
file-quizzes-pr:
name: File _Quizzes Transfer PR
runs-on: ubuntu-latest
needs: [yaml-check]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't running properly because I forgot to specify it needed yaml-check

if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes' || needs.yaml-check.outputs.toggle_leanpub == 'yes'}}

steps:
Expand Down
69 changes: 0 additions & 69 deletions coursera_quizzes/quiz_ch1.md.yml

This file was deleted.

54 changes: 0 additions & 54 deletions quizzes/quiz_ch1.md

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/make_screenshots.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (is.null(opt$base_url)) {
base_url <- cow::get_pages_url(repo_name = opt$repo, git_pat = opt$git_pat)
}

chapt_df <- ottrpal::get_chapters(base_url = file.path(base_url, "no_toc"))
chapt_df <- ottrpal::get_chapters(base_url = file.path(base_url, "no_toc/"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This / is needed or else the image names get messed up.


file_names <- lapply(chapt_df$url, function(url) {
file_name <- gsub(".html", ".png", file.path(output_folder, basename(url)))
Expand Down