name: Documentation

on:
  push:
    branches: [ master ]
    paths-ignore:
      - 'src/pretix/locale/**'
      - 'src/pretix/static/**'
      - 'src/tests/**'
  pull_request:
    branches: [ master ]
    paths-ignore:
      - 'src/pretix/locale/**'
      - 'src/pretix/static/**'
      - 'src/tests/**'

permissions:
  contents: read  #  to fetch code (actions/checkout)

env:
  FORCE_COLOR: 1

jobs:
  spelling:
    name: Spellcheck
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python 3.13
        uses: actions/setup-python@v5
        with:
          python-version: 3.13
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      - name: Install system packages
        run: sudo apt update && sudo apt install -y enchant-2 hunspell aspell-en
      - name: Install Dependencies
        run: pip3 install -Ur requirements.txt
        working-directory: ./doc
      - name: Spellcheck docs
        run: make spelling
        working-directory: ./doc
      - name:
        run: '[ ! -s _build/spelling/output.txt ]'
        working-directory: ./doc
