---
name: Mypy Stubtest
on: [pull_request]

permissions:
  contents: read

jobs:
  mypy-stubtest:
    name: mypy-stubtest
    runs-on: ubuntu-latest
    permissions:
      checks: write
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4.2.2
        with:
          persist-credentials: false

      - name: Set up Python 3
        uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b  # v5.3.0
        with:
          python-version: '3.10'

      - name: Set up reviewdog
        uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887  # v1.3.9

      - name: Install tox
        run: python -m pip install tox

      - name: Run mypy stubtest
        env:
          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          set -o pipefail
          tox -e stubtest | \
              sed -e "s!.tox/stubtest/lib/python3.10/site-packages!lib!g" | \
              reviewdog \
                -efm '%Eerror: %m' \
                -efm '%CStub: in file %f:%l' \
                -efm '%CStub: in file %f' \
                -efm '%+CRuntime:%.%#' \
                -efm '%+CMISSING' \
                -efm '%+Cdef %.%#' \
                -efm '%+C<%.%#>' \
                -efm '%Z' \
                -reporter=github-check -tee -name=mypy-stubtest \
                -filter-mode=nofilter
