|
| 1 | +name: Validate Site |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + validate: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Build with Jekyll |
| 19 | + uses: actions/jekyll-build-pages@v1 |
| 20 | + with: |
| 21 | + source: . |
| 22 | + destination: ./_site |
| 23 | + |
| 24 | + - name: Validate generated output |
| 25 | + run: | |
| 26 | + set -euo pipefail |
| 27 | +
|
| 28 | + for f in \ |
| 29 | + _site/index.html \ |
| 30 | + _site/assets.html \ |
| 31 | + _site/challenge.html \ |
| 32 | + _site/capability.html \ |
| 33 | + _site/framework.html \ |
| 34 | + _site/decisions.html \ |
| 35 | + _site/measurement.html \ |
| 36 | + _site/barriers.html \ |
| 37 | + _site/assets/css/site.css \ |
| 38 | + _site/assets/js/site.js \ |
| 39 | + _site/assets/images/network.png \ |
| 40 | + _site/assets/images/kore-logo-horizontal-gradient-dark.svg; do |
| 41 | + test -f "$f" || { echo "Missing expected file: $f"; exit 1; } |
| 42 | + done |
| 43 | +
|
| 44 | + python3 - <<'PY' |
| 45 | + import re |
| 46 | + import pathlib |
| 47 | + import sys |
| 48 | +
|
| 49 | + pages = [ |
| 50 | + "_site/index.html", |
| 51 | + "_site/assets.html", |
| 52 | + "_site/challenge.html", |
| 53 | + "_site/capability.html", |
| 54 | + "_site/framework.html", |
| 55 | + "_site/decisions.html", |
| 56 | + "_site/measurement.html", |
| 57 | + "_site/barriers.html", |
| 58 | + ] |
| 59 | + nav_targets = [ |
| 60 | + "/assets.html", |
| 61 | + "/challenge.html", |
| 62 | + "/capability.html", |
| 63 | + "/framework.html", |
| 64 | + "/decisions.html", |
| 65 | + "/measurement.html", |
| 66 | + "/barriers.html", |
| 67 | + ] |
| 68 | + expected_canonical = { |
| 69 | + "_site/index.html": "https://knowledge-intelligence.dev/", |
| 70 | + "_site/assets.html": "https://knowledge-intelligence.dev/assets.html", |
| 71 | + "_site/challenge.html": "https://knowledge-intelligence.dev/challenge.html", |
| 72 | + "_site/capability.html": "https://knowledge-intelligence.dev/capability.html", |
| 73 | + "_site/framework.html": "https://knowledge-intelligence.dev/framework.html", |
| 74 | + "_site/decisions.html": "https://knowledge-intelligence.dev/decisions.html", |
| 75 | + "_site/measurement.html": "https://knowledge-intelligence.dev/measurement.html", |
| 76 | + "_site/barriers.html": "https://knowledge-intelligence.dev/barriers.html", |
| 77 | + } |
| 78 | +
|
| 79 | + for page in pages: |
| 80 | + html = pathlib.Path(page).read_text(encoding="utf-8") |
| 81 | + if 'href="/assets/css/site.css"' not in html: |
| 82 | + print(f"Missing shared CSS reference in {page}") |
| 83 | + sys.exit(1) |
| 84 | + if 'src="/assets/js/site.js"' not in html: |
| 85 | + print(f"Missing shared JS reference in {page}") |
| 86 | + sys.exit(1) |
| 87 | + for target in nav_targets: |
| 88 | + if f'href="{target}"' not in html: |
| 89 | + print(f"Missing nav target {target} in {page}") |
| 90 | + sys.exit(1) |
| 91 | + match = re.search(r'<link rel="canonical" href="([^"]+)"', html) |
| 92 | + if not match: |
| 93 | + print(f"Missing canonical tag in {page}") |
| 94 | + sys.exit(1) |
| 95 | + if match.group(1) != expected_canonical[page]: |
| 96 | + print(f"Canonical mismatch in {page}: {match.group(1)}") |
| 97 | + sys.exit(1) |
| 98 | +
|
| 99 | + print("Validation passed.") |
| 100 | + PY |
0 commit comments