Refactoring from pool to populator #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: python-code-quality | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| code-quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5.0.0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.12.11' | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4.2.4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install black isort flake | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black==24.4.2 isort==5.13.2 flake8==7.0.0 | |
| - name: Check for trailing whitespace | |
| run: | | |
| # Check for trailing whitespace in all files | |
| if grep -r --include="*.py" --include="*.yml" --include="*.yaml" --include="*.json" --include="*.md" --include="*.txt" '[[:space:]]$' .; then | |
| echo "Found trailing whitespace in the above files" | |
| exit 1 | |
| fi | |
| - name: Check end of file newlines | |
| run: | | |
| # Check that files end with a newline | |
| find . -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.md" | while read file; do | |
| if [ -n "$(tail -c1 "$file")" ]; then | |
| echo "File $file does not end with a newline" | |
| exit 1 | |
| fi | |
| done | |
| - name: Check for large files | |
| run: | | |
| # Check for files larger than 600KB | |
| find . -type f -size +600k | grep -v '.git/' | while read file; do | |
| echo "Large file found: $file" | |
| done | |
| if find . -type f -size +600k | grep -v '.git/' | grep -q .; then | |
| echo "Large files found. Consider using Git LFS or removing them." | |
| exit 1 | |
| fi | |
| - name: Run Black (code formatting check) | |
| run: | | |
| black --check --diff . | |
| - name: Run isort (import sorting check) | |
| run: | | |
| isort --profile black --check-only --diff . | |
| - name: Run flake8 (linting) | |
| run: | | |
| flake8 --max-line-length=88 --extend-ignore=E203,W503 . | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "Code quality checks completed!" | |
| echo "If any checks failed, please run the following locally to fix issues:" | |
| echo " black ." | |
| echo " isort --profile black ." | |
| echo " flake8 --max-line-length=88 --extend-ignore=E203,W503 ." |