diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cab62cd9d64f6..600496f4a6d39 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -211,22 +211,41 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + + - name: Setup Dev Drive + run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1 + + # actions/checkout does not let us clone into anywhere outside `github.workspace`, so we have to copy the clone + # the fuzz corpus links are broken so we remove them + - name: Copy Git Repo to Dev Drive + run: | + Remove-Item -Path ".\fuzz\corpus" -Recurse + Copy-Item -Path "${{ github.workspace }}" -Destination "${{ env.RUFF_WORKSPACE }}" -Recurse + - uses: Swatinem/rust-cache@v2 + with: + workspaces: ${{ env.RUFF_WORKSPACE }} + - name: "Install Rust toolchain" + working-directory: ${{ env.RUFF_WORKSPACE }} run: rustup show + - name: "Install cargo nextest" uses: taiki-e/install-action@v2 with: tool: cargo-nextest - name: "Run tests" + working-directory: ${{ env.RUFF_WORKSPACE }} shell: bash env: NEXTEST_PROFILE: "ci" # Workaround for . RUSTUP_WINDOWS_PATH_ADD_BIN: 1 + RED_KNOT_LOG: debug + RUST_LOG: debug run: | - cargo nextest run --all-features --profile ci - cargo test --all-features --doc + cargo nextest run --all-features --profile ci -- directory_deleted + # cargo test --all-features --doc cargo-test-wasm: name: "cargo test (wasm)" diff --git a/.github/workflows/setup-dev-drive.ps1 b/.github/workflows/setup-dev-drive.ps1 new file mode 100644 index 0000000000000..244093d844260 --- /dev/null +++ b/.github/workflows/setup-dev-drive.ps1 @@ -0,0 +1,62 @@ +# Configures a drive for testing in CI. + +# When not using a GitHub Actions "larger runner", the `D:` drive is present and +# has similar or better performance characteristics than a ReFS dev drive. +# Sometimes using a larger runner is still more performant (e.g., when running +# the test suite) and we need to create a dev drive. This script automatically +# configures the appropriate drive. + +# Note we use `Get-PSDrive` is not sufficient because the drive letter is assigned. +if (Test-Path "D:\") { + Write-Output "Using existing drive at D:" + $Drive = "D:" +} else { + # The size (20 GB) is chosen empirically to be large enough for our + # workflows; larger drives can take longer to set up. + $Volume = New-VHD -Path C:/ruff_dev_drive.vhdx -SizeBytes 20GB | + Mount-VHD -Passthru | + Initialize-Disk -Passthru | + New-Partition -AssignDriveLetter -UseMaximumSize | + Format-Volume -DevDrive -Confirm:$false -Force + + $Drive = "$($Volume.DriveLetter):" + + # Set the drive as trusted + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-designate-a-dev-drive-as-trusted + fsutil devdrv trust $Drive + + # Disable antivirus filtering on dev drives + # See https://learn.microsoft.com/en-us/windows/dev-drive/#how-do-i-configure-additional-filters-on-dev-drive + fsutil devdrv enable /disallowAv + + # Remount so the changes take effect + Dismount-VHD -Path C:/ruff_dev_drive.vhdx + Mount-VHD -Path C:/ruff_dev_drive.vhdx + + # Show some debug information + Write-Output $Volume + fsutil devdrv query $Drive + + Write-Output "Using Dev Drive at $Volume" +} + +$Tmp = "$($Drive)\ruff-tmp" + +# Create the directory ahead of time in an attempt to avoid race-conditions +New-Item $Tmp -ItemType Directory + +# Move Cargo to the dev drive +New-Item -Path "$($Drive)/.cargo/bin" -ItemType Directory -Force +Copy-Item -Path "C:/Users/runneradmin/.cargo/*" -Destination "$($Drive)/.cargo/" -Recurse -Force + +Write-Output ` + "DEV_DRIVE=$($Drive)" ` + "TMP=$($Tmp)" ` + "TEMP=$($Tmp)" ` + "UV_INTERNAL__TEST_DIR=$($Tmp)" ` + "RUSTUP_HOME=$($Drive)/.rustup" ` + "CARGO_HOME=$($Drive)/.cargo" ` + "RUFF_WORKSPACE=$($Drive)/ruff" ` + "PATH=$($Drive)/.cargo/bin;$env:PATH" ` + >> $env:GITHUB_ENV + diff --git a/crates/red_knot/tests/file_watching.rs b/crates/red_knot/tests/file_watching.rs index 49788e9785d87..5e39ac1161920 100644 --- a/crates/red_knot/tests/file_watching.rs +++ b/crates/red_knot/tests/file_watching.rs @@ -741,6 +741,9 @@ fn directory_renamed() -> anyhow::Result<()> { #[test] fn directory_deleted() -> anyhow::Result<()> { + use ruff_db::testing::setup_logging; + let _logging = setup_logging(); + let mut case = setup([ ("bar.py", "import sub.a"), ("sub/__init__.py", ""),