---
name: PR Quality (soft)
on:
  pull_request:
    types: [opened, synchronize, reopened, labeled, unlabeled, edited]
permissions:
  contents: read
  pull-requests: read
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref || github.ref }}
  cancel-in-progress: true
jobs:
  # All three jobs are `continue-on-error: true` for the first ~2 weeks after
  # this workflow lands, so we can tune the parsers + matrix gates without
  # blocking merges. Flip to hard-fail once the false-positive rate is stable.
  checklist-guard:
    name: PR Submission Checklist
    runs-on: ubuntu-22.04
    container:
      image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
    continue-on-error: true
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'docs') && !contains(github.event.pull_request.labels.*.name, 'chore') }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
        with:
          fetch-depth: 1
      - name: Verify Submission Checklist
        env:
          PR_BODY: ${{ github.event.pull_request.body }}
        run: node scripts/check-pr-checklist.mjs
  coverage-matrix:
    name: Coverage Matrix Sync
    runs-on: ubuntu-22.04
    container:
      image: ghcr.io/tinyhumansai/openhuman_ci:rust-1.93.0
    continue-on-error: true
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'docs') && !contains(github.event.pull_request.labels.*.name, 'chore') }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
        with:
          fetch-depth: 1
      - name: Verify Coverage Matrix
        run: node scripts/check-coverage-matrix.mjs
  markdown-link-check:
    name: Markdown Link Check
    runs-on: ubuntu-latest
    continue-on-error: true
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'docs') && !contains(github.event.pull_request.labels.*.name, 'chore') }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v5
        with:
          fetch-depth: 1
      - name: Lychee link check
        uses: lycheeverse/lychee-action@v2
        with:
          args: >-
            --no-progress
            --include-fragments
            --exclude '^http://localhost'
            --exclude '^https?://127\.0\.0\.1'
            --exclude 'docs/install\.md#apt-debianubuntu$'
            --exclude '^https://github\.com/tinyhumansai/homebrew-openhuman'
            'docs/**/*.md'
            'src/**/README.md'
            '.github/PULL_REQUEST_TEMPLATE.md'
          fail: true
