|
1 | | -name: Test SDK Examples |
| 1 | +name: Test Python SDK examples |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - paths: |
6 | | - - 'sdk-examples/**' |
7 | | - - '.github/workflows/test-sdk-examples.yml' |
| 4 | + pull_request: {} |
8 | 5 | push: |
9 | | - branches: |
10 | | - - main |
11 | | - - 'claude/**' |
12 | | - paths: |
13 | | - - 'sdk-examples/**' |
14 | | - - '.github/workflows/test-sdk-examples.yml' |
| 6 | + branches: [main] |
15 | 7 |
|
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 |
| 8 | +permissions: |
| 9 | + contents: read |
65 | 10 |
|
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 |
| 11 | +jobs: |
| 12 | + python: |
| 13 | + name: Python 3.12 / openmetadata-ingestion 1.13 |
75 | 14 | runs-on: ubuntu-latest |
76 | 15 |
|
77 | 16 | steps: |
78 | | - - name: Checkout code |
| 17 | + - name: Check out repository |
79 | 18 | uses: actions/checkout@v4 |
80 | 19 |
|
81 | | - - name: Set up Python |
82 | | - uses: actions/setup-python@v4 |
| 20 | + - name: Set up Python 3.12 |
| 21 | + uses: actions/setup-python@v5 |
83 | 22 | with: |
84 | | - python-version: '3.10' |
| 23 | + python-version: "3.12" |
| 24 | + cache: pip |
| 25 | + cache-dependency-path: sdk-examples/requirements-test.txt |
85 | 26 |
|
86 | | - - name: Install linting tools |
| 27 | + - name: Install pinned SDK and test tools |
87 | 28 | run: | |
88 | 29 | python -m pip install --upgrade pip |
89 | | - pip install ruff black isort |
| 30 | + python -m pip install -r sdk-examples/requirements-test.txt |
90 | 31 |
|
91 | | - - name: Check formatting with black |
92 | | - run: | |
93 | | - black --check sdk-examples/*.py sdk-examples/tests/*.py || true |
| 32 | + - name: Compile examples |
| 33 | + run: python -m compileall -q sdk-examples |
94 | 34 |
|
95 | | - - name: Check import sorting with isort |
96 | | - run: | |
97 | | - isort --check-only sdk-examples/*.py sdk-examples/tests/*.py || true |
| 35 | + - name: Test imports, requests, and mocked SDK calls |
| 36 | + run: pytest -q sdk-examples/tests |
98 | 37 |
|
99 | | - - name: Lint with ruff |
100 | | - run: | |
101 | | - ruff check sdk-examples/*.py sdk-examples/tests/*.py || true |
| 38 | + - name: Lint |
| 39 | + run: ruff check sdk-examples |
102 | 40 |
|
103 | | - validate-examples: |
104 | | - name: Validate Example Files |
| 41 | + - name: Check formatting |
| 42 | + run: ruff format --check sdk-examples |
| 43 | + |
| 44 | + secrets: |
| 45 | + name: Secret scan |
105 | 46 | runs-on: ubuntu-latest |
106 | 47 |
|
107 | 48 | steps: |
108 | | - - name: Checkout code |
| 49 | + - name: Check out repository |
109 | 50 | uses: actions/checkout@v4 |
110 | 51 |
|
111 | | - - name: Set up Python |
112 | | - uses: actions/setup-python@v4 |
| 52 | + - name: Scan for secrets |
| 53 | + uses: docker://zricethezav/gitleaks:v8.27.0 |
113 | 54 | 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" |
| 55 | + args: dir /github/workspace --redact --no-banner |
0 commit comments