From 1ada6a20aeefef6f4daa42bffd8f5ac3deb46a25 Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 16:46:42 -0700 Subject: [PATCH 1/7] Add nighlty link checks per #366 --- .github/scripts/muffet.sh | 8 +++-- .github/workflows/daily.yml | 71 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/daily.yml diff --git a/.github/scripts/muffet.sh b/.github/scripts/muffet.sh index 1c819d5c2..4082c3203 100755 --- a/.github/scripts/muffet.sh +++ b/.github/scripts/muffet.sh @@ -16,7 +16,7 @@ muffet http://localhost:1313 \ --buffer-size 50000 \ - --timeout 35 \ + --timeout 10 \ --concurrency 2 \ --ignore-fragments \ --exclude ".*demo\.app\.medicmobile\.org.*" \ @@ -27,5 +27,7 @@ muffet http://localhost:1313 \ --exclude "https://github\.com/medic/cht-docs/commit.*" \ --exclude "https://github\.com/medic/cht-core/commit.*" \ --exclude "https://github\.com/medic/cht-docs/edit/master/.*" \ - --exclude ".*localhost:5984.*" \ - --exclude "https://docs.google.com/spreadsheets/d/12345ABCDEF/edit#gid=555666888" \ No newline at end of file + --exclude "http[s]*://localhost[8443|5984]*" \ + --exclude "http[s]*://cht\.domain\.com.*" \ + --exclude "http[s]*://127\.0\.0*" \ + --exclude "https://docs.google.com/spreadsheets/d/12345ABCDEF/.*" \ No newline at end of file diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml new file mode 100644 index 000000000..06b6801f4 --- /dev/null +++ b/.github/workflows/daily.yml @@ -0,0 +1,71 @@ +# Notes: +# - All software installed below is pinned so they don't get upgraded and break w/o us knowing why. +# - If you bump one version up to latest, please bump them all so we stay current! +# - Hugo builds the site twice: once for link checking and once minified for pushing live +# - Bash script for muffet is intentionally stand alone so devs/content editors can easily run it locally + +on: + schedule: + # * is a special character in YAML so you have to quote this string + # runs at 3:15am every day: +# - cron: '15 3 * * *' + # runs every 5 min +# - cron: '*/5 * * * *' + +name: Test site and push live if we're on Master +jobs: + BuildLinkCheckPushLive: + name: + runs-on: ubuntu-18.04 + timeout-minutes: 15 + steps: + + - name: All Branches - Git checkout, including recursive call for Docsy theme + uses: actions/checkout@v2 + with: + submodules: recursive # Fetch the Docsy theme + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + + - name: All Branches - Install hugo extended v0.71.1 + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: "0.71.1" + extended: true + + - name: All Branches - Install Node 12.x + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: All Branches - Install npm modules for Hugo + run: npm install + + - name: All Branches - Install Go v1.18 + uses: actions/setup-go@v2 + with: + go-version: '1.18' + + - name: All Branches - Install Muffet v1.5.7 + run: GO111MODULE=on go install github.com/raviqqe/muffet@1.5.7 + + # run in background so CI doesn't hang waiting for "ctrl + c". Sleep ensures server is ready in next step + - name: All Branches - Serve Hugo site + run: | + hugo server& + sleep 5 + + - name: All Branches - Run Muffet link checker + shell: bash + run: ./.github/scripts/muffet.sh + + - name: Master Branch Only - Report errors to Slack, if any + if: ${{ github.ref == 'refs/heads/master' && failure() }} + uses: rtCamp/action-slack-notify@v2.0.2 + env: + SLACK_WEBHOOK: '${{ secrets.SLACK_WEB_HOOK }}' + SLACK_CHANNEL: '#cht-squad-docs' + SLACK_COLOR: '#3278BD' + SLACK_ICON: ":flappingphone:" + SLACK_MESSAGE: 'Broken Links Found' + SLACK_TITLE: CHT DOCS BAD LINKS + SLACK_USERNAME: Medic-Bot From e5b98eecf536b90ef724c057b9c0cdde097b24e8 Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 16:51:29 -0700 Subject: [PATCH 2/7] test schedule --- .github/workflows/daily.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 06b6801f4..dfa41419a 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -10,7 +10,7 @@ on: # runs at 3:15am every day: # - cron: '15 3 * * *' # runs every 5 min -# - cron: '*/5 * * * *' + - cron: '*/5 * * * *' name: Test site and push live if we're on Master jobs: From 367f8354ee7029d2ea3e649c22edae7ea56d9171 Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 16:57:37 -0700 Subject: [PATCH 3/7] comment out schedule for now, switch master -> main --- .github/workflows/daily.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index dfa41419a..5a7ad28ff 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -10,7 +10,7 @@ on: # runs at 3:15am every day: # - cron: '15 3 * * *' # runs every 5 min - - cron: '*/5 * * * *' +# - cron: '*/5 * * * *' name: Test site and push live if we're on Master jobs: @@ -59,7 +59,7 @@ jobs: run: ./.github/scripts/muffet.sh - name: Master Branch Only - Report errors to Slack, if any - if: ${{ github.ref == 'refs/heads/master' && failure() }} + if: ${{ github.ref == 'refs/heads/main' && failure() }} uses: rtCamp/action-slack-notify@v2.0.2 env: SLACK_WEBHOOK: '${{ secrets.SLACK_WEB_HOOK }}' From 39f0f5df11d6b35b27128f4150b9070fa4527f6c Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 16:58:29 -0700 Subject: [PATCH 4/7] switch master -> main x2 --- .github/scripts/muffet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/muffet.sh b/.github/scripts/muffet.sh index 4082c3203..5d4d7ee50 100755 --- a/.github/scripts/muffet.sh +++ b/.github/scripts/muffet.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This script is used in Github Actions to do link checking on commits to branches and master, so +# This script is used in Github Actions to do link checking on commits to branches and main, so # please edit with care! See ../workflows/ci.yml for specific usage. # # If you're doing local development and want to run link checkers locally, please use this script! From 7a259836810f861d48498a51a6b51cdfad63bcca Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 19:32:21 -0700 Subject: [PATCH 5/7] second schedule test --- .github/workflows/daily.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 5a7ad28ff..b28e55804 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -6,11 +6,10 @@ on: schedule: - # * is a special character in YAML so you have to quote this string # runs at 3:15am every day: # - cron: '15 3 * * *' # runs every 5 min -# - cron: '*/5 * * * *' + - cron: '*/5 * * * *' name: Test site and push live if we're on Master jobs: From c00f4e866d90eaae4d7320089f5e0221bd688b94 Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 19:38:05 -0700 Subject: [PATCH 6/7] third schedule test --- .github/workflows/daily.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index b28e55804..c0673bee6 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -4,12 +4,13 @@ # - Hugo builds the site twice: once for link checking and once minified for pushing live # - Bash script for muffet is intentionally stand alone so devs/content editors can easily run it locally + +# runs every 5 min on: schedule: + - cron: '*/5 * * * *' # runs at 3:15am every day: # - cron: '15 3 * * *' - # runs every 5 min - - cron: '*/5 * * * *' name: Test site and push live if we're on Master jobs: From 2110cb48ba592403351cec268669a8bfec55996f Mon Sep 17 00:00:00 2001 From: mrjones-plip Date: Wed, 27 Apr 2022 19:42:47 -0700 Subject: [PATCH 7/7] switch over to real schedule --- .github/workflows/daily.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index c0673bee6..888afafd7 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -5,12 +5,12 @@ # - Bash script for muffet is intentionally stand alone so devs/content editors can easily run it locally -# runs every 5 min +# Scheduled workflows run on the latest commit on +# the default or base branch on: schedule: - - cron: '*/5 * * * *' - # runs at 3:15am every day: -# - cron: '15 3 * * *' + # runs at 3:15am every day + - cron: '15 3 * * *' name: Test site and push live if we're on Master jobs: