From c60db1022b99f8dd8a31948a6052c63238eb7246 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 11:20:55 -0500 Subject: [PATCH 01/21] Try this out --- .github/workflows/pull_request.yml | 18 ++++++++++++++++++ _output.yml | 1 + config_automation.yml | 2 ++ 3 files changed, 21 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f5ffef01..dfebc4c5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -48,6 +48,7 @@ jobs: toggle_style_code: "${{ env.STYLE_CODE }}" toggle_url_check: "${{ env.URL_CHECKER }}" toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" + toggle_md_linter: "${{ env.MARKDOWN_LINTER }}" toggle_render_preview: "${{ env.RENDER_PREVIEW }}" rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" @@ -110,6 +111,23 @@ jobs: git commit -m 'Style *mds' || echo "No changes to commit" git push origin || echo "No changes to commit" +############################# Check Markdown Formatting ################################### + markdown-linter: + name: Markdown linter + needs: yaml-check + runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} + + steps: + - name: Checkout files + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: DavidAnson/markdownlint-cli2-action@v19 + with: + globs: '*md$' + ############################# Render Preview ################################### render-preview: diff --git a/_output.yml b/_output.yml index 4421ce19..a1f3ae99 100644 --- a/_output.yml +++ b/_output.yml @@ -16,3 +16,4 @@ bookdown::gitbook:

Style adapted from: rstudio4edu-book (CC-BY 2.0)

bookdown::word_document2: toc: true + always_allow_html: true diff --git a/config_automation.yml b/config_automation.yml index 460f4189..7aaabac1 100644 --- a/config_automation.yml +++ b/config_automation.yml @@ -10,6 +10,8 @@ render-preview: yes spell-check: yes # Style any R code style-code: yes +# Would you like your markdown files to be checked for formatting +markdown-linter: yes # Test build the docker image if any docker-relevant files have been changed docker-test: no # Should URLs be tested periodically? From 2229ff9861b7c1c14bb57b36d6f1d063a6091111 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 11:28:04 -0500 Subject: [PATCH 02/21] ${secrets.GH_PAT} --- .github/workflows/pull_request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index dfebc4c5..d1a96096 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -61,7 +61,7 @@ jobs: with: check_type: spelling error_min: 3 - gh_pat: secrets.GH_PAT + gh_pat: ${secrets.GH_PAT} branch_name: ${GITHUB_HEAD_REF} url-check: @@ -72,7 +72,7 @@ jobs: with: check_type: urls error_min: 0 - gh_pat: secrets.GH_PAT + gh_pat: ${secrets.GH_PAT} branch_name: ${GITHUB_HEAD_REF} quiz-check: @@ -83,7 +83,7 @@ jobs: with: check_type: quiz_format error_min: 0 - gh_pat: secrets.GH_PAT + gh_pat: ${secrets.GH_PAT} branch_name: ${GITHUB_HEAD_REF} ############################# Style the code ################################### From ea677d779e7e26971716b371f2e83d3783454fb6 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 12:46:56 -0500 Subject: [PATCH 03/21] Update README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 8c59ad36..cbd6f23a 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,13 @@ _This template and guide helps you_: - [Advanced Reproducibility in Cancer Informatics](https://jhudatascience.org/Adv_Reproducibility_in_Cancer_Informatics/) ## To Get Started + - Go to the [ottrproject.org](https://www.ottrproject.org/). - Check out the [rendered version of the template](https://jhudatascience.org/OTTR_Template/). - Check out our [course on using Leanpub](https://hutchdatascience.org/Using_Leanpub/index.html) for help publishing on this platform. - Please take a look at the [code of conduct](./code_of_conduct.md). - If you encounter any problems or have ideas for improvements to this template repository or this getting started guide, please [file an issue here](https://github.com/jhudsl/OTTR_Template/issues/new/choose)! Your feedback is very much appreciated. + +## Contributing + +If you'd like to contribute, we love that! Please go to the [CONTRIBUTING.md doc](https://github.com/jhudsl/OTTR_Template/blob/main/CONTRIBUTING.md). From 00842bc3a114503d1b202c1991ead0fd78354a44 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 12:51:59 -0500 Subject: [PATCH 04/21] ${{ secrets. }} --- .github/workflows/pull_request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d1a96096..42ba2bed 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -61,7 +61,7 @@ jobs: with: check_type: spelling error_min: 3 - gh_pat: ${secrets.GH_PAT} + gh_pat: ${{ secrets.GH_PAT }} branch_name: ${GITHUB_HEAD_REF} url-check: @@ -72,7 +72,7 @@ jobs: with: check_type: urls error_min: 0 - gh_pat: ${secrets.GH_PAT} + gh_pat: ${{ secrets.GH_PAT}} branch_name: ${GITHUB_HEAD_REF} quiz-check: @@ -83,7 +83,7 @@ jobs: with: check_type: quiz_format error_min: 0 - gh_pat: ${secrets.GH_PAT} + gh_pat: ${{ secrets.GH_PAT }} branch_name: ${GITHUB_HEAD_REF} ############################# Style the code ################################### From e1497492943785e8bc1a0030822fa86782407206 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 12:59:20 -0500 Subject: [PATCH 05/21] Fix secrets --- .github/workflows/pull_request.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 42ba2bed..7f1e473d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -61,8 +61,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 @@ -72,8 +73,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 @@ -83,8 +85,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: From bf4813ce0bb18740ae0fa501f7d3a99746fbf651 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 13:30:21 -0500 Subject: [PATCH 06/21] adding readability reports --- .github/workflows/pull_request.yml | 23 ++++++++++++++++++++++- config_automation.yml | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7f1e473d..950c9155 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -49,6 +49,7 @@ jobs: toggle_url_check: "${{ env.URL_CHECKER }}" toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" toggle_md_linter: "${{ env.MARKDOWN_LINTER }}" + toggle_readability: "${{ env.READABILITY_REPORT }}" toggle_render_preview: "${{ env.RENDER_PREVIEW }}" rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" @@ -129,7 +130,27 @@ jobs: - uses: DavidAnson/markdownlint-cli2-action@v19 with: - globs: '*md$' + globs: '**/*.md' + +############################# 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 ################################### diff --git a/config_automation.yml b/config_automation.yml index 7aaabac1..bcbe6135 100644 --- a/config_automation.yml +++ b/config_automation.yml @@ -12,6 +12,8 @@ spell-check: yes style-code: yes # Would you like your markdown files to be checked for formatting markdown-linter: yes +# Would you like a readability report on your markdowns? +readability-report: yes # Test build the docker image if any docker-relevant files have been changed docker-test: no # Should URLs be tested periodically? From ac79d25edc10a67adeba16e7cdb4c6a6e897a808 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 13:32:09 -0500 Subject: [PATCH 07/21] Markdown --- .github/workflows/pull_request.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 950c9155..c7a9abd0 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -130,7 +130,10 @@ jobs: - uses: DavidAnson/markdownlint-cli2-action@v19 with: - globs: '**/*.md' + globs: | + *.Rmd + *.md + *.qmd ############################# Readability Report ################################### From 0a9d7c63db00e05f379149e12a5e441437a76812 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 13:33:21 -0500 Subject: [PATCH 08/21] indent --- .github/workflows/pull_request.yml | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index c7a9abd0..648fd404 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -137,23 +137,23 @@ jobs: ############################# 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' + 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 ################################### From c24f8f46ac67f114dea3a8e8f0d51c40e3bd3f36 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 13:54:25 -0500 Subject: [PATCH 09/21] Will this work? --- .github/workflows/pull_request.yml | 67 +++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 648fd404..a6e6bf48 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,6 +121,8 @@ jobs: needs: yaml-check runs-on: ubuntu-latest if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} + image : + container: davidanson/markdownlint-cli2:v0.17.1 steps: - name: Checkout files @@ -128,12 +130,67 @@ jobs: with: fetch-depth: 0 - - uses: DavidAnson/markdownlint-cli2-action@v19 + - run: | + mkdir -p check_reports + + curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml" + -O resources/.markdownlint-cli2.yaml + + markdownlint-cli2 \ + --config "resources/.markdownlint-cli2.yaml" "**/*.md" \ + > check_reports/markdown_lint_report.txt + + # Commit the rendered bookdown files + - name: Commit markdown report to preview branch + id: commit + run: | + branch_name='preview-${{ github.event.pull_request.number }}' + echo "markdown_issues=$(wc -l check_reports/markdown_lint_report.txt)" >> $GITHUB_OUTPUT + git add check_reports/markdown_lint_report.txt --force + git commit -m 'Add markdown report' || echo "No report to commit" + git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours + git push --force || echo "No report to commit" + shell: bash + + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc with: - globs: | - *.Rmd - *.md - *.qmd + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: + + - name: Build components of the comment + id: build-components + run: | + + course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-") + report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/report_link.zip") + echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT + echo ${{steps.commit.outputs.markdown_issues}} + + - name: Create or update comment + if: steps.commit.outputs.markdown_issues > 4 + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + [Markdown linter report here](${{ steps.build-components.outputs.time }}) + _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ + edit-mode: replace + + - name: Comment if no changes + if: steps.commit.outputs.markdown_issues > 4 + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Markdown linter report did not find any issues! + _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ + edit-mode: replace ############################# Readability Report ################################### From 514508418a557d366ba1dc9eebf70f77be70b27c Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:16:07 -0500 Subject: [PATCH 10/21] Try it out --- .github/workflows/pull_request.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index a6e6bf48..7ad12d75 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -133,19 +133,19 @@ jobs: - run: | mkdir -p check_reports - curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml" - -O resources/.markdownlint-cli2.yaml + curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ + -o resources/.markdownlint-cli2.jsonc - markdownlint-cli2 \ - --config "resources/.markdownlint-cli2.yaml" "**/*.md" \ - > check_reports/markdown_lint_report.txt + markdownlint-cli2 "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 # Commit the rendered bookdown files - name: Commit markdown report to preview branch id: commit run: | branch_name='preview-${{ github.event.pull_request.number }}' - echo "markdown_issues=$(wc -l check_reports/markdown_lint_report.txt)" >> $GITHUB_OUTPUT + error_num=$(cat check_reports/markdown_lint_report.txt | wc -l) + error_num="$((error_num-12))" + echo "markdown_issues=$error_num" >> $GITHUB_OUTPUT git add check_reports/markdown_lint_report.txt --force git commit -m 'Add markdown report' || echo "No report to commit" git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours @@ -163,9 +163,7 @@ jobs: - name: Build components of the comment id: build-components run: | - - course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-") - report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/report_link.zip") + report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/check_reports/markdown_lint_report.txt") echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT echo ${{steps.commit.outputs.markdown_issues}} @@ -177,7 +175,8 @@ jobs: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | - [Markdown linter report here](${{ steps.build-components.outputs.time }}) + [Markdown linter report here](${{ steps.build-components.outputs.report_link }}) + $(error_num) potential errors reported _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ edit-mode: replace From f3f2d249e00970a3de074e19c262128909dd77ea Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:18:03 -0500 Subject: [PATCH 11/21] Fix image: --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7ad12d75..ac60c340 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,8 +121,8 @@ jobs: needs: yaml-check runs-on: ubuntu-latest if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} - image : - container: davidanson/markdownlint-cli2:v0.17.1 + container: + image: davidanson/markdownlint-cli2:v0.17.1 steps: - name: Checkout files From f205a228b7c7c0909057de35adff39a9f3f5167c Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:23:10 -0500 Subject: [PATCH 12/21] Try not fetch-depth: 0 --- .github/workflows/pull_request.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ac60c340..4563d0a3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -127,8 +127,6 @@ jobs: steps: - name: Checkout files uses: actions/checkout@v4 - with: - fetch-depth: 0 - run: | mkdir -p check_reports From bedf96422ca9a180f56bba406ff120b1b1e893c0 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:25:37 -0500 Subject: [PATCH 13/21] Try not actually on the docker image --- .github/workflows/pull_request.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4563d0a3..f129a2c6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,8 +121,6 @@ jobs: needs: yaml-check runs-on: ubuntu-latest if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} - container: - image: davidanson/markdownlint-cli2:v0.17.1 steps: - name: Checkout files @@ -134,7 +132,8 @@ jobs: curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ -o resources/.markdownlint-cli2.jsonc - markdownlint-cli2 "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 + docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.17.1 \ + "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 # Commit the rendered bookdown files - name: Commit markdown report to preview branch From 5e6e662e0d8df7ab0f3f1d77985bd5e968e635cc Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:27:50 -0500 Subject: [PATCH 14/21] Try this way --- .github/workflows/pull_request.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f129a2c6..18ed6699 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -132,8 +132,9 @@ jobs: curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ -o resources/.markdownlint-cli2.jsonc - docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.17.1 \ - "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 + npm install markdownlint-cli2 --global + + markdownlint-cli2 "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 # Commit the rendered bookdown files - name: Commit markdown report to preview branch From e0a957fc465f3009019f2265ad30df0622239489 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:38:34 -0500 Subject: [PATCH 15/21] Try once more --- .github/workflows/pull_request.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 18ed6699..df4c87a9 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,6 +121,8 @@ jobs: needs: yaml-check runs-on: ubuntu-latest if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} + container: + image: davidanson/markdownlint-cli2 steps: - name: Checkout files @@ -132,9 +134,8 @@ jobs: curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ -o resources/.markdownlint-cli2.jsonc - npm install markdownlint-cli2 --global - - markdownlint-cli2 "**/*.md" "#node_modules" >> check_reports/markdown_lint_report.txt 2>&1 + docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.17.1 "**/*.md" "#node_modules" \ + >> check_reports/markdown_lint_report.txt 2>&1 # Commit the rendered bookdown files - name: Commit markdown report to preview branch From df4480aea5f48a9655c101b6ac8a9284b8667bb8 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 8 Jan 2025 14:39:08 -0500 Subject: [PATCH 16/21] markdownlint-cli2 --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index df4c87a9..513d3a74 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -134,7 +134,7 @@ jobs: curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ -o resources/.markdownlint-cli2.jsonc - docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.17.1 "**/*.md" "#node_modules" \ + markdownlint-cli2 "**/*.md" "#node_modules" \ >> check_reports/markdown_lint_report.txt 2>&1 # Commit the rendered bookdown files From 48c6123f02dbdf28104cbb60d0df4c9bc3eeb3d4 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Fri, 10 Jan 2025 12:08:21 -0500 Subject: [PATCH 17/21] Update linter --- .github/workflows/pull_request.yml | 47 +++++------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 513d3a74..94ba5184 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -121,35 +121,15 @@ jobs: needs: yaml-check runs-on: ubuntu-latest if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} - container: - image: davidanson/markdownlint-cli2 steps: - name: Checkout files uses: actions/checkout@v4 - - run: | - mkdir -p check_reports - - curl "https://github.com/DavidAnson/markdownlint-cli2/blob/af14a2e768b741b941255b4c6b875339b4acbb73/test/config-files/cfg/.markdownlint-cli2.jsonc" \ - -o resources/.markdownlint-cli2.jsonc - - markdownlint-cli2 "**/*.md" "#node_modules" \ - >> check_reports/markdown_lint_report.txt 2>&1 - - # Commit the rendered bookdown files - - name: Commit markdown report to preview branch - id: commit - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - error_num=$(cat check_reports/markdown_lint_report.txt | wc -l) - error_num="$((error_num-12))" - echo "markdown_issues=$error_num" >> $GITHUB_OUTPUT - git add check_reports/markdown_lint_report.txt --force - git commit -m 'Add markdown report' || echo "No report to commit" - git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours - git push --force || echo "No report to commit" - shell: bash + - uses: DavidAnson/markdownlint-cli2-action@v19 + with: + globs: '**/*.md' + continue-on-error: true - name: Find Comment uses: peter-evans/find-comment@v2 @@ -157,39 +137,26 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' - body-includes: + body-includes: Markdown linter - name: Build components of the comment id: build-components run: | - report_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/check_reports/markdown_lint_report.txt") + report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}") echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT echo ${{steps.commit.outputs.markdown_issues}} - - name: Create or update comment - if: steps.commit.outputs.markdown_issues > 4 + - name: Create or uxpdate comment uses: peter-evans/create-or-update-comment@v2 with: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | [Markdown linter report here](${{ steps.build-components.outputs.report_link }}) - $(error_num) potential errors reported _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ edit-mode: replace - - name: Comment if no changes - if: steps.commit.outputs.markdown_issues > 4 - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - Markdown linter report did not find any issues! - _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace - ############################# Readability Report ################################### readability-report: From 7967ce1721ecb96829146e265d24a3798350526b Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Fri, 10 Jan 2025 12:12:12 -0500 Subject: [PATCH 18/21] continue-on-error: true --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 94ba5184..fa4b9b43 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -129,7 +129,7 @@ jobs: - uses: DavidAnson/markdownlint-cli2-action@v19 with: globs: '**/*.md' - continue-on-error: true + continue-on-error: true - name: Find Comment uses: peter-evans/find-comment@v2 From 797de853734011f60107d4987ddf4641cbd373ae Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Fri, 10 Jan 2025 12:21:45 -0500 Subject: [PATCH 19/21] Try this out --- .github/workflows/pull_request.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fa4b9b43..fd94ba7f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -139,10 +139,19 @@ jobs: comment-author: 'github-actions[bot]' body-includes: Markdown linter + - name: Get Job ID from GH API + id: get-job-id + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id}}/attempts/${{ github.run_attempt }}/jobs) + job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .id') + echo "job_id=$job_id" >> $GITHUB_OUTPUT + - name: Build components of the comment id: build-components run: | - report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}") + report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ steps.get-job-id.outputs.job_id }}") echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT echo ${{steps.commit.outputs.markdown_issues}} From 96df0aa7e7118823429a87d02589118cdebf3680 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Fri, 10 Jan 2025 12:23:45 -0500 Subject: [PATCH 20/21] echo it --- .github/workflows/pull_request.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index fd94ba7f..edb6e144 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -142,16 +142,18 @@ jobs: - name: Get Job ID from GH API id: get-job-id env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GH_PAT }} run: | jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id}}/attempts/${{ github.run_attempt }}/jobs) job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .id') + echo $job_id echo "job_id=$job_id" >> $GITHUB_OUTPUT - name: Build components of the comment id: build-components run: | report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ steps.get-job-id.outputs.job_id }}") + echo $report_link echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT echo ${{steps.commit.outputs.markdown_issues}} From 52b3549e74eda0438635dc5d3b0254125dbfcbf5 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Fri, 10 Jan 2025 13:51:31 -0500 Subject: [PATCH 21/21] Delete for now --- .github/workflows/pull_request.yml | 53 ------------------------------ 1 file changed, 53 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index edb6e144..091af950 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -115,59 +115,6 @@ jobs: git commit -m 'Style *mds' || echo "No changes to commit" git push origin || echo "No changes to commit" -############################# Check Markdown Formatting ################################### - markdown-linter: - name: Markdown linter - needs: yaml-check - runs-on: ubuntu-latest - if: ${{needs.yaml-check.outputs.toggle_md_linter == 'yes'}} - - steps: - - name: Checkout files - uses: actions/checkout@v4 - - - uses: DavidAnson/markdownlint-cli2-action@v19 - with: - globs: '**/*.md' - continue-on-error: true - - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: Markdown linter - - - name: Get Job ID from GH API - id: get-job-id - env: - GH_TOKEN: ${{ secrets.GH_PAT }} - run: | - jobs=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id}}/attempts/${{ github.run_attempt }}/jobs) - job_id=$(echo $jobs | jq -r '.jobs[] | select(.runner_name=="${{ runner.name }}") | .id') - echo $job_id - echo "job_id=$job_id" >> $GITHUB_OUTPUT - - - name: Build components of the comment - id: build-components - run: | - report_link=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ steps.get-job-id.outputs.job_id }}") - echo $report_link - echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT - echo ${{steps.commit.outputs.markdown_issues}} - - - name: Create or uxpdate comment - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - [Markdown linter report here](${{ steps.build-components.outputs.report_link }}) - _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace - ############################# Readability Report ################################### readability-report: