diff --git a/.ci_support/check_links.sh b/.ci_support/check_links.sh new file mode 100755 index 00000000..8298e111 --- /dev/null +++ b/.ci_support/check_links.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +CACHE_NAME=$(pwd)/.pytest-check-links-cache +KNOWN_FAILS="\ +ibm \ +or declarativewidgets +" + +cd _build/html + + +pytest \ + --check-links \ + --check-links-cache \ + --check-links-cache-name $CACHE_NAME \ + --check-links-cache-expire-after 604800 \ + --links-ext html \ + -k "not ($KNOWN_FAILS)" diff --git a/.ci_support/check_spelling.sh b/.ci_support/check_spelling.sh new file mode 100755 index 00000000..8533bcf9 --- /dev/null +++ b/.ci_support/check_spelling.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "checking spelling..." + +cd _build/html + +hunspell \ + -d en-GB,en_US \ + -p ../../.ci_support/dictionary.txt \ + -l \ + -H **/*.html \ + | sort \ + | uniq \ + > check-spelling.txt + +if [ -s "check-spelling.txt" ]; then + echo "::warning ::{misspelled words found in built HTML}" + echo "::warning ::{$(cat check-spelling.txt)}" + exit 1 +else + echo "did not find any misspelled words" +fi diff --git a/.ci_support/dictionary.txt b/.ci_support/dictionary.txt new file mode 100644 index 00000000..e587aecf --- /dev/null +++ b/.ci_support/dictionary.txt @@ -0,0 +1,5 @@ +DeclarativeWidgets +JEP +Jupyter +md +Xeus diff --git a/.ci_support/environment-spelling.yml b/.ci_support/environment-spelling.yml new file mode 100644 index 00000000..be246282 --- /dev/null +++ b/.ci_support/environment-spelling.yml @@ -0,0 +1,8 @@ +name: spelling + +channels: + - conda-forge + +dependencies: + - hunspell-en >=2020.06.01 + - hunspell >=1.7.0,<2 diff --git a/.ci_support/requirements-build.txt b/.ci_support/requirements-build.txt new file mode 100644 index 00000000..c8d7b89c --- /dev/null +++ b/.ci_support/requirements-build.txt @@ -0,0 +1 @@ +jupyter-book >=0.7.0,<1 diff --git a/.ci_support/requirements-check-links.txt b/.ci_support/requirements-check-links.txt new file mode 100644 index 00000000..81c20df9 --- /dev/null +++ b/.ci_support/requirements-check-links.txt @@ -0,0 +1,2 @@ +pytest-check-links >=0.4.2,<1 +requests_cache >=0.5.2,<1 diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..7f6e5063 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,121 @@ +name: Linting + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Restore dependency cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-build-${{ hashFiles('.ci_support/requirements-build.txt') }} + restore-keys: | + pip-build- + pip- + + - name: Install dependencies + run: | + pip install -U -r .ci_support/requirements-build.txt + + - name: Build the book + run: | + jupyter-book build . + + - name: Upload book + uses: actions/upload-artifact@v2 + with: + name: _build + path: _build + + spelling: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v2 + + - name: Download book + uses: actions/download-artifact@v2 + with: + name: _build + path: _build + + - name: Restore dependency cache + uses: actions/cache@v1 + with: + path: ~/conda_pkgs_dir + key: conda-spelling-${{ hashFiles('.ci_support/environment-spelling.yml') }} + restore-keys: | + conda-spelling- + conda- + + - name: Install dependencies + uses: goanpeca/setup-miniconda@v1.6.0 + with: + activate-environment: spelling + channel-priority: strict + environment-file: .ci_support/environment-spelling.yml + use-only-tar-bz2: true + + - name: Find misspelled words + shell: bash -l {0} + run: | + bash .ci_support/check_spelling.sh + + links: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v2 + + - name: Download book + uses: actions/download-artifact@v2 + with: + name: _build + path: _build + + - name: Restore link cache + uses: actions/cache@v2 + with: + path: .pytest-check-links-cache.sqlite + key: links-checked-${{ hashFiles('.ci_support/requirements-check-links.txt') }} + restore-keys: | + links-checked- + + - name: Restore dependency cache + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-check-links-${{ hashFiles('.ci_support/requirements-check-links.txt') }} + restore-keys: | + pip-check-links- + pip- + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + pip install -U -r .ci_support/requirements-check-links.txt + + - name: Find broken links + run: | + bash .ci_support/check_links.sh diff --git a/.gitignore b/.gitignore index 422ea682..43e48932 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ node_modules # Jupyter Book _build + +# test cruft +*.sqlite