Skip to content

Commit 131d8b2

Browse files
chore(ci): single ruff pin via requirements-dev.txt
- Add requirements-dev.txt as the only ruff version pin - CI and scripts reference it; local pre-commit hook runs scripts/lint - Document Python lint setup in README
1 parent 8233b0e commit 131d8b2

6 files changed

Lines changed: 37 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
python-version: "3.11"
3131
- name: Install ruff
32-
run: pip install --no-cache-dir ruff==0.15.5
32+
run: pip install --no-cache-dir -r requirements-dev.txt
3333
- name: Run ruff format check
3434
run: ruff format --check .
3535
- name: Run ruff lint check

.pre-commit-config.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
# Lightweight Python formatting/lint for scenario workloads. Matches the ruff job in ci.yml.
2-
# Local: ./scripts/lint (check) or ./scripts/format (auto-fix)
3-
# Optional hooks (skipped when core.hooksPath is set): pip install pre-commit && pre-commit install
1+
# Optional git hooks for Python scenario files (same checks as CI — see scripts/lint).
2+
# Setup: pip install -r requirements-dev.txt pre-commit && pre-commit install
3+
# On Datadog laptops with global core.hooksPath, use ./scripts/lint instead of pre-commit install.
44
repos:
5-
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.15.5
5+
- repo: local
76
hooks:
87
- id: ruff
9-
args: [--fix]
10-
- id: ruff-format
8+
name: ruff (scripts/lint)
9+
entry: scripts/lint
10+
language: system
11+
types: [python]

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ Checkout #profiling-library-pager to get notified of test failures.
1010
Install go >= 1.25.1: `brew install go`, `choco install go`, etc.
1111
Install docker.
1212

13+
### Python lint (scenario workloads)
14+
15+
CI and local checks use [Ruff](https://docs.astral.sh/ruff/). Install once:
16+
17+
```sh
18+
pip install -r requirements-dev.txt
19+
```
20+
21+
```sh
22+
./scripts/lint # check (matches the ci.yml ruff job)
23+
./scripts/format # auto-fix formatting and lint
24+
```
25+
26+
Optional git hooks (skip on Datadog laptops that use global `core.hooksPath` — run `./scripts/lint` manually instead):
27+
28+
```sh
29+
pip install pre-commit
30+
pre-commit install
31+
```
32+
33+
Ruff version is pinned only in `requirements-dev.txt`.
34+
1335
### Running Tests
1436

1537
```sh

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Python dev tools for repo-wide lint/format (ci.yml, scripts/lint, scripts/format, pre-commit).
2+
ruff==0.15.5

scripts/format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ set -euo pipefail
33

44
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
cd "$root"
6+
dev_requirements="$root/requirements-dev.txt"
67

78
if ! command -v ruff >/dev/null 2>&1; then
8-
echo "ruff not found; install with: pip install ruff==0.15.5" >&2
9+
echo "ruff not found; install with: pip install -r $dev_requirements" >&2
910
exit 1
1011
fi
1112

scripts/lint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ set -euo pipefail
44
# Matches the ruff job in .github/workflows/ci.yml (see also scripts/format).
55
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
66
cd "$root"
7+
dev_requirements="$root/requirements-dev.txt"
78

89
if ! command -v ruff >/dev/null 2>&1; then
9-
echo "ruff not found; install with: pip install ruff==0.15.5" >&2
10+
echo "ruff not found; install with: pip install -r $dev_requirements" >&2
1011
exit 1
1112
fi
1213

0 commit comments

Comments
 (0)