diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75aefa0a57..43738c92c0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -268,6 +268,9 @@ jobs: needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} timeout-minutes: 20 + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -334,6 +337,9 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') timeout-minutes: 20 + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -370,6 +376,9 @@ jobs: needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} timeout-minutes: 20 + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -431,6 +440,9 @@ jobs: needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} timeout-minutes: 20 + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -500,7 +512,12 @@ jobs: save-if: false - name: "Install Rust toolchain" run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 - name: Build Ruff binary + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only run: cargo build --bin ruff - name: Fuzz run: | @@ -564,6 +581,9 @@ jobs: needs.determine_changes.outputs.formatter == 'true' ) timeout-minutes: 20 + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -697,6 +717,8 @@ jobs: - name: Fuzz env: FORCE_COLOR: 1 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only run: | echo "new commit" git rev-list --format=%s --max-count=1 "$GITHUB_SHA" @@ -741,6 +763,9 @@ jobs: runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }} needs: determine_changes if: ${{ needs.determine_changes.outputs.ty == 'true' || github.ref == 'refs/heads/main' }} + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -878,6 +903,9 @@ jobs: timeout-minutes: 5 needs: determine_changes if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }} + env: + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 env: @@ -896,6 +924,9 @@ jobs: - name: "Install Rust toolchain" run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - name: Build Ruff binary run: cargo build -p ruff --bin ruff diff --git a/.github/workflows/daily_fuzz.yaml b/.github/workflows/daily_fuzz.yaml index 6b385d70b8..ed3f5b8844 100644 --- a/.github/workflows/daily_fuzz.yaml +++ b/.github/workflows/daily_fuzz.yaml @@ -20,6 +20,8 @@ env: CARGO_NET_RETRY: 10 CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only PACKAGE_NAME: ruff FORCE_COLOR: 1 diff --git a/.github/workflows/memory_report.yaml b/.github/workflows/memory_report.yaml index 8973a41c28..899851f5c5 100644 --- a/.github/workflows/memory_report.yaml +++ b/.github/workflows/memory_report.yaml @@ -34,6 +34,8 @@ env: CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 RUST_BACKTRACE: 1 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only PYTHON_VERSION: 3.14 jobs: @@ -59,6 +61,9 @@ jobs: - name: Install Rust toolchain run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - name: Compute memory usage diff shell: bash env: diff --git a/.github/workflows/ty-ecosystem-analyzer.yaml b/.github/workflows/ty-ecosystem-analyzer.yaml index 2cc1dfa438..72d73d3637 100644 --- a/.github/workflows/ty-ecosystem-analyzer.yaml +++ b/.github/workflows/ty-ecosystem-analyzer.yaml @@ -35,6 +35,8 @@ env: CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 RUST_BACKTRACE: 1 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only ECOSYSTEM_ANALYZER_COMMIT: e7576e66e8f992b057ea92c820c04313dceda755 jobs: @@ -60,6 +62,9 @@ jobs: - name: Install Rust toolchain run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - name: Build ty for both commits id: build working-directory: ruff diff --git a/.github/workflows/ty-ecosystem-report.yaml b/.github/workflows/ty-ecosystem-report.yaml index ddc91723f9..72d86daacf 100644 --- a/.github/workflows/ty-ecosystem-report.yaml +++ b/.github/workflows/ty-ecosystem-report.yaml @@ -18,6 +18,8 @@ env: CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 RUST_BACKTRACE: 1 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_PROFILING_DEBUG: line-tables-only jobs: ty-ecosystem-report: @@ -45,6 +47,9 @@ jobs: - name: Install Rust toolchain run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - name: Create report shell: bash run: | diff --git a/.github/workflows/typing_conformance.yaml b/.github/workflows/typing_conformance.yaml index f70bca3a1e..1495c12174 100644 --- a/.github/workflows/typing_conformance.yaml +++ b/.github/workflows/typing_conformance.yaml @@ -34,6 +34,8 @@ env: CARGO_TERM_COLOR: always RUSTUP_MAX_RETRIES: 10 RUST_BACKTRACE: 1 + # Line-tables-only debug info: faster builds, backtraces still work. + CARGO_PROFILE_DEV_DEBUG: line-tables-only CONFORMANCE_SUITE_COMMIT: 5a701a037b5243df1f39622b642893d865f06205 PYTHON_VERSION: 3.12 @@ -67,6 +69,9 @@ jobs: - name: Install Rust toolchain run: rustup show + - name: "Install mold" + uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 + - name: Compute diagnostic diff shell: bash run: | diff --git a/AGENTS.md b/AGENTS.md index 1d9cbbe243..3c6db942f0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,28 +4,28 @@ This repository contains both Ruff (a Python linter and formatter) and ty (a Pyt ## Running Tests -Run all tests (using `nextest` for faster execution, setting `CARGO_PROFILE_DEV_OPT_LEVEL=1` to enable optimizations while retaining debug info, and setting `INSTA_FORCE_PASS=1 INSTA_UPDATE=always` to ensure all snapshots are updated): +Run all tests (using `nextest` for faster execution, setting `CARGO_PROFILE_DEV_OPT_LEVEL=1 CARGO_PROFILE_DEV_DEBUG="line-tables-only"` to enable optimizations while retaining some debug info, and setting `INSTA_FORCE_PASS=1 INSTA_UPDATE=always MDTEST_UPDATE_SNAPSHOTS=1` to ensure all snapshots are updated): ```sh -CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always cargo nextest run +CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always CARGO_PROFILE_DEV_DEBUG="line-tables-only" MDTEST_UPDATE_SNAPSHOTS=1 cargo nextest run ``` Run tests for a specific crate: ```sh -CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always cargo nextest run -p ty_python_semantic +CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always CARGO_PROFILE_DEV_DEBUG="line-tables-only" MDTEST_UPDATE_SNAPSHOTS=1 cargo nextest run -p ty_python_semantic ``` Run a single mdtest file. The path to the mdtest file should be relative to the `crates/ty_python_semantic/resources/mdtest` folder: ```sh -CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always cargo nextest run -p ty_python_semantic -- mdtest:: +CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always CARGO_PROFILE_DEV_DEBUG="line-tables-only" MDTEST_UPDATE_SNAPSHOTS=1 cargo nextest run -p ty_python_semantic -- mdtest:: ``` To run a specific mdtest within a file, use a substring of the Markdown header text as `MDTEST_TEST_FILTER`. Only use this if it's necessary to isolate a single test case: ```sh -MDTEST_TEST_FILTER="" CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always cargo nextest run -p ty_python_semantic -- mdtest:: +MDTEST_TEST_FILTER="" CARGO_PROFILE_DEV_OPT_LEVEL=1 INSTA_FORCE_PASS=1 INSTA_UPDATE=always CARGO_PROFILE_DEV_DEBUG="line-tables-only" MDTEST_UPDATE_SNAPSHOTS=1 cargo nextest run -p ty_python_semantic -- mdtest:: ``` After running the tests, always review the contents of any snapshots that have been added or updated. diff --git a/crates/ty_python_semantic/mdtest.py b/crates/ty_python_semantic/mdtest.py index ee19f559c5..5fe3b7b7ea 100644 --- a/crates/ty_python_semantic/mdtest.py +++ b/crates/ty_python_semantic/mdtest.py @@ -77,6 +77,7 @@ class MDTestRunner: os.environ, CLI_COLOR="1", CARGO_PROFILE_DEV_OPT_LEVEL="0" if self.filters else "1", + CARGO_PROFILE_DEV_DEBUG="line-tables-only", ), stderr=subprocess.STDOUT, text=True,