Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow for link checking and spelling #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .ci_support/check_links.sh
Original file line number Diff line number Diff line change
@@ -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)"
23 changes: 23 additions & 0 deletions .ci_support/check_spelling.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .ci_support/dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DeclarativeWidgets
JEP
Jupyter
md
Xeus
8 changes: 8 additions & 0 deletions .ci_support/environment-spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: spelling

channels:
- conda-forge

dependencies:
- hunspell-en >=2020.06.01
- hunspell >=1.7.0,<2
1 change: 1 addition & 0 deletions .ci_support/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jupyter-book >=0.7.0,<1
2 changes: 2 additions & 0 deletions .ci_support/requirements-check-links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest-check-links >=0.4.2,<1
requests_cache >=0.5.2,<1
121 changes: 121 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Linting

on:
pull_request:
branches:
- master
push:
branches:
- master
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this here, aside from doing one last check on master (which would get a little more visibility... I guess badges would be better!), also ensures all the caches are created in that "context"... PRs can be use it as a fallback with restore-keys.


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow I didn't realize it was so easy to persist artifacts in GHA haha

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/[email protected]
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the likelihood that this is going to be triggered on a regular basis just because people are using non-standard words in JEPs etc? I'm a bit concerned that this is going to feel like a nagging bot that keeps telling people to slightly change wording that they think is correct. Do you know what I mean?


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is that we could use the link checker from Sphinx. Jupyter Book supports users calling it with jupyter-book build . --builder linkcheck. It's a little finnicky in my experience, but maybe that's true of all link checkers. Could simply the build process a bit?

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ node_modules

# Jupyter Book
_build

# test cruft
*.sqlite