Skip to content

🎨 Optimize CI and improve code formatting #31

🎨 Optimize CI and improve code formatting

🎨 Optimize CI and improve code formatting #31

Workflow file for this run

name: Python CI
on:
push:
paths:
- '**.py'
pull_request:
paths:
- '**.py'
jobs:
lint-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8 pytest pytest-cov
pip install -r requirements.txt
- name: Lint with black (specific files only)
run: |
# Only check files added in this PR to avoid failing on existing codebase issues
git fetch origin master
CHANGED_FILES=$(git diff --name-only origin/master...HEAD -- "*.py" | tr '\n' ' ')
if [ -n "$CHANGED_FILES" ]; then
echo "Checking black formatting for: $CHANGED_FILES"
black --check $CHANGED_FILES
else
echo "No Python files changed in this PR"
fi
- name: Lint with flake8 (specific files only)
run: |
# Only check files added in this PR to avoid failing on existing codebase issues
git fetch origin master
CHANGED_FILES=$(git diff --name-only origin/master...HEAD -- "*.py" | tr '\n' ' ')
if [ -n "$CHANGED_FILES" ]; then
echo "Checking flake8 for: $CHANGED_FILES"
flake8 --max-line-length=120 --extend-ignore=E203,W503 $CHANGED_FILES
else
echo "No Python files changed in this PR"
fi
- name: Run tests with coverage
run: pytest --cov=.