Skip to content

Commit

Permalink
Run Unmarked Test pre-commit only if all other hooks pass (#1338)
Browse files Browse the repository at this point in the history
the unmarked test pre-commit hook (at least on my laptop) can take
anywhere from 5-10 seconds to run, so I'd rather it only run if
everything else is passing.
  • Loading branch information
dpanici authored Oct 31, 2024
2 parents 66e43f2 + ccbe4ca commit 56a4db9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,42 @@ repos:
rev: 24.3.0
hooks:
- id: black-jupyter
log_file: devtools/pre-commit.log
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
log_file: devtools/pre-commit.log
- id: check-case-conflict
log_file: devtools/pre-commit.log
- id: check-merge-conflict
log_file: devtools/pre-commit.log
- id: detect-private-key
log_file: devtools/pre-commit.log
- id: end-of-file-fixer
log_file: devtools/pre-commit.log
- id: trailing-whitespace
log_file: devtools/pre-commit.log
- id: no-commit-to-branch
log_file: devtools/pre-commit.log
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
log_file: devtools/pre-commit.log
- repo: https://github.com/PyCQA/flake8
rev: "5.0.4"
hooks:
- id: flake8
additional_dependencies: ["flake8-docstrings", "flake8-eradicate", "flake8-isort"]
log_file: devtools/pre-commit.log
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
log_file: devtools/pre-commit.log
- repo: local
hooks:
- id: check_unmarked_tests
Expand All @@ -37,3 +48,9 @@ repos:
files: ^tests/
types: [python]
pass_filenames: true
- repo: local
hooks:
- id: clean_logfiles
name: clean_logfiles
entry: devtools/clean_logfiles.sh
language: script
5 changes: 5 additions & 0 deletions devtools/check_unmarked_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/sh

if [ -f "devtools/pre-commit.log" ]; then
echo "Error in earlier pre-commit! Skipping unmarked tests check."
exit 1
fi

# Start the timer using date (in seconds since epoch)
start_time=$(date +%s)

Expand Down
6 changes: 6 additions & 0 deletions devtools/clean_logfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

if [ -f "devtools/pre-commit.log" ]; then
echo "deleting devtools/pre-commit.log file..."
rm "devtools/pre-commit.log"
fi

0 comments on commit 56a4db9

Please sign in to comment.