|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Set up Python |
| 16 | + uses: actions/setup-python@v5 |
| 17 | + with: |
| 18 | + python-version: "3.11" |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade pip |
| 23 | + pip install -e ".[dev]" |
| 24 | +
|
| 25 | + - name: Check proto files are up-to-date |
| 26 | + run: | |
| 27 | + python scripts/compile_protos.py |
| 28 | + if ! git diff --exit-code src/altertable_flightsql/generated/; then |
| 29 | + echo "❌ Error: Generated proto files are out of date!" |
| 30 | + echo "Please run 'python scripts/compile_protos.py' and commit the changes." |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | + echo "✅ Generated proto files are up to date." |
| 34 | +
|
| 35 | + - name: Lint with ruff |
| 36 | + run: | |
| 37 | + ruff check src/ tests/ scripts/ examples/ |
| 38 | +
|
| 39 | + - name: Check formatting with black |
| 40 | + run: | |
| 41 | + black --check src/ tests/ scripts/ examples/ |
| 42 | +
|
| 43 | + - name: Check import sorting with isort |
| 44 | + run: | |
| 45 | + isort --check-only src/ tests/ scripts/ examples/ |
| 46 | +
|
| 47 | + test: |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + permissions: |
| 50 | + contents: read |
| 51 | + packages: read |
| 52 | + strategy: |
| 53 | + fail-fast: false |
| 54 | + matrix: |
| 55 | + os: [ubuntu-latest] |
| 56 | + python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 57 | + |
| 58 | + services: |
| 59 | + altertable: |
| 60 | + image: ghcr.io/altertable-ai/altertable-mock:latest |
| 61 | + credentials: |
| 62 | + username: ${{ github.actor }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + ports: |
| 65 | + - 15002:15002 |
| 66 | + env: |
| 67 | + ALTERTABLE_MOCK_USERS: altertable-test:lk_test |
| 68 | + ALTERTABLE_MOCK_FLIGHT_PORT: 15002 |
| 69 | + options: >- |
| 70 | + --health-cmd "exit 0" |
| 71 | + --health-interval 5s |
| 72 | + --health-timeout 3s |
| 73 | + --health-retries 3 |
| 74 | + --health-start-period 10s |
| 75 | +
|
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Set up Python ${{ matrix.python-version }} |
| 80 | + uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: ${{ matrix.python-version }} |
| 83 | + |
| 84 | + - name: Install dependencies |
| 85 | + run: | |
| 86 | + python -m pip install --upgrade pip |
| 87 | + pip install -e ".[dev]" |
| 88 | +
|
| 89 | + - name: Run integration tests |
| 90 | + env: |
| 91 | + ALTERTABLE_HOST: localhost |
| 92 | + ALTERTABLE_PORT: 15002 |
| 93 | + ALTERTABLE_USERNAME: altertable-test |
| 94 | + ALTERTABLE_PASSWORD: lk_test |
| 95 | + ALTERTABLE_TLS: false |
| 96 | + run: | |
| 97 | + pytest tests/ --no-cov -v |
| 98 | +
|
| 99 | + - name: Run client usage examples |
| 100 | + env: |
| 101 | + ALTERTABLE_HOST: localhost |
| 102 | + ALTERTABLE_PORT: 15002 |
| 103 | + ALTERTABLE_USERNAME: altertable-test |
| 104 | + ALTERTABLE_PASSWORD: lk_test |
| 105 | + ALTERTABLE_TLS: false |
| 106 | + run: | |
| 107 | + python examples/client_usage.py |
| 108 | +
|
| 109 | + build: |
| 110 | + runs-on: ubuntu-latest |
| 111 | + needs: [lint, test] |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Set up Python |
| 116 | + uses: actions/setup-python@v5 |
| 117 | + with: |
| 118 | + python-version: "3.11" |
| 119 | + |
| 120 | + - name: Install build dependencies |
| 121 | + run: | |
| 122 | + python -m pip install --upgrade pip |
| 123 | + pip install build twine |
| 124 | +
|
| 125 | + - name: Build package |
| 126 | + run: python -m build |
| 127 | + |
| 128 | + - name: Check package |
| 129 | + run: twine check dist/* |
| 130 | + |
| 131 | + - name: Upload artifacts |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: dist |
| 135 | + path: dist/ |
0 commit comments