Skip to content

Commit 11fa554

Browse files
authored
add pre-commit (#741)
Proposes adding a small `pre-commit` configuration to the repo, and a new CI job that runs it. Motivated by noticing an unused import in this Python code: https://github.com/rapidsai/integration/blob/172ef624ea50670969e1fd79930a46eabdd9c3c9/ci/check_conda_nightly_env.py#L3 I think this will be helpful to catch the types of things that static analyzers are good at catching. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: #741
1 parent 172ef62 commit 11fa554

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/pr.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ jobs:
1616
- test-conda-nightly-env
1717
secrets: inherit
1818
uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02
19+
checks:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
- uses: pre-commit/action@v3.0.1
1926
build:
27+
needs: checks
2028
secrets: inherit
2129
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02
2230
with:
2331
build_type: pull-request
2432
test-conda-nightly-env:
33+
needs: checks
2534
secrets: inherit
2635
# We use a build workflow so that we get CPU jobs and high matrix coverage
2736
uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02

.pre-commit-config.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: check-added-large-files
10+
- id: end-of-file-fixer
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.9.3
13+
hooks:
14+
- id: ruff
15+
args: ["--fix"]
16+
- id: ruff-format
17+
- repo: https://github.com/rapidsai/pre-commit-hooks
18+
rev: v0.5.0
19+
hooks:
20+
- id: verify-copyright

ci/check_conda_nightly_env.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
12
import json
23
import re
3-
import subprocess
44
import sys
55
from datetime import datetime, timedelta
66

@@ -139,7 +139,7 @@ def check_env(json_path):
139139

140140
if __name__ == "__main__":
141141
if len(sys.argv) != 2:
142-
print("Provide only one argument, the filepath to a JSON output from " "conda.")
142+
print("Provide only one argument, the filepath to a JSON output from conda.")
143143
sys.exit(1)
144144

145145
sys.exit(check_env(sys.argv[1]))

0 commit comments

Comments
 (0)