166 lines
5.3 KiB
YAML
166 lines
5.3 KiB
YAML
name: Run mypy_primer
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- "crates/ty*/**"
|
|
- "!crates/ty_ide/**"
|
|
- "!crates/ty_server/**"
|
|
- "!crates/ty_test/**"
|
|
- "!crates/ty_completion_eval/**"
|
|
- "!crates/ty_wasm/**"
|
|
- "crates/ruff_db"
|
|
- "crates/ruff_python_ast"
|
|
- "crates/ruff_python_parser"
|
|
- ".github/workflows/mypy_primer.yaml"
|
|
- ".github/workflows/mypy_primer_comment.yaml"
|
|
- "scripts/mypy_primer.sh"
|
|
- "Cargo.lock"
|
|
- "!**.md"
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_NET_RETRY: 10
|
|
CARGO_TERM_COLOR: always
|
|
RUSTUP_MAX_RETRIES: 10
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
mypy_primer:
|
|
name: Run mypy_primer
|
|
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
path: ruff
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Install the latest version of uv
|
|
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
|
|
|
|
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
|
with:
|
|
shared-key: "mypy-primer"
|
|
workspaces: "ruff"
|
|
|
|
- name: Install Rust toolchain
|
|
run: rustup show
|
|
|
|
- name: Run mypy_primer
|
|
env:
|
|
PRIMER_SELECTOR: crates/ty_python_semantic/resources/primer/good.txt
|
|
CLICOLOR_FORCE: "1"
|
|
DIFF_FILE: mypy_primer.diff
|
|
run: |
|
|
cd ruff
|
|
scripts/mypy_primer.sh
|
|
|
|
# NOTE: astral-sh-bot uses this artifact to post comments on PRs.
|
|
# Make sure to update the bot if you rename the artifact.
|
|
- name: Upload diff
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: mypy_primer_diff
|
|
path: mypy_primer.diff
|
|
|
|
memory_usage:
|
|
name: Run memory statistics
|
|
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
path: ruff
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Install the latest version of uv
|
|
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
|
|
|
|
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
|
with:
|
|
workspaces: "ruff"
|
|
shared-key: "mypy-primer"
|
|
|
|
- name: Install Rust toolchain
|
|
run: rustup show
|
|
|
|
- name: Run mypy_primer
|
|
env:
|
|
TY_MAX_PARALLELISM: 1 # for deterministic memory numbers
|
|
TY_MEMORY_REPORT: mypy_primer
|
|
PRIMER_SELECTOR: crates/ty_python_semantic/resources/primer/memory.txt
|
|
DIFF_FILE: mypy_primer_memory.diff
|
|
run: |
|
|
cd ruff
|
|
scripts/mypy_primer.sh
|
|
|
|
- name: Upload diff
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
|
with:
|
|
name: mypy_primer_memory_diff
|
|
path: mypy_primer_memory.diff
|
|
|
|
# Runs mypy twice against the same ty version to catch any non-deterministic behavior (ideally).
|
|
# The job is disabled for now because there are some non-deterministic diagnostics.
|
|
mypy_primer_same_revision:
|
|
name: Run mypy_primer on same revision
|
|
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-32' || 'ubuntu-latest' }}
|
|
timeout-minutes: 20
|
|
# TODO: Enable once we fixed the non-deterministic diagnostics
|
|
if: false
|
|
steps:
|
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
path: ruff
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Install the latest version of uv
|
|
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
|
|
|
|
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
|
|
with:
|
|
workspaces: "ruff"
|
|
shared-key: "mypy-primer"
|
|
|
|
- name: Install Rust toolchain
|
|
run: rustup show
|
|
|
|
- name: Run determinism check
|
|
env:
|
|
BASE_REVISION: ${{ github.event.pull_request.head.sha }}
|
|
PRIMER_SELECTOR: crates/ty_python_semantic/resources/primer/good.txt
|
|
CLICOLOR_FORCE: "1"
|
|
DIFF_FILE: mypy_primer_determinism.diff
|
|
run: |
|
|
cd ruff
|
|
scripts/mypy_primer.sh
|
|
|
|
- name: Check for non-determinism
|
|
run: |
|
|
# Remove ANSI color codes for checking
|
|
sed -e 's/\x1b\[[0-9;]*m//g' mypy_primer_determinism.diff > mypy_primer_determinism_clean.diff
|
|
|
|
# Check if there are any differences (non-determinism)
|
|
if [ -s mypy_primer_determinism_clean.diff ]; then
|
|
echo "ERROR: Non-deterministic output detected!"
|
|
echo "The following differences were found when running ty twice on the same commit:"
|
|
cat mypy_primer_determinism_clean.diff
|
|
exit 1
|
|
else
|
|
echo "✓ Output is deterministic"
|
|
fi
|