Repository navigation
104 lines (93 loc) · 3.73 KB
/
Copy pathtest-article-headers.yml
File metadata and controls
104 lines (93 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Test Article Headers
# Manually audit the `<head>` metadata (title, description, keywords plus
# OpenGraph + Twitter siblings) that the article renderer would embed for
# every aggregated `analysis/daily/<date>/<subfolder>/article.md` — for the
# English locale only.
#
# The audit script (`scripts/test-article-headers.ts`) calls the same
# `computeArticleHeadMetadata` helper as the real article renderer
# (`scripts/render-lib/article.ts → renderArticleHtml`), so the report
# is guaranteed not to drift from what production HTML actually ships.
#
# Reference docs:
# - Article-Generation.md (full pipeline)
# - scripts/render-lib/article-head-metadata.ts (shared composer)
# - .github/workflows/regenerate-articles.yml (sibling deterministic workflow)
#
# Output: a human + AI readable text report uploaded as a workflow artifact
# (`test-article-headers-report`). First step toward improving the bad
# current state of titles / descriptions / keywords seen at
# https://riksdagsmonitor.com/news/index.html and
# https://riksdagsmonitor.com/news/2026-05-22-committee-reports-en.html.
on:
workflow_dispatch:
inputs:
limit:
description: 'Optional cap on the number of articles processed (smoke test). Leave blank to process all.'
required: false
default: ''
strict:
description: 'Fail the job when SEO budget violations (title>70, description>200) or content issues (empty description / keywords, missing brand suffix) are detected. Uncheck for a purely informational audit run.'
required: false
type: boolean
default: true
permissions:
contents: read
jobs:
audit:
name: Audit <head> metadata (English locale)
runs-on: ubuntu-26.04
timeout-minutes: 30
steps:
- name: Harden Runner
uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '26'
cache: 'npm'
cache-dependency-path: |
package-lock.json
.github/workflows/test-article-headers.yml
- name: Install dependencies
run: npm ci
- name: Run `<head>` audit (English locale, all articles)
env:
AUDIT_LIMIT: ${{ inputs.limit }}
AUDIT_STRICT: ${{ inputs.strict }}
run: |
mkdir -p reports
STRICT_FLAG=""
if [ "${AUDIT_STRICT:-true}" = "true" ]; then
STRICT_FLAG="--strict"
fi
if [ -n "${AUDIT_LIMIT:-}" ]; then
echo "Running with --limit ${AUDIT_LIMIT} ${STRICT_FLAG}"
npx tsx scripts/test-article-headers.ts \
--out reports/test-article-headers-report.txt \
--limit "${AUDIT_LIMIT}" \
${STRICT_FLAG}
else
echo "Running full corpus ${STRICT_FLAG}"
npx tsx scripts/test-article-headers.ts \
--out reports/test-article-headers-report.txt \
${STRICT_FLAG}
fi
- name: Print summary tail to job log
if: always()
run: |
echo "::group::Report summary (last 40 lines)"
tail -n 40 reports/test-article-headers-report.txt
echo "::endgroup::"
- name: Upload report artifact
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-article-headers-report
path: reports/test-article-headers-report.txt
retention-days: 30
if-no-files-found: error