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 HTML validator action #579

Merged
merged 14 commits into from
Dec 30, 2021
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ci": {
"collect": {
"staticDistDir": "./_site",
"autodiscoverUrlBlocklist": [
"conduct.html"
],
"settings": {
"skipAudits": ["canonical"]
}
},
"assert": {
"assertions": {
"categories:performance": ["error", { "minScore": 0.95 }],
"categories:accessibility": ["error", { "minScore": 0.95 }],
"categories:best-practices": ["error", { "minScore": 0.95 }],
"categories:seo": ["error", { "minScore": 0.95 }]
}
}
}
}
108 changes: 108 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
name: Build Jekyll site for testing

steps:
- uses: actions/checkout@v2

- name: Build the site in the Jekyll/builder container
run: |
docker run \
-v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have nox usable with this repository now, so we could just re-use that here via a verb like nox -s build. That might reduce some redundancy.

@nox.session(venv_backend='conda')
def build(session):
install_deps(session)
session.run(*"bundle exec jekyll serve liveserve".split())

We'd need to update that so that there was a build verb that didn't also do liveserve but that would be easy

jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future"

- name: List result of Jekyll build
run: |
ls _site/ -l
ls _site/assets -l

# - name: Copy assets
# run: cp -r assets _site/assets

- name: Publish built site
uses: actions/upload-artifact@v2
with:
name: Built site ${{ github.run_number }}
path: ./_site
if-no-files-found: error

validate:

runs-on: ubuntu-latest
name: Validate HTML
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add a comment somewhere just saying what we mean by "validate"? e.g., are we just doing some kind of basic integrity check? And would this not be captured by lighthouse already?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some of them overlap (like alt meta tags for images, but others are not caught by Lighthouse).

By validate we mean run though W3C-sanctioned HTML integrity validator. In this case we use https://github.com/validator (https://validator.github.io/validator/) backend "Nu". It is featured on W3C: https://validator.w3.org/nu/ and https://validator.w3.org/docs/help.html#validation_basics describes what validation means to them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

then maybe we could just add a comment like # See https://validator.w3.org/docs/help.html#validation_basics for more information?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added link to that to README in e62e6b0

needs: [build]

steps:
- name: Fetch built site
uses: actions/download-artifact@v2
with:
name: Built site ${{ github.run_number }}
path: ./_site

# just to satisfy the `Cyb3r-Jak3/html5validator-action` action
- name: Create dummy git repository
run: git init

- name: HTML5 Validator
uses: Cyb3r-Jak3/html5validator-action@44696509d19bec6bd00e5ebf29bbeda320562aac
with:
root: _site/

check-links:

runs-on: ubuntu-latest
name: Check links
needs: [build]

steps:
- name: Fetch built site
uses: actions/download-artifact@v2
with:
name: Built site ${{ github.run_number }}
path: ./_site

- name: Install link check dependencies
run: pip install pytest-check-links

# TODO: we are not checking absolute links as pytest plugins does not support them
- name: Check links
run: |
pytest _site/ --check-links \
--check-links-ignore "https://.*linkedin.com/.*" \
--check-links-ignore "/" \
--check-links-ignore ".github/images/netlify-preview.png"

lighthouse:

runs-on: ubuntu-latest
name: Audit with Lighthouse
needs: [build]

steps:
- name: Fetch repository for `lighthouserc.json`
uses: actions/checkout@v2
- name: Fetch built site
uses: actions/download-artifact@v2
with:
name: Built site ${{ github.run_number }}
path: ./_site
- name: Audit with Lighthouse
uses: treosh/lighthouse-ci-action@v8
with:
configPath: ".github/workflows/lighthouserc.json"
temporaryPublicStorage: true
uploadArtifacts: true
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To build and preview the site locally, follow these steps:
3. **Run the `build` command**

```console
$ nox -s build
$ nox -s build-live
```


Expand Down Expand Up @@ -141,3 +141,16 @@ For images that are "above the fold" (that will be seen by users immediately aft
```html
<img class="my-class" src="my/src.png" loading="eager" />
```

### Automated quality checks

A workflow on GitHub Actions is run at every push and for every pull request to ensure basic integrity of the website:
- [validating](https://validator.w3.org/docs/help.html#validation_basics) the structure of the HTML using [Nu validator](https://validator.github.io/validator/) to ensure compliance with HTML standards
- checking linked URLs for errors (including expired certificates)
- running [Lighthouse](https://github.com/GoogleChrome/lighthouse) audits to ensure performance, accessibility, SEO optimization and best practices

If pre-defined quality targets are not met, the jobs will fail.
Click on "Details" link for the failing job to see what caused the failure.

The detailed results will be available in the logs (which are only shown to users logged in on GitHub),
including links to full Lighthouse reports on public temporary storage (the links will expire after 7 days).
6 changes: 3 additions & 3 deletions binder.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ about the deployment. Here are a few useful resources in case you're interested:
information about the BinderHub deployment at mybinder.org
* [The mybinder.org billing repository](https://github.com/jupyterhub/binder-billing) has
information about the cloud cost associated with running mybinder.org
* [The mybinder.org site reliability guide](mybinder-sre.readthedocs.io/) is a resource
* [The mybinder.org site reliability guide](https://mybinder-sre.readthedocs.io/en/latest/) is a resource
for the operations team and the community to share best-practices and information about
running the public BinderHub deployment at mybinder.org
* [The mybinder.org incident reports page](mybinder-sre.readthedocs.io/en/latest/#incident-reports)
* [The mybinder.org incident reports page](https://mybinder-sre.readthedocs.io/en/latest/#incident-reports)
contains a list of incidents that have happened in the public deployment, as well as
steps taken to resolve them.

Expand All @@ -123,7 +123,7 @@ to join our community and contribute code, time, comments, or appreciation.
the current members of the JupyterHub and Binder teams.
* [**The JupyterHub Contributing guide**](https://jupyterhub-team-compass.readthedocs.io/en/latest/contributing.html) is
a great place to start learning how you can contribute to the Binder Project.
* [**The Binder Gitter Channel**](https://gitter.im/binder) is where a lot of real-time
* [**The Binder Gitter Channel**](https://gitter.im/jupyterhub/binder) is where a lot of real-time
conversations happen in the Binder community.
* [**The Binder Community Forum**](https://discourse.jupyter.org/c/binder) has a lot of
community interaction and useful information about using, running, and contributing to Binder.
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
height: 627
buttons:
- class:
href: try
href: /try
text: Try it in your browser
- class: install-button
href: install
href: /install
text: Install JupyterLab

notebook:
Expand All @@ -54,10 +54,10 @@
height: 627
buttons:
- class:
href: try
href: /try
text: Try it in your browser
- class: install-button
href: install
href: /install
text: Install the Notebook
features:
- headline: Language of choice
Expand Down Expand Up @@ -112,7 +112,7 @@
alt: icon to represent data
src: assets/data.svg
button:
href: hub
href: /hub
text: Learn more about JupyterHub

voila:
Expand All @@ -125,10 +125,10 @@
height: 716
buttons:
- class:
href: try
href: /try
text: Try it in your browser
- class: install-button
href: install
href: /install
text: Install Voilà

open_standards:
Expand Down Expand Up @@ -287,7 +287,7 @@ <h4 class="jumbotron-text">{{ page.jumbotron.text }}</h4>
<div class="col-md-6">
<picture>
<source type="image/webp" srcset="{{ page.jupyterlab.image.src }}.webp">
<img src="{{ page.jupyterlab.image.src }}.jpg"
<img src="{{ page.jupyterlab.image.src }}.png"
alt="{{ page.jupyterlab.image.alt }}"
width={{ page.jupyterlab.image.width }}
height={{ page.jupyterlab.image.height }}
Expand Down Expand Up @@ -319,7 +319,7 @@ <h4 class="nb-desc">{{ page.jupyterlab.description }}</h4>
<div class="col-md-6">
<picture>
<source type="image/webp" srcset="{{ page.notebook.image.src }}.webp">
<img src="{{ page.notebook.image.src }}.jpg"
<img src="{{ page.notebook.image.src }}.png"
alt="{{ page.notebook.image.alt }}"
width={{ page.notebook.image.width }}
height={{ page.notebook.image.height }}
Expand Down Expand Up @@ -397,7 +397,7 @@ <h4>{{ feat.headline }}</h4>
<div class="col-md-6">
<picture>
<source type="image/webp" srcset="{{ page.voila.image.src }}.webp">
<img src="{{ page.voila.image.src }}.jpg"
<img src="{{ page.voila.image.src }}.png"
alt="{{ page.voila.image.alt }}"
width={{ img.width }}
height={{ img.height }}
Expand Down
7 changes: 6 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ def install_deps(session):
session.run(*"bundle install".split())


@nox.session(name="build-live", venv_backend='conda')
def build_live(session):
install_deps(session)
session.run(*"bundle exec jekyll serve liveserve".split())

@nox.session(venv_backend='conda')
def build(session):
install_deps(session)
session.run(*"bundle exec jekyll serve liveserve".split())
session.run(*"bundle exec jekyll build".split())
2 changes: 1 addition & 1 deletion widgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ <h3>Installation</h3>
</span>
</div>
<p>
<a href="https://BeakerX.com">BeakerX</a> includes widgets
<a href="http://beakerx.com">BeakerX</a> includes widgets
for interactive tables, plots, forms, Apache Spark, and more.
The table widget automatically recognizes pandas dataframes
and allows you to search, sort, drag, filter, format,
Expand Down