From 218bfbaa9839f3fad557351dbebd3d44268337ff Mon Sep 17 00:00:00 2001 From: PrathumP <115390367+PrathumP@users.noreply.github.com> Date: Sat, 8 Jul 2023 23:51:31 +0530 Subject: [PATCH 1/8] Added .yml file --- .github/workflows/link-check.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/link-check.yml diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml new file mode 100644 index 00000000..524df09c --- /dev/null +++ b/.github/workflows/link-check.yml @@ -0,0 +1,23 @@ +name: Link Check + +# this cancels workflows currently in progress if you start a new one +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + schedule: + - cron: "0 9 * * *" + +jobs: + link-check: + runs-on: [ubuntu-20.04] + + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies + run: npm install + + - name: Run link check + run: ./ci/link_check.sh From 56ec68c743d29d7805a57ffb0d9c48f586dff53c Mon Sep 17 00:00:00 2001 From: PrathumP <115390367+PrathumP@users.noreply.github.com> Date: Sat, 8 Jul 2023 23:59:56 +0530 Subject: [PATCH 2/8] Modified link-check.yml --- .github/workflows/link-check.yml | 38 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 524df09c..2e6d3c46 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -10,14 +10,32 @@ on: - cron: "0 9 * * *" jobs: - link-check: - runs-on: [ubuntu-20.04] + build-and-test: + runs-on: [ubuntu-20.04] + steps: + - uses: actions/checkout@v3 + + - run: sudo apt install -y jq + + - name: get latest roc nightly + run: | + curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz + - name: rename nightly tar + run: mv $(ls | grep "roc_nightly.*tar\.gz") roc_nightly.tar.gz + + - name: decompress the tar + run: tar -xzf roc_nightly.tar.gz + + - run: rm roc_nightly.tar.gz + + - name: simplify nightly folder name + run: mv roc_nightly* roc_nightly + + - run: ./roc_nightly/roc version - steps: - - uses: actions/checkout@v3 - - - name: Install dependencies - run: npm install - - - name: Run link check - run: ./ci/link_check.sh + - run: sudo apt install -y expect ncat + # expect for testing + # ncat for tcp-client example + + - name: Run link check + run: ./ci/link_check.sh From 83698757d5ee8ea8d1c174d31a29209055e47716 Mon Sep 17 00:00:00 2001 From: PrathumP <115390367+PrathumP@users.noreply.github.com> Date: Sun, 9 Jul 2023 02:13:56 +0530 Subject: [PATCH 3/8] Added link_check.sh --- .github/workflows/link-check.yml | 4 +--- ci/link_check.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 ci/link_check.sh diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 2e6d3c46..00e0619b 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -15,8 +15,6 @@ jobs: steps: - uses: actions/checkout@v3 - - run: sudo apt install -y jq - - name: get latest roc nightly run: | curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz @@ -36,6 +34,6 @@ jobs: - run: sudo apt install -y expect ncat # expect for testing # ncat for tcp-client example - + - name: Run link check run: ./ci/link_check.sh diff --git a/ci/link_check.sh b/ci/link_check.sh new file mode 100644 index 00000000..6c60c6d0 --- /dev/null +++ b/ci/link_check.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -euxo pipefail + +base_url="https://www.roc-lang.org/packages/basic-cli/" + +timeout=15 #timeout in seconds + +broken_links=() + +extract_links() { + curl -s "$1" | grep -Eo 'href="([^"#]+)"' | cut -d'"' -f2 +} + +links=$(extract_links "$base_url") + +for link in "${links[@]}"; do + full_link="${base_url}${link}" + status=$(curl -o /dev/null -s -w "%{http_code}" --connect-timeout $timeout "$full_link") + if [[ $status != 200 ]]; then + broken_links+=("$full_link") + fi +done + +if [[ ${#broken_links[@]} -gt 0 ]]; then + echo "Broken links found:" + printf '%s\n' "${broken_links[@]}" + exit 1 +fi \ No newline at end of file From 1921afdf001747ddb403371b0346c061db48286a Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:56:35 +0200 Subject: [PATCH 4/8] simplified workflow --- .github/workflows/link-check.yml | 38 +++++++------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 00e0619b..7d5f7fe1 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -1,39 +1,17 @@ -name: Link Check +on: + pull_request: # temporary for testing + schedule: + - cron: "0 9 * * *" -# this cancels workflows currently in progress if you start a new one +name: Check roc-lang.org/packages/basic-cli/ for broken links + +# this cancels workflows in progress if you start a new one concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - -on: - schedule: - - cron: "0 9 * * *" jobs: build-and-test: runs-on: [ubuntu-20.04] steps: - - uses: actions/checkout@v3 - - - name: get latest roc nightly - run: | - curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz - - name: rename nightly tar - run: mv $(ls | grep "roc_nightly.*tar\.gz") roc_nightly.tar.gz - - - name: decompress the tar - run: tar -xzf roc_nightly.tar.gz - - - run: rm roc_nightly.tar.gz - - - name: simplify nightly folder name - run: mv roc_nightly* roc_nightly - - - run: ./roc_nightly/roc version - - - run: sudo apt install -y expect ncat - # expect for testing - # ncat for tcp-client example - - - name: Run link check - run: ./ci/link_check.sh + - run: ./ci/link_check.sh From 4b8a8b4561d9fcbd59a280bb22488a20b720ad28 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:08:10 +0200 Subject: [PATCH 5/8] re-add checkout --- .github/workflows/{link-check.yml => link_check.yml} | 2 ++ 1 file changed, 2 insertions(+) rename .github/workflows/{link-check.yml => link_check.yml} (91%) diff --git a/.github/workflows/link-check.yml b/.github/workflows/link_check.yml similarity index 91% rename from .github/workflows/link-check.yml rename to .github/workflows/link_check.yml index 7d5f7fe1..18d6051b 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link_check.yml @@ -14,4 +14,6 @@ jobs: build-and-test: runs-on: [ubuntu-20.04] steps: + - uses: actions/checkout@v3 + - run: ./ci/link_check.sh From 37d6d8415d62bf1bf831cdbea0be2c0f730ee9b8 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:20:43 +0200 Subject: [PATCH 6/8] chmod +x link_check.sh --- ci/link_check.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 ci/link_check.sh diff --git a/ci/link_check.sh b/ci/link_check.sh old mode 100644 new mode 100755 From 590215e4480ec8baf7024f691345430362396855 Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:24:01 +0200 Subject: [PATCH 7/8] simplifty name --- .github/workflows/link_check.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/link_check.yml b/.github/workflows/link_check.yml index 18d6051b..f36a987c 100644 --- a/.github/workflows/link_check.yml +++ b/.github/workflows/link_check.yml @@ -3,15 +3,13 @@ on: schedule: - cron: "0 9 * * *" -name: Check roc-lang.org/packages/basic-cli/ for broken links - # this cancels workflows in progress if you start a new one concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: - build-and-test: + check-basic-cli-docs-broken-links: runs-on: [ubuntu-20.04] steps: - uses: actions/checkout@v3 From 324af58713de86256afb7f426071647506a6fc4a Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:24:34 +0200 Subject: [PATCH 8/8] remove / at end base_url --- ci/link_check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/link_check.sh b/ci/link_check.sh index 6c60c6d0..e9ff574d 100755 --- a/ci/link_check.sh +++ b/ci/link_check.sh @@ -3,7 +3,7 @@ # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ set -euxo pipefail -base_url="https://www.roc-lang.org/packages/basic-cli/" +base_url="https://www.roc-lang.org/packages/basic-cli" timeout=15 #timeout in seconds @@ -27,4 +27,4 @@ if [[ ${#broken_links[@]} -gt 0 ]]; then echo "Broken links found:" printf '%s\n' "${broken_links[@]}" exit 1 -fi \ No newline at end of file +fi