Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,19 @@ slow-timeout = { period = "1s", terminate-after = 60 }

# Show slow jobs in the final summary
final-status-level = "slow"

[profile.ci-short]
# Print out output for failing tests as soon as they fail, and also at the end
# of the run (for easy scrollability).
failure-output = "immediate-final"
# Do not cancel the test run on the first failure.
fail-fast = false

status-level = "pass"

# Mark tests that take longer than 1s as slow.
# Terminate after 60s as a stop-gap measure to terminate on deadlock.
slow-timeout = { period = "1s", terminate-after = 60 }

# Show slow jobs in the final summary
final-status-level = "slow"
89 changes: 89 additions & 0 deletions .github/actions/cache-wsl-distro/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: "Create and cache WSL vhdx"

inputs:
cache_key:
description: "The cache key to use with actions/cache"
required: true
cache_path:
description: "The path to use with actions/cache"
required: true
vhdx_file:
description: "The full path to the vhdx file restored by actions/cache"
required: true
distro:
description: "The distro name to use with wsl --import-in-place and Vampire/setup-wsl"
required: true
ext4_workspace:
description: "The path to the workspace directory on the wsl ext4 filesystem"
required: true

runs:
using: "composite"
steps:
- name: "Install ${{ inputs.distro }} with build-essential & mold"
uses: Vampire/setup-wsl@f40fb59d850112c9a292b0218bca8271305b9127 # v5.0.0
with:
distribution: ${{ inputs.distro }}
use-cache: "false"
additional-packages: build-essential mold
- name: "Validate Installation"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ inputs.distro }}
exec: |
id
uname -a
df -T
- name: "Install Toolchain"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ inputs.distro }}
exec: |
set -ex
export CI=1
echo "::group::Rustup"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "::endgroup::"
echo "::group::Insta"
curl -LsSf https://insta.rs/install.sh | sh
echo "::endgroup::"
echo "::group::Nextest"
source $HOME/.cargo/env
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall cargo-nextest --secure -y
echo "::endgroup::"
- name: "Create dir for ext4 workspace"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ inputs.distro }}
exec: |
mkdir --parents ${{ inputs.ext4_workspace }}
- name: "Export distro for cache"
shell: pwsh
env:
CACHE_PATH: ${{ inputs.cache_path }}
VHDX_FILE: ${{ inputs.vhdx_file }}
run: |
$ErrorActionPreference = 'Stop'
wsl --list
wsl --shutdown
New-Item -ItemType Directory -Path $env:CACHE_PATH -Force
wsl --export --vhd $env:DISTRO $env:VHDX_FILE
- name: "Check vhdx file exists"
id: check
shell: pwsh
env:
VHDX_FILE: ${{ inputs.vhdx_file }}
run: |
$ErrorActionPreference = 'Stop'
if (Test-Path $env:VHDX_FILE) {
exit 0
} else {
Write-Error "File not found: $env:VHDX_FILE"
exit 1
}
- name: "Write cache"
uses: actions/cache/save@v4
with:
path: ${{ inputs.cache_path }}
key: ${{ inputs.cache_key }}
216 changes: 216 additions & 0 deletions .github/workflows/test_flake8_executable_wsl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# This workflow will check flake8_executable lints on:
# - Native Linux
# - WSL, using an ext4 filesystem
# - WSL, using a windows filesystem
#
# This is to ensure that EXE001 & EXE002 are automatically disabled
# where appropriate.
#
# It will run when:
# - this file is changed or
# - any of the flake8_executable code, tests, fixtures, ... are changed.
#
# On first run it will cache the installed WSL distro, as the initial
# installation is time-consuming.

name: Check flake8_executable lints

on:
push:
paths:
[
".github/workflows/test_flake8_executable_wsl.yml",
".github/actions/cache-wsl-distro/action.yml",
"**/flake8_executable/**",
]
workflow_dispatch:

permissions: {}

jobs:
find_wsl_cache:
name: "Check/Create WSL vhdx"
runs-on: windows-latest
timeout-minutes: 15
env:
CACHE_FILE: "ubuntu_ruff.vhdx"
CACHE_DIR: ".wsl_cache"
DISTRO: "Ubuntu-24.04"
EXT4_WORKSPACE: "/workspaces/${{ github.repository }}"
outputs:
cache_key: ${{ steps.calc_vars.outputs.cache_key }}
cache_path: ${{ steps.calc_vars.outputs.cache_path }}
vhdx_file: ${{ steps.calc_vars.outputs.vhdx_file }}
distro: ${{ env.DISTRO }}
ext4_workspace: ${{ env.EXT4_WORKSPACE }}
steps:
# Using version numbers, not SHAs, throughout to avoid dependabot triggering this workflow often
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- id: calc_vars
name: "Calculate paths & key"
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$cachePath = Join-Path ${{ runner.temp }} $env:CACHE_DIR
Write-Output "cache_path=$cachePath"
Write-Output "cache_path=$cachePath" >> $env:GITHUB_OUTPUT
$vhdxPath = Join-Path $cachePath $env:CACHE_FILE
Write-Output "vhdx_file=$vhdxPath"
Write-Output "vhdx_file=$vhdxPath" >> $env:GITHUB_OUTPUT
$workflowHash = (Get-FileHash .github/actions/cache-wsl-distro/action.yml).Hash
Write-Output "cache_key=wsl_distro_cache-$env:DISTRO-$workflowHash"
Write-Output "cache_key=wsl_distro_cache-$env:DISTRO-$workflowHash" >> $env:GITHUB_OUTPUT
- id: check-wsl-cache
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: ${{ steps.calc_vars.outputs.cache_key }}
path: ${{ steps.calc_vars.outputs.cache_path}}
lookup-only: true
- name: "Create and cache distro"
if: ${{ steps.check-wsl-cache.outputs.cache-hit != 'true'}}
uses: ./.github/actions/cache-wsl-distro
with:
cache_key: ${{ steps.calc_vars.outputs.cache_key }}
cache_path: ${{ steps.calc_vars.outputs.cache_path }}
vhdx_file: ${{ steps.calc_vars.outputs.vhdx_file }}
distro: ${{ env.DISTRO }}
ext4_workspace: ${{ env.EXT4_WORKSPACE }}

test_wsl_ntfs:
needs: find_wsl_cache
name: "Run tests on WSL - mounted NTFS filesystem"
runs-on: windows-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: "Get wsl distro from cache"
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: ${{ needs.find_wsl_cache.outputs.cache_key }}
path: ${{ needs.find_wsl_cache.outputs.cache_path }}
fail-on-cache-miss: true
- name: "Import cached Distro"
id: import-wsl
shell: pwsh
env:
VHDX_FILE: ${{ needs.find_wsl_cache.outputs.vhdx_file }}
DISTRO: ${{ needs.find_wsl_cache.outputs.distro }}
run: |
$ErrorActionPreference = 'Stop'
Write-Output "Updating WSL"
wsl --update
Write-Output "Importing $env:VHDX_FILE as $env:DISTRO"
wsl --import-in-place $env:DISTRO $env:VHDX_FILE

# We use this --cd trick otherwise bash gets confused with the \ path separators
$workspacePath = wsl.exe -d $env:DISTRO --cd $env:GITHUB_WORKSPACE -- wslpath -ua .
Write-Output "WSL Path to Workspace: $workspacePath"
Write-Output "workspace_path=$workspacePath" >> $env:GITHUB_OUTPUT
# Using the wsl-native filesystem for storing build artifacts reduces build from 10 mins to 3 mins
- name: "Use wsl-native file system for ./target"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ needs.find_wsl_cache.outputs.distro }}
working-dir: ${{ steps.import-wsl.outputs.workspace_path }}
exec: |
set -ex
mkdir /tmp/target
mkdir target || true
mount --bind /tmp/target target
- name: "Run tests"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ needs.find_wsl_cache.outputs.distro }}
working-dir: ${{ steps.import-wsl.outputs.workspace_path }}
exec: |
set -ex
source $HOME/.cargo/env
export NEXTEST_PROFILE="ci-short"
RUFF_TEST_ENVIRONMENT="ntfs" cargo insta test --check --test-runner nextest --package ruff_linter -- flake8_executable

test_wsl_ext4:
needs: find_wsl_cache
name: "Run tests on WSL Native filesystem"
runs-on: windows-latest
timeout-minutes: 10
steps:
- name: "Get wsl distro from cache"
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: ${{ needs.find_wsl_cache.outputs.cache_key }}
path: ${{ needs.find_wsl_cache.outputs.cache_path }}
fail-on-cache-miss: true
- name: "Import cached Distro"
shell: pwsh
env:
VHDX_FILE: ${{ needs.find_wsl_cache.outputs.vhdx_file }}
DISTRO: ${{ needs.find_wsl_cache.outputs.distro }}
run: |
$ErrorActionPreference = 'Stop'
Write-Output "Updating WSL"
wsl --update
Write-Output "Importing $env:VHDX_FILE as $env:DISTRO"
wsl --import-in-place $env:DISTRO $env:VHDX_FILE
- name: Checkout
uses: ubuntu/WSL/.github/actions/wsl-checkout@0cbf324d47c733b1b5026a07357a9ec15ab11408 # 2023-05-30
with:
distro: ${{ needs.find_wsl_cache.outputs.distro }}
working-dir: ${{ needs.find_wsl_cache.outputs.ext4_workspace }}
- name: "Run tests"
uses: ubuntu/WSL/.github/actions/wsl-bash@dd06b19f5acdd0d085ab539427980e49bb5e8143 # 2024-02-01
with:
distro: ${{ needs.find_wsl_cache.outputs.distro }}
working-dir: ${{ needs.find_wsl_cache.outputs.ext4_workspace }}
exec: |
set -ex
source "$HOME/.cargo/env"
export NEXTEST_PROFILE="ci-short"
cargo insta test --check --test-runner nextest --package ruff_linter -- flake8_executable

test_non_wsl:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: "Test on ${{ matrix.os }}"
timeout-minutes: ${{ matrix.os == 'windows-latest' && 10 || 5 }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
if: runner.os != 'Windows'
# Known performance problems windows - see https://github.com/Swatinem/rust-cache/issues/169
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
if: runner.os == 'Windows'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: "Install Rust toolchain"
run: rustup show
- name: "Install mold"
if: runner.os != 'Windows'
uses: rui314/setup-mold@e16410e7f8d9e167b74ad5697a9089a35126eb50 # v1
- name: "Install cargo nextest"
uses: taiki-e/install-action@90558ad1e179036f31467972b00dec6cb80701fa # v2.66.3
with:
tool: cargo-nextest
- name: "Install cargo insta"
uses: taiki-e/install-action@90558ad1e179036f31467972b00dec6cb80701fa # v2.66.3
with:
tool: cargo-insta
- name: "Run tests"
shell: bash
env:
NEXTEST_PROFILE: "ci-short"
run: cargo insta test --check --test-runner nextest --package ruff_linter -- flake8_executable
20 changes: 0 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ indoc = { version = "2.0.4" }
insta = { version = "1.35.1" }
insta-cmd = { version = "0.6.0" }
is-macro = { version = "0.3.5" }
is-wsl = { version = "0.4.0" }
itertools = { version = "0.14.0" }
jiff = { version = "0.2.0" }
jod-thread = { version = "1.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ globset = { workspace = true }
hashbrown = { workspace = true }
imperative = { workspace = true }
is-macro = { workspace = true }
is-wsl = { workspace = true }
itertools = { workspace = true }
jiff = { workspace = true }
libcst = { workspace = true }
Expand All @@ -64,6 +63,7 @@ similar = { workspace = true }
smallvec = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
toml = { workspace = true }
typed-arena = { workspace = true }
Expand Down
Loading