|
| 1 | +# This is the name of the workflow, it appears in the GitHub Actions tab |
| 2 | +name: Code Quality |
| 3 | + |
| 4 | +# The name for workflow runs generated from this workflow |
| 5 | +run-name: Code Quality Run on ${{ github.ref }} by @${{ github.actor }} |
| 6 | + |
| 7 | +# This specifies the events that will trigger the workflow to run |
| 8 | +on: [push, pull_request] |
| 9 | + |
| 10 | +# Jobs define the actual tasks that the workflow will execute |
| 11 | +jobs: |
| 12 | + code_quality_check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + # Setup Python environment |
| 18 | + - name: Setup Python |
| 19 | + uses: actions/setup-python@v5 |
| 20 | + with: |
| 21 | + python-version: '3.12' |
| 22 | + |
| 23 | + - name: Install Poetry |
| 24 | + run: | |
| 25 | + curl -sSL https://install.python-poetry.org | python3 - |
| 26 | +
|
| 27 | + - name: Generate requirements.txt from Poetry |
| 28 | + run: | |
| 29 | + poetry export -f requirements.txt --output requirements.txt --without-hashes |
| 30 | +
|
| 31 | + # Install Python dependencies |
| 32 | + - name: Install Dependencies |
| 33 | + run: | |
| 34 | + python -m pip install --upgrade pip |
| 35 | + pip install -r requirements.txt |
| 36 | +
|
| 37 | + - name: Diagnose isort Configuration |
| 38 | + run: | |
| 39 | + isort . --verbose |
| 40 | + isort --show-config |
| 41 | + isort app/crud/specification.py --diff |
| 42 | + isort --version |
| 43 | +
|
| 44 | + # Check code formatting using isort |
| 45 | + - name: Run isort |
| 46 | + uses: isort/isort-action@v1 |
| 47 | + |
| 48 | + - name: Auto-format Python code with Black |
| 49 | + run: | |
| 50 | + black . |
| 51 | +
|
| 52 | + # Check code formatting using Black |
| 53 | + - name: Run Black |
| 54 | + uses: psf/black@stable |
| 55 | + with: |
| 56 | + options: "--check --verbose" |
| 57 | + |
| 58 | + # Use Ruff to run additional quality checks |
| 59 | + - name: Run Ruff |
| 60 | + uses: chartboost/ruff-action@v1 |
| 61 | + with: |
| 62 | + args: --fix |
| 63 | + |
| 64 | + - name: Run MyPy |
| 65 | + run: | |
| 66 | + mypy --config-file=pyproject.toml --pretty . |
0 commit comments