|
| 1 | +name: Code Quality & Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +env: |
| 8 | + PYTHON_VERSION: "3.11" |
| 9 | + |
| 10 | +jobs: |
| 11 | + black: |
| 12 | + name: Black Formatting |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: ${{ env.PYTHON_VERSION }} |
| 20 | + - name: Cache pip |
| 21 | + uses: actions/cache@v4 |
| 22 | + with: |
| 23 | + path: ~/.cache/pip |
| 24 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install -r requirements.txt |
| 29 | + - name: Check formatting with Black |
| 30 | + run: black . --check |
| 31 | + |
| 32 | + isort: |
| 33 | + name: Import Sorting |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + - name: Set up Python |
| 38 | + uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: ${{ env.PYTHON_VERSION }} |
| 41 | + - name: Cache pip |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: ~/.cache/pip |
| 45 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 46 | + - name: Install dependencies |
| 47 | + run: | |
| 48 | + python -m pip install --upgrade pip |
| 49 | + pip install isort |
| 50 | + - name: Sort imports with isort |
| 51 | + run: isort . --check-only --diff |
| 52 | + |
| 53 | + flake8: |
| 54 | + name: Flake8 Linting |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - name: Set up Python |
| 59 | + uses: actions/setup-python@v5 |
| 60 | + with: |
| 61 | + python-version: ${{ env.PYTHON_VERSION }} |
| 62 | + - name: Cache pip |
| 63 | + uses: actions/cache@v4 |
| 64 | + with: |
| 65 | + path: ~/.cache/pip |
| 66 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 67 | + - name: Install dependencies |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + pip install flake8 |
| 71 | + - name: Lint with flake8 |
| 72 | + run: flake8 . |
| 73 | + |
| 74 | + mypy: |
| 75 | + name: MyPy Type Checking |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + - name: Set up Python |
| 80 | + uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: ${{ env.PYTHON_VERSION }} |
| 83 | + - name: Cache pip |
| 84 | + uses: actions/cache@v4 |
| 85 | + with: |
| 86 | + path: ~/.cache/pip |
| 87 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 88 | + - name: Install dependencies |
| 89 | + run: | |
| 90 | + python -m pip install --upgrade pip |
| 91 | + pip install -r requirements.txt |
| 92 | + - name: Type check with mypy |
| 93 | + run: mypy . --check-untyped-defs |
| 94 | + |
| 95 | + tests: |
| 96 | + name: Run Tests |
| 97 | + runs-on: ubuntu-latest |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + - name: Set up Python |
| 101 | + uses: actions/setup-python@v5 |
| 102 | + with: |
| 103 | + python-version: ${{ env.PYTHON_VERSION }} |
| 104 | + - name: Cache pip |
| 105 | + uses: actions/cache@v4 |
| 106 | + with: |
| 107 | + path: ~/.cache/pip |
| 108 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 109 | + - name: Install dependencies |
| 110 | + run: | |
| 111 | + python -m pip install --upgrade pip |
| 112 | + pip install -r requirements.txt |
| 113 | + pip install coverage |
| 114 | + - name: Run tests with coverage |
| 115 | + run: | |
| 116 | + export $(cat .env.dev.example | xargs) |
| 117 | + coverage run -m pytest tests/ -v |
| 118 | + coverage xml |
| 119 | + coverage report |
| 120 | + - name: Upload coverage reports |
| 121 | + uses: codecov/codecov-action@v3 |
0 commit comments