# This workflow runs mypy_primer, a tool that runs pyright on a variety # of open-source Python projects that are known to type check with pyright. # It builds pyright from the latest commit and the last release tag and # compares the output of both. It uploads the diffs as an artifact. name: Run mypy_primer on push env: NODE_VERSION: '22.x' # Shipped with VS Code. on: # Run on all pushes to main. push: branches: - main paths: - 'packages/pyright/**' - 'packages/pyright-internal/src/**' - 'packages/pyright-internal/typeshed-fallback/**' # Also run manually if requested. workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: mypy_primer: name: Run mypy_primer on push runs-on: ubuntu-latest permissions: contents: read strategy: fail-fast: false steps: - uses: actions/checkout@v4 with: path: pyright_to_test fetch-depth: 0 - uses: actions/setup-python@v5 with: python-version: '3.11' - uses: actions/setup-node@v6 with: node-version: ${{ env.NODE_VERSION }} cache: 'npm' cache-dependency-path: 'pyright_to_test/**/package-lock.json' - name: Install dependencies run: | python -m pip install -U pip pip install git+https://github.com/hauntsaninja/mypy_primer.git - name: Run mypy_primer shell: bash env: # mypy_primer installs both the new and old commits. The old commit can contain # historical peer dependency conflicts that should not block primer comparisons. NPM_CONFIG_LEGACY_PEER_DEPS: 'true' run: | cd pyright_to_test echo "new commit" git rev-list --format=%s --max-count=1 $GITHUB_SHA cd .. npm config set legacy-peer-deps true --location=user npm config get legacy-peer-deps # fail action if exit code isn't zero or one ( mypy_primer \ --repo pyright_to_test \ --type-checker pyright \ --new $GITHUB_SHA \ --debug \ --output concise \ | tee diff.txt ) || [ $? -eq 1 ] - name: Upload mypy_primer diff uses: actions/upload-artifact@v4 with: name: mypy_primer_diffs path: diff.txt