Skip to content

Commit c826d8a

Browse files
committed
ci: run one unified Dylint gate on Linux
1 parent caaca5e commit c826d8a

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

‎.github/workflows/_lint.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
runs-on:
1111
required: true
1212
type: string
13+
run-dylint:
14+
required: false
15+
type: boolean
16+
default: false
1317

1418
jobs:
1519
lint:
@@ -77,7 +81,7 @@ jobs:
7781
# Native dylint caching: caches cargo-dylint/dylint-link binaries and
7882
# the dylint driver dir, exposing dylint-cache-hit so we can skip the
7983
# expensive cargo installs below (#170).
80-
dylint-cache: true
84+
dylint-cache: ${{ inputs.run-dylint }}
8185
dylint-toolchain: nightly-2026-05-28
8286
cargo-dylint-version: "6.0.3"
8387
dylint-link-version: "6.0.3"
@@ -86,10 +90,15 @@ jobs:
8690
run: uv sync --group dev
8791

8892
- name: Prepare published Dylint tools
93+
if: inputs.run-dylint
8994
run: env -u RUSTUP_TOOLCHAIN soldr dylint prepare
9095

91-
- name: Lint
96+
- name: Lint with Dylint
97+
if: inputs.run-dylint
9298
run: ./lint
99+
- name: Lint without Dylint
100+
if: ${{ !inputs.run-dylint }}
101+
run: ./lint --skip-dylint
93102

94103
- name: Upload failure logs
95104
if: failure()

‎.github/workflows/linux-x86-lint.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ jobs:
2424
with:
2525
source-sha: ${{ github.event_name == 'workflow_dispatch' && inputs.candidate_sha || github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2626
runs-on: ubuntu-24.04
27+
run-dylint: true

‎lint‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ set -e
33

44
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
55

6+
if [[ $# -gt 1 || ($# -eq 1 && "$1" != "--skip-dylint") ]]; then
7+
echo "Usage: ./lint [--skip-dylint]" >&2
8+
exit 2
9+
fi
10+
SKIP_DYLINT=${1:-}
11+
612
LINT_PATHS=(src tests ci)
713

814
# Python stages run first: they need no Rust toolchain, so a host without
@@ -29,13 +35,15 @@ soldr cargo fmt --all --check
2935
echo Running cargo clippy
3036
soldr cargo clippy --workspace --all-targets -- -D warnings
3137

32-
echo Running ban_std_pathbuf dylint
33-
export SOLDR_FORCE_MANAGED_CARGO_SUBCOMMANDS=1
34-
if ! env -u RUSTUP_TOOLCHAIN soldr dylint prepare; then
35-
echo "Error: dylint prerequisites are missing: soldr dylint prepare failed" >&2
36-
exit 1
38+
if [[ "$SKIP_DYLINT" != "--skip-dylint" ]]; then
39+
echo Running ban_std_pathbuf dylint
40+
export SOLDR_FORCE_MANAGED_CARGO_SUBCOMMANDS=1
41+
if ! env -u RUSTUP_TOOLCHAIN soldr dylint prepare; then
42+
echo "Error: dylint prerequisites are missing: soldr dylint prepare failed" >&2
43+
exit 1
44+
fi
45+
env -u RUSTUP_TOOLCHAIN soldr dylint --all -- --workspace --all-targets
3746
fi
38-
env -u RUSTUP_TOOLCHAIN soldr dylint --all -- --workspace --all-targets
3947

4048
echo Linting complete!
4149
exit 0

‎tests/unit/test_lint_script.py‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _path_entry_has_dylint_or_rustup(entry: str) -> bool:
2929

3030

3131
def _run_lint(
32-
tmp_path: Path, *, ci: bool
32+
tmp_path: Path, *, ci: bool, args: tuple[str, ...] = ()
3333
) -> tuple[subprocess.CompletedProcess[str], list[str]]:
3434
bin_dir = tmp_path / "bin"
3535
bin_dir.mkdir()
@@ -58,7 +58,7 @@ def _run_lint(
5858
env.pop("CI", None)
5959

6060
result = subprocess.run(
61-
["bash", str(REPO_ROOT / "lint")],
61+
["bash", str(REPO_ROOT / "lint"), *args],
6262
cwd=REPO_ROOT,
6363
env=env,
6464
capture_output=True,
@@ -120,6 +120,13 @@ def test_missing_dylint_is_a_hard_failure_in_ci(tmp_path: Path) -> None:
120120
assert _log_has_match(log_lines, r"^uv (run )?pyright src tests ci$")
121121

122122

123+
def test_explicit_skip_keeps_other_lints_but_does_not_run_dylint(tmp_path: Path) -> None:
124+
result, log_lines = _run_lint(tmp_path, ci=True, args=("--skip-dylint",))
125+
assert result.returncode == 0
126+
assert any(line.startswith("soldr cargo clippy") for line in log_lines)
127+
assert not any("dylint" in line for line in log_lines)
128+
129+
123130
def test_python_stages_precede_the_rust_stages(tmp_path: Path) -> None:
124131
_result, log_lines = _run_lint(tmp_path, ci=False)
125132

@@ -144,10 +151,18 @@ def test_python_stages_precede_the_rust_stages(tmp_path: Path) -> None:
144151
"windows-x86-lint.yml",
145152
],
146153
)
147-
def test_native_dylint_runs_on_unlabelled_pr(workflow: str) -> None:
154+
def test_native_lint_without_dylint_runs_on_unlabelled_pr(workflow: str) -> None:
148155
source = (REPO_ROOT / ".github" / "workflows" / workflow).read_text(
149156
encoding="utf-8"
150157
)
151158
assert "pull_request:" in source
152159
assert "uses: ./.github/workflows/_lint.yml" in source
160+
assert "run-dylint: true" not in source
153161
assert "contains(github.event.pull_request.labels.*.name, 'ci-full')" not in source
162+
163+
164+
def test_only_linux_x86_runs_unified_dylint() -> None:
165+
source = (REPO_ROOT / ".github" / "workflows" / "linux-x86-lint.yml").read_text(
166+
encoding="utf-8"
167+
)
168+
assert "run-dylint: true" in source

0 commit comments

Comments
 (0)