name: Check hyperlinks

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Install uv
        uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
        with:
          activate-environment: true
          python-version: "3.10"
          enable-cache: true

      - name: Install dependencies
        # a newer version of mistune is incompatible with nbconvert
        # pytest>=9 removed the `path` arg from pytest_collect_file; pytest-check-links still uses it
        run: uv pip install "mistune<3.1" "pytest<9" pytest-check-links

      - name: Check links
        run: pytest --check-links README.md tutorials --check-links-ignore "http*"

      - name: Minimize uv cache
        run: uv cache prune --ci
