Skip to content

Commit

Permalink
add pre-commit (#741)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jameslamb authored Jan 27, 2025
1 parent 172ef62 commit 11fa554
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ jobs:
- test-conda-nightly-env
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: pre-commit/[email protected]
build:
needs: checks
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
test-conda-nightly-env:
needs: checks
secrets: inherit
# We use a build workflow so that we get CPU jobs and high matrix coverage
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# Copyright (c) 2025, NVIDIA CORPORATION.

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.3
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/rapidsai/pre-commit-hooks
rev: v0.5.0
hooks:
- id: verify-copyright
4 changes: 2 additions & 2 deletions ci/check_conda_nightly_env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
import json
import re
import subprocess
import sys
from datetime import datetime, timedelta

Expand Down Expand Up @@ -139,7 +139,7 @@ def check_env(json_path):

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

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

0 comments on commit 11fa554

Please sign in to comment.