Skip to content
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
40 changes: 40 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check

# The site has no build step, so its pages link brand.css with a version written by hand: /brand.css?v= and the first
# 10 hex of the file's sha256. GitHub Pages lets a browser reuse a file for 10 minutes, and the version gives a changed
# stylesheet a new URL, so a returning visitor never gets new HTML with an old cached brand.css. This fails when a
# page's version doesn't match the file, and prints the line to use.

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Stylesheet versions
run: |
python3 - <<'PY'
import hashlib, pathlib, re, sys
bad = 0
for page in sorted(pathlib.Path(".").glob("*.html")):
text = page.read_text(encoding="utf-8")
for m in re.finditer(r'<link rel="stylesheet" href="/([^"?#]+\.css)(?:\?v=(\w*))?">', text):
want = hashlib.sha256(pathlib.Path(m[1]).read_bytes()).hexdigest()[:10]
if m[2] != want:
print(f'::error file={page}::{m[0]} should be <link rel="stylesheet" href="/{m[1]}?v={want}">')
bad += 1
if re.search(r'<link rel="stylesheet" href="(?!/[^"?#]+\.css)', text) or re.search(r"<script[^>]*\bsrc=", text):
print(f"::error file={page}::links a stylesheet or script this check doesn't know; version it and extend the check")
bad += 1
sys.exit(1 if bad else 0)
PY
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"SoftwareApplication","name":"wheelgap","applicationCategory":"DeveloperApplication","operatingSystem":"Linux, macOS, Windows","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"description":"Finds the Python dependencies that have no prebuilt wheel for a target platform, before the build does, and gives the upgrade that fixes each one.","url":"https://wheelgap.github.io/","codeRepository":"https://github.com/wheelgap/wheelgap","license":"https://opensource.org/licenses/MIT"}
</script>
<link rel="stylesheet" href="/brand.css">
<link rel="stylesheet" href="/brand.css?v=e093748145">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<style>
/* The colours and fonts every wheelgap site shares, light and dark, from brand.css. */
Expand Down