diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 000000000..86c76475a --- /dev/null +++ b/.github/workflows/links.yml @@ -0,0 +1,26 @@ +name: Check links + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: '3.9' + architecture: 'x64' + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements.txt + + - name: Check links + run: | + # This will not make anything fail on build, but at least we will know + pytest -s diff --git a/.gitignore b/.gitignore index 33e604e35..dfbcbaefe 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ docs/2023-24/year-1/t3 docs/2023-24/year-2/t2 docs/2023-24/year-2/t3 docs/2023-24/research-trip -docs/assets/images/zz \ No newline at end of file +docs/assets/images/zz +*.log \ No newline at end of file diff --git a/links.sh b/links.sh new file mode 100755 index 000000000..e81b2c633 --- /dev/null +++ b/links.sh @@ -0,0 +1,2 @@ +#!/usr/bin/bash +mkdocs-linkcheck docs -r --exclude assets -v -l> tests/out.log 2>tests/err.log diff --git a/requirements.txt b/requirements.txt index 9357100dd..344dbfbf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,8 @@ mkdocs-macros-plugin mkdocs-exclude mistune mkdocs-open-in-new-tab +mkdocs-linkcheck +pytest #mkdocs-print-site-plugin #mkdocs-plugin-tags #mkdocs-with-pdf diff --git a/tests/links/test_links.py b/tests/links/test_links.py new file mode 100644 index 000000000..42dbf43ce --- /dev/null +++ b/tests/links/test_links.py @@ -0,0 +1,13 @@ +import pytest +import subprocess +import os + +def test_links(): + out = 0 + try: + out = subprocess.call([os.path.join(os.getcwd(), "links.sh")]) + except: + pass + + print (out) + assert out == 0 \ No newline at end of file