|
| 1 | +name: Run typing conformance |
| 2 | + |
| 3 | +permissions: {} |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + paths: |
| 8 | + - "crates/ty*/**" |
| 9 | + - "crates/ruff_db" |
| 10 | + - "crates/ruff_python_ast" |
| 11 | + - "crates/ruff_python_parser" |
| 12 | + - ".github/workflows/typing_conformance.yaml" |
| 13 | + - ".github/workflows/typing_conformance_comment.yaml" |
| 14 | + - "Cargo.lock" |
| 15 | + - "!**.md" |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +env: |
| 22 | + CARGO_INCREMENTAL: 0 |
| 23 | + CARGO_NET_RETRY: 10 |
| 24 | + CARGO_TERM_COLOR: always |
| 25 | + RUSTUP_MAX_RETRIES: 10 |
| 26 | + RUST_BACKTRACE: 1 |
| 27 | + |
| 28 | +jobs: |
| 29 | + typing_conformance: |
| 30 | + name: Compute diagnostic diff |
| 31 | + runs-on: depot-ubuntu-22.04-32 |
| 32 | + timeout-minutes: 10 |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 35 | + with: |
| 36 | + path: ruff |
| 37 | + fetch-depth: 0 |
| 38 | + persist-credentials: false |
| 39 | + |
| 40 | + - name: Install the latest version of uv |
| 41 | + uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1 |
| 42 | + |
| 43 | + - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0 |
| 44 | + with: |
| 45 | + workspaces: "ruff" |
| 46 | + |
| 47 | + - name: Install Rust toolchain |
| 48 | + run: rustup show |
| 49 | + |
| 50 | + - name: Compute diagnostic diff |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + cd ruff |
| 54 | +
|
| 55 | + echo "new commit" |
| 56 | + git checkout -b new_commit "${{ github.event.pull_request.head.sha }}" |
| 57 | + git rev-list --format=%s --max-count=1 new_commit |
| 58 | + cargo build --release --bin ty |
| 59 | + mv target/release/ty ty-new |
| 60 | +
|
| 61 | + echo "old commit (merge base)" |
| 62 | + MERGE_BASE="$(git merge-base "${{ github.event.pull_request.head.sha }}" "origin/${{ github.event.pull_request.base.ref }}")" |
| 63 | + git checkout -b old_commit "$MERGE_BASE" |
| 64 | + git rev-list --format=%s --max-count=1 old_commit |
| 65 | + cargo build --release --bin ty |
| 66 | + mv target/release/ty ty-old |
| 67 | +
|
| 68 | + cd .. |
| 69 | +
|
| 70 | + git clone https://github.com/python/typing.git |
| 71 | + cd typing |
| 72 | + git checkout d4f39b27a4a47aac8b6d4019e1b0b5b3156fabdc |
| 73 | +
|
| 74 | + echo "Running ty on old commit (merge base)" |
| 75 | + cd conformance/tests |
| 76 | + ../../../ruff/ty-old check --color=never --output-format=concise . > ../../../old-output.txt 2>&1 || true |
| 77 | +
|
| 78 | + echo "Running ty on new commit" |
| 79 | + ../../../ruff/ty-new check --color=never --output-format=concise . > ../../../new-output.txt 2>&1 || true |
| 80 | +
|
| 81 | + cd ../../.. |
| 82 | +
|
| 83 | + if ! diff -u old-output.txt new-output.txt > typing_conformance_diagnostics.diff; then |
| 84 | + echo "Differences found between base and PR" |
| 85 | + else |
| 86 | + echo "No differences found" |
| 87 | + touch typing_conformance_diagnostics.diff |
| 88 | + fi |
| 89 | +
|
| 90 | + echo ${{ github.event.number }} > pr-number |
| 91 | +
|
| 92 | + - name: Upload diff |
| 93 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 94 | + with: |
| 95 | + name: typing_conformance_diagnostics_diff |
| 96 | + path: typing_conformance_diagnostics.diff |
| 97 | + |
| 98 | + - name: Upload pr-number |
| 99 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 100 | + with: |
| 101 | + name: pr-number |
| 102 | + path: pr-number |
0 commit comments