|
| 1 | +name: Test SDK Examples |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'sdk-examples/**' |
| 7 | + - '.github/workflows/test-sdk-examples.yml' |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - 'claude/**' |
| 12 | + paths: |
| 13 | + - 'sdk-examples/**' |
| 14 | + - '.github/workflows/test-sdk-examples.yml' |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + name: Test SDK Examples (Python 3.10) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + pull-requests: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Set up Python 3.10 |
| 31 | + uses: actions/setup-python@v4 |
| 32 | + with: |
| 33 | + python-version: '3.10' |
| 34 | + cache: 'pip' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: | |
| 38 | + python -m pip install --upgrade pip setuptools wheel |
| 39 | + pip install --prefer-binary -r sdk-examples/requirements-test.txt |
| 40 | +
|
| 41 | + - name: Run tests with pytest and coverage |
| 42 | + working-directory: sdk-examples |
| 43 | + run: | |
| 44 | + pytest tests/ -v --cov=. --cov-report=term-missing --cov-report=xml --cov-report=html |
| 45 | +
|
| 46 | + - name: Verify coverage data exists |
| 47 | + working-directory: sdk-examples |
| 48 | + run: | |
| 49 | + if [ ! -f .coverage ]; then |
| 50 | + echo "Error: No coverage data found. Coverage was not collected." |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + echo "Coverage data verified at .coverage" |
| 54 | +
|
| 55 | + - name: Coverage comment |
| 56 | + uses: py-cov-action/python-coverage-comment-action@v3 |
| 57 | + if: github.event_name == 'pull_request' |
| 58 | + with: |
| 59 | + GITHUB_TOKEN: ${{ github.token }} |
| 60 | + MINIMUM_GREEN: 100 |
| 61 | + MINIMUM_ORANGE: 90 |
| 62 | + ANNOTATE_MISSING_LINES: true |
| 63 | + ANNOTATION_TYPE: warning |
| 64 | + COVERAGE_PATH: sdk-examples |
| 65 | + |
| 66 | + - name: Generate coverage report |
| 67 | + if: always() |
| 68 | + working-directory: sdk-examples |
| 69 | + run: | |
| 70 | + pip install coverage |
| 71 | + coverage report --show-missing |
| 72 | +
|
| 73 | + lint: |
| 74 | + name: Lint SDK Examples |
| 75 | + runs-on: ubuntu-latest |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Checkout code |
| 79 | + uses: actions/checkout@v4 |
| 80 | + |
| 81 | + - name: Set up Python |
| 82 | + uses: actions/setup-python@v4 |
| 83 | + with: |
| 84 | + python-version: '3.10' |
| 85 | + |
| 86 | + - name: Install linting tools |
| 87 | + run: | |
| 88 | + python -m pip install --upgrade pip |
| 89 | + pip install ruff black isort |
| 90 | +
|
| 91 | + - name: Check formatting with black |
| 92 | + run: | |
| 93 | + black --check sdk-examples/*.py sdk-examples/tests/*.py || true |
| 94 | +
|
| 95 | + - name: Check import sorting with isort |
| 96 | + run: | |
| 97 | + isort --check-only sdk-examples/*.py sdk-examples/tests/*.py || true |
| 98 | +
|
| 99 | + - name: Lint with ruff |
| 100 | + run: | |
| 101 | + ruff check sdk-examples/*.py sdk-examples/tests/*.py || true |
| 102 | +
|
| 103 | + validate-examples: |
| 104 | + name: Validate Example Files |
| 105 | + runs-on: ubuntu-latest |
| 106 | + |
| 107 | + steps: |
| 108 | + - name: Checkout code |
| 109 | + uses: actions/checkout@v4 |
| 110 | + |
| 111 | + - name: Set up Python |
| 112 | + uses: actions/setup-python@v4 |
| 113 | + with: |
| 114 | + python-version: '3.10' |
| 115 | + |
| 116 | + - name: Install dependencies |
| 117 | + run: | |
| 118 | + python -m pip install --upgrade pip setuptools wheel |
| 119 | + pip install --prefer-binary -r sdk-examples/requirements-test.txt |
| 120 | +
|
| 121 | + - name: Validate Python syntax |
| 122 | + run: | |
| 123 | + python -m py_compile sdk-examples/*.py |
| 124 | + python -m py_compile sdk-examples/tests/*.py |
| 125 | +
|
| 126 | + - name: Check for common issues |
| 127 | + run: | |
| 128 | + # Check all files have proper docstrings (skip shebangs and encoding declarations) |
| 129 | + for file in sdk-examples/*.py; do |
| 130 | + if ! head -n 20 "$file" | grep -E '^("""|'"'"''"'"''"'"')' > /dev/null; then |
| 131 | + echo "Missing docstring in $file" |
| 132 | + exit 1 |
| 133 | + fi |
| 134 | + done |
| 135 | +
|
| 136 | + - name: Verify all imports can be resolved |
| 137 | + working-directory: sdk-examples |
| 138 | + run: | |
| 139 | + python -c "import setup; import services; import entities; import metadata_ops; import lineage; import queries; import advanced" |
0 commit comments