| 1 | name: style_check |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - main # Or whichever branch you want to trigger this on |
| 7 | pull_request: |
| 8 | branches: |
| 9 | - main # Or whichever branch you want to trigger this on |
| 10 | |
| 11 | jobs: |
| 12 | style_check: |
| 13 | runs-on: ubuntu-latest |
| 14 | |
| 15 | steps: |
| 16 | - name: Checkout code |
| 17 | uses: actions/checkout@v2 |
| 18 | |
| 19 | - name: Set up Python |
| 20 | uses: actions/setup-python@v2 |
| 21 | with: |
| 22 | python-version: '3.11' # Replace '3.x' with the Python version you're using |
| 23 | cache: 'pip' |
| 24 | |
| 25 | - name: Install checkers |
| 26 | run: | |
| 27 | python -m pip install --upgrade pip |
| 28 | pip install -r requirements-dev.txt |
| 29 | |
| 30 | - name: pyupgrade |
| 31 | run: | |
| 32 | output=$(pyupgrade --py311-plus app/**/*.py) |
| 33 | if [ -n "$output" ]; then |
| 34 | exit 1 |
| 35 | fi |
| 36 | if: '!cancelled()' |
| 37 | |
| 38 | - name: ruff |
| 39 | run: ruff check --fix app |
| 40 | if: '!cancelled()' |
| 41 | |
| 42 | - name: isort |
| 43 | run: | |
| 44 | output=$(isort --profile black app) |
| 45 | if [ -n "$output" ]; then |
| 46 | exit 1 |
| 47 | fi |
| 48 | if: '!cancelled()' |
| 49 | |
| 50 | - name: black |
| 51 | run: black --check app |
| 52 | if: '!cancelled()' |
| 53 | |