|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + cache: 'pip' |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: | |
| 28 | + python -m pip install --upgrade pip |
| 29 | + pip install -r requirements.txt |
| 30 | + pip install -r requirements-dev.txt |
| 31 | +
|
| 32 | + - name: Run tests with pytest |
| 33 | + run: | |
| 34 | + pytest --cov=abstra_json_sql --cov-report=xml --cov-report=term -v |
| 35 | +
|
| 36 | + - name: Upload coverage to Codecov |
| 37 | + uses: codecov/codecov-action@v4 |
| 38 | + if: matrix.python-version == '3.12' |
| 39 | + with: |
| 40 | + file: ./coverage.xml |
| 41 | + flags: unittests |
| 42 | + name: codecov-umbrella |
| 43 | + fail_ci_if_error: false |
| 44 | + |
| 45 | + lint: |
| 46 | + name: Lint (Ruff) |
| 47 | + runs-on: ubuntu-latest |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: "3.12" |
| 56 | + cache: 'pip' |
| 57 | + |
| 58 | + - name: Install ruff |
| 59 | + run: | |
| 60 | + python -m pip install --upgrade pip |
| 61 | + pip install ruff |
| 62 | +
|
| 63 | + - name: Run ruff check |
| 64 | + run: ruff check . |
| 65 | + |
| 66 | + - name: Run ruff format check |
| 67 | + run: ruff format --check . |
| 68 | + |
| 69 | + typecheck: |
| 70 | + name: Type Check (Pyright) |
| 71 | + runs-on: ubuntu-latest |
| 72 | + |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Set up Python |
| 77 | + uses: actions/setup-python@v5 |
| 78 | + with: |
| 79 | + python-version: "3.12" |
| 80 | + cache: 'pip' |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: | |
| 84 | + python -m pip install --upgrade pip |
| 85 | + pip install -r requirements.txt |
| 86 | + pip install pyright |
| 87 | +
|
| 88 | + - name: Run pyright |
| 89 | + run: pyright abstra_json_sql |
| 90 | + |
| 91 | + all-checks-passed: |
| 92 | + name: All Checks Passed |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: [test, lint, typecheck] |
| 95 | + if: always() |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Check all jobs |
| 99 | + run: | |
| 100 | + if [ "${{ needs.test.result }}" != "success" ] || \ |
| 101 | + [ "${{ needs.lint.result }}" != "success" ] || \ |
| 102 | + [ "${{ needs.typecheck.result }}" != "success" ]; then |
| 103 | + echo "One or more checks failed" |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + echo "All checks passed successfully!" |
0 commit comments