Skip to content

Commit

Permalink
Merge pull request #56 from berenslab/add-format-check
Browse files Browse the repository at this point in the history
feat: add formatting check & shortcut usage
  • Loading branch information
alex404 authored Oct 30, 2024
2 parents 37d645c + f8a575a commit 8f70f66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/ci/changed_py_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo $(git diff --name-only origin/master...HEAD -- '*.py')
17 changes: 15 additions & 2 deletions tests/ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ shift
if [ "$1" = "--all" ]; then
# Remove --all from arguments
shift

# Check or fix
check="--check"
if [[ "$@" == *"--fix"* ]]; then
check=""
fi

# Format
apptainer exec "$CONTAINER" ruff format "$check" .

# Run ruff on all files with any remaining arguments
apptainer exec "$CONTAINER" ruff check . "$@"
else
Expand All @@ -36,10 +46,13 @@ else
fi

# Get changed Python files
changed_files=$(git diff --name-only origin/master...HEAD -- '*.py')
changed_files=$(tests/ci/changed_py_files.sh)
if [ -n "$changed_files" ]; then
# Format
apptainer exec "$CONTAINER" ruff format "$check" $changed_files

# Run ruff on changed files with any remaining arguments
apptainer exec "$CONTAINER" ruff check $(git diff --name-only origin/master...HEAD -- '*.py') "$@"
apptainer exec "$CONTAINER" ruff check $changed_files "$@"
else
echo "No .py files changed"
fi
Expand Down

0 comments on commit 8f70f66

Please sign in to comment.