test: add comprehensive testing infrastructure

- Add npm test scripts for build, markdown, HTML, and link validation
- Install markdownlint-cli for content quality checks
- Install html-validate for HTML5 conformity validation
- Add htmltest (via devbox) for internal/external link checking
- Configure test rules in .htmltest.yml, .htmlvalidate.json, .markdownlint.json
- Add GitHub Actions workflow for automated CI testing
- Add TESTING.md documentation for test usage
This commit is contained in:
Stephan Lo 2025-10-23 14:02:39 +02:00
parent d6f3d67724
commit 12e31ede91
6 changed files with 163 additions and 0 deletions

51
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,51 @@
name: Hugo Site Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: Install dependencies
run: |
npm ci
go install github.com/wjdp/htmltest@latest
- name: Run tests
run: |
npm run test:build
npm run test:markdown
npm run test:html
- name: Run link checker
run: htmltest
continue-on-error: true
- name: Upload htmltest results
uses: actions/upload-artifact@v4
if: always()
with:
name: htmltest-report
path: tmp/.htmltest/

10
.htmltest.yml Normal file
View file

@ -0,0 +1,10 @@
DirectoryPath: "public"
CheckExternal: true
CheckInternalHash: true
IgnoreURLs:
- "^https://example\\.docsy\\.dev"
- "^https://example\\.com"
- "^http://localhost"
IgnoreDirectoryMissingTrailingSlash: true
IgnoreAltMissing: true
CheckDoctype: true

12
.htmlvalidate.json Normal file
View file

@ -0,0 +1,12 @@
{
"extends": ["html-validate:recommended"],
"rules": {
"no-inline-style": "off",
"require-sri": "off",
"no-trailing-whitespace": "off",
"void-style": "off"
},
"elements": [
"html5"
]
}

8
.markdownlint.json Normal file
View file

@ -0,0 +1,8 @@
{
"default": true,
"MD013": false,
"MD033": false,
"MD041": false,
"MD024": { "siblings_only": true },
"MD025": { "front_matter_title": "" }
}

62
TESTING.md Normal file
View file

@ -0,0 +1,62 @@
# Hugo Site Testing
Dieses Projekt verwendet mehrere automatisierte Tests zur Qualitätssicherung.
## Verfügbare Tests
### 1. Build-Test
```bash
npm run test:build
```
Prüft ob die Hugo-Seite überhaupt baut und zeigt Warnungen/Fehler an.
### 2. Markdown-Linting
```bash
npm run test:markdown
```
Validiert Markdown-Dateien auf Stilprobleme und Best Practices.
### 3. HTML-Validierung
```bash
npm run test:html
```
Prüft die generierte HTML auf HTML5-Konformität.
### 4. Link-Checker
```bash
npm run test:links
```
Testet alle internen und externen Links auf Gültigkeit.
### Alle Tests ausführen
```bash
npm test
```
### Schnelle Tests (ohne Link-Check)
```bash
npm run test:quick
```
## Konfigurationsdateien
- `.htmltest.yml` - Link-Checker-Konfiguration
- `.htmlvalidate.json` - HTML-Validierungs-Regeln
- `.markdownlint.json` - Markdown-Linting-Regeln
## CI/CD Integration
GitHub Actions führt diese Tests automatisch bei jedem Push/PR aus:
- `.github/workflows/test.yml`
## Lokale Entwicklung
Vor dem Commit empfohlen:
```bash
npm run test:quick # Schnelle Tests
```
Vor dem Push:
```bash
npm test # Alle Tests inkl. Link-Check
```

20
package.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "ipceicis-developerframework",
"version": "1.0.0",
"scripts": {
"build": "hugo --gc --minify",
"test:build": "hugo --gc --minify --logLevel info",
"test:links": "htmltest",
"test:html": "html-validate 'public/**/*.html'",
"test:markdown": "markdownlint 'content/**/*.md'",
"test": "npm run test:build && npm run test:markdown && npm run test:html && npm run test:links",
"test:quick": "npm run test:build && npm run test:markdown"
},
"devDependencies": {
"autoprefixer": "^10.4.21",
"html-validate": "^10.1.2",
"markdownlint-cli": "^0.45.0",
"postcss": "^8.5.6",
"postcss-cli": "^11.0.1"
}
}