name: mypy

on:
  pull_request:
  push:
    branches: [main]

jobs:
  mypy:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -leo pipefail {0}
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2.0.7
        with:
          micromamba-version: "1.5.10-0" # until https://github.com/mamba-org/setup-micromamba/issues/225 is resolved
          environment-file: environment.yml
          init-shell: bash
          cache-environment: true
          post-cleanup: "all"
      - name: Install pytensor and mypy dependencies
        run: |
          pip install -e .
          python --version
        shell: micromamba-shell {0}
      - name: Run mypy
        run: |
          python ./scripts/run_mypy.py --verbose
        shell: micromamba-shell {0}
