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/
