From 84b34690293f87979307f558701013fe209f5931 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 19 Jun 2020 00:16:29 -0400 Subject: [PATCH 1/2] add workflow for link checking and spelling --- .ci_support/check_links.sh | 19 +++++ .ci_support/check_spelling.sh | 23 ++++++ .ci_support/dictionary.txt | 5 ++ .ci_support/environment-spelling.yml | 7 ++ .ci_support/requirements-build.txt | 1 + .ci_support/requirements-check-links.txt | 2 + .github/workflows/check.yml | 99 ++++++++++++++++++++++++ .gitignore | 3 + 8 files changed, 159 insertions(+) create mode 100755 .ci_support/check_links.sh create mode 100755 .ci_support/check_spelling.sh create mode 100644 .ci_support/dictionary.txt create mode 100644 .ci_support/environment-spelling.yml create mode 100644 .ci_support/requirements-build.txt create mode 100644 .ci_support/requirements-check-links.txt create mode 100644 .github/workflows/check.yml 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..2fd96203 --- /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 "hunspell found misspelled words" + cat check-spelling.txt + exit 1 +else + echo "hunspell 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..d3ed7122 --- /dev/null +++ b/.ci_support/dictionary.txt @@ -0,0 +1,5 @@ +DeclarativeWidgets +JEP +Jupyter +Xeus +md diff --git a/.ci_support/environment-spelling.yml b/.ci_support/environment-spelling.yml new file mode 100644 index 00000000..86a6fe8a --- /dev/null +++ b/.ci_support/environment-spelling.yml @@ -0,0 +1,7 @@ +name: spelling + +channels: + - conda-forge + +dependencies: + - hunspell-en diff --git a/.ci_support/requirements-build.txt b/.ci_support/requirements-build.txt new file mode 100644 index 00000000..9fc0428e --- /dev/null +++ b/.ci_support/requirements-build.txt @@ -0,0 +1 @@ +jupyter-book diff --git a/.ci_support/requirements-check-links.txt b/.ci_support/requirements-check-links.txt new file mode 100644 index 00000000..ed2db1f3 --- /dev/null +++ b/.ci_support/requirements-check-links.txt @@ -0,0 +1,2 @@ +pytest-check-links +requests_cache diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..d3a8a4ff --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,99 @@ +on: + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-build-${{ hashFiles('.ci_support/requirements-build.txt') }} + restore-keys: | + pip-build- + pip- + + - run: | + pip install -U -r .ci_support/requirements-build.txt + + - run: | + jupyter-book build . + + - uses: actions/upload-artifact@v2 + with: + name: _build + path: _build + + spelling: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: _build + path: _build + + - name: Cache conda + uses: actions/cache@v1 + with: + path: ~/conda_pkgs_dir + key: conda-spelling-${{ hashFiles('.ci_support/environment-spelling.yml') }} + restore-keys: | + conda-spelling- + conda- + + - 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 + + - shell: bash -l {0} + run: | + bash .ci_support/check_spelling.sh + + links: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: _build + path: _build + + - uses: actions/cache@v2 + with: + path: .pytest-check-links-cache.sqlite + key: link-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- + + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - run: | + pip install -U -r .ci_support/requirements-check-links.txt + + - 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 From dc5e46fea44cb42011d70e0e17be082e5a2546de Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 19 Jun 2020 08:01:01 -0400 Subject: [PATCH 2/2] step labels, more work on deps and cache, sort dictionary --- .ci_support/check_spelling.sh | 6 +-- .ci_support/dictionary.txt | 2 +- .ci_support/environment-spelling.yml | 3 +- .ci_support/requirements-build.txt | 2 +- .ci_support/requirements-check-links.txt | 4 +- .github/workflows/check.yml | 56 +++++++++++++++++------- 6 files changed, 48 insertions(+), 25 deletions(-) diff --git a/.ci_support/check_spelling.sh b/.ci_support/check_spelling.sh index 2fd96203..8533bcf9 100755 --- a/.ci_support/check_spelling.sh +++ b/.ci_support/check_spelling.sh @@ -15,9 +15,9 @@ hunspell \ > check-spelling.txt if [ -s "check-spelling.txt" ]; then - echo "hunspell found misspelled words" - cat check-spelling.txt + echo "::warning ::{misspelled words found in built HTML}" + echo "::warning ::{$(cat check-spelling.txt)}" exit 1 else - echo "hunspell did not find any misspelled words" + echo "did not find any misspelled words" fi diff --git a/.ci_support/dictionary.txt b/.ci_support/dictionary.txt index d3ed7122..e587aecf 100644 --- a/.ci_support/dictionary.txt +++ b/.ci_support/dictionary.txt @@ -1,5 +1,5 @@ DeclarativeWidgets JEP Jupyter -Xeus md +Xeus diff --git a/.ci_support/environment-spelling.yml b/.ci_support/environment-spelling.yml index 86a6fe8a..be246282 100644 --- a/.ci_support/environment-spelling.yml +++ b/.ci_support/environment-spelling.yml @@ -4,4 +4,5 @@ channels: - conda-forge dependencies: - - hunspell-en + - hunspell-en >=2020.06.01 + - hunspell >=1.7.0,<2 diff --git a/.ci_support/requirements-build.txt b/.ci_support/requirements-build.txt index 9fc0428e..c8d7b89c 100644 --- a/.ci_support/requirements-build.txt +++ b/.ci_support/requirements-build.txt @@ -1 +1 @@ -jupyter-book +jupyter-book >=0.7.0,<1 diff --git a/.ci_support/requirements-check-links.txt b/.ci_support/requirements-check-links.txt index ed2db1f3..81c20df9 100644 --- a/.ci_support/requirements-check-links.txt +++ b/.ci_support/requirements-check-links.txt @@ -1,2 +1,2 @@ -pytest-check-links -requests_cache +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 index d3a8a4ff..7f6e5063 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,6 +1,12 @@ +name: Linting + on: pull_request: - branches: [ master ] + branches: + - master + push: + branches: + - master jobs: build: @@ -8,11 +14,13 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 with: python-version: 3.7 - - uses: actions/cache@v2 + - name: Restore dependency cache + uses: actions/cache@v2 with: path: ~/.cache/pip key: pip-build-${{ hashFiles('.ci_support/requirements-build.txt') }} @@ -20,13 +28,16 @@ jobs: pip-build- pip- - - run: | + - name: Install dependencies + run: | pip install -U -r .ci_support/requirements-build.txt - - run: | + - name: Build the book + run: | jupyter-book build . - - uses: actions/upload-artifact@v2 + - name: Upload book + uses: actions/upload-artifact@v2 with: name: _build path: _build @@ -38,12 +49,13 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - name: Download book + uses: actions/download-artifact@v2 with: name: _build path: _build - - name: Cache conda + - name: Restore dependency cache uses: actions/cache@v1 with: path: ~/conda_pkgs_dir @@ -52,14 +64,16 @@ jobs: conda-spelling- conda- - - uses: goanpeca/setup-miniconda@v1.6.0 + - 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 - - shell: bash -l {0} + - name: Find misspelled words + shell: bash -l {0} run: | bash .ci_support/check_spelling.sh @@ -70,17 +84,22 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/download-artifact@v2 + - name: Download book + uses: actions/download-artifact@v2 with: name: _build path: _build - - uses: actions/cache@v2 + - name: Restore link cache + uses: actions/cache@v2 with: path: .pytest-check-links-cache.sqlite - key: link-cache + key: links-checked-${{ hashFiles('.ci_support/requirements-check-links.txt') }} + restore-keys: | + links-checked- - - uses: actions/cache@v2 + - name: Restore dependency cache + uses: actions/cache@v2 with: path: ~/.cache/pip key: pip-check-links-${{ hashFiles('.ci_support/requirements-check-links.txt') }} @@ -88,12 +107,15 @@ jobs: pip-check-links- pip- - - uses: actions/setup-python@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 with: python-version: 3.7 - - run: | + - name: Install dependencies + run: | pip install -U -r .ci_support/requirements-check-links.txt - - run: | + - name: Find broken links + run: | bash .ci_support/check_links.sh