forked from ArcadeData/arcadedb
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (162 loc) Β· 7.04 KB
/
Copy pathtest-python-bindings.yml
File metadata and controls
190 lines (162 loc) Β· 7.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Test Python Bindings
on:
# Run on PRs that touch Python code
pull_request:
paths:
- 'bindings/python/**'
- '.github/workflows/test-python-bindings.yml'
# Run on pushes to branches with "python" in the name
push:
branches:
- '**python**' # Matches: python-embedded, feature-python, python-docs, etc.
- '**Python**' # Case variations
- '**PYTHON**'
# Run before releases (as a required check for python releases)
release:
types: [created, published]
# Allow being called by other workflows (e.g., release workflow)
workflow_call:
# Allow manual trigger
workflow_dispatch:
inputs:
distribution:
description: 'Distribution to test (all, headless, minimal, or full)'
required: false
default: 'all'
type: choice
options:
- all
- headless
- minimal
- full
jobs:
test:
name: Test ${{ matrix.distribution }} distribution
runs-on: ubuntu-latest
strategy:
# Don't cancel other matrix jobs if one fails
fail-fast: false
matrix:
distribution: [headless, minimal, full]
# Filter based on workflow_dispatch input if present
exclude:
- distribution: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.distribution != 'all' && github.event.inputs.distribution != 'headless' && 'headless' || '' }}
- distribution: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.distribution != 'all' && github.event.inputs.distribution != 'minimal' && 'minimal' || '' }}
- distribution: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.distribution != 'all' && github.event.inputs.distribution != 'full' && 'full' || '' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and test ${{ matrix.distribution }} distribution
run: |
cd bindings/python
echo "π¨ Building ${{ matrix.distribution }} distribution..."
./build-all.sh ${{ matrix.distribution }}
env:
DISTRIBUTION: ${{ matrix.distribution }}
- name: Extract wheel for additional testing
run: |
cd bindings/python
mkdir -p test-install
cp dist/*${{ matrix.distribution }}*.whl test-install/ || cp dist/*.whl test-install/
- name: Set up Python for host testing
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Java (required for JPype)
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Install wheel and test dependencies
run: |
cd bindings/python
pip install test-install/*.whl pytest pytest-cov requests
- name: Run pytest on host
id: pytest
run: |
cd bindings/python
echo "π§ͺ Testing ${{ matrix.distribution }} distribution..."
# Run pytest with verbose output
pytest tests/ -v --tb=short --color=yes 2>&1 | tee pytest-output.txt
# Check results
if grep -q "failed" pytest-output.txt; then
echo "β Tests FAILED"
exit 1
elif grep -q "passed" pytest-output.txt || grep -q "skipped" pytest-output.txt; then
echo "β
Tests PASSED (may include skipped tests based on distribution)"
# Count results
PASSED=$(grep -oP '\d+(?= passed)' pytest-output.txt || echo "0")
SKIPPED=$(grep -oP '\d+(?= skipped)' pytest-output.txt || echo "0")
FAILED=$(grep -oP '\d+(?= failed)' pytest-output.txt || echo "0")
echo "passed=$PASSED" >> $GITHUB_OUTPUT
echo "skipped=$SKIPPED" >> $GITHUB_OUTPUT
echo "failed=$FAILED" >> $GITHUB_OUTPUT
# Exit with error if any failures
if [ "$FAILED" != "0" ]; then
exit 1
fi
else
echo "β οΈ Unexpected test output"
exit 1
fi
- name: Generate test summary
if: always()
run: |
cd bindings/python
echo "## π§ͺ Test Results: ${{ matrix.distribution }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.pytest.outcome }}" = "success" ]; then
echo "β
**Status**: PASSED" >> $GITHUB_STEP_SUMMARY
else
echo "β **Status**: FAILED" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Metric | Count |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| β
Passed | ${{ steps.pytest.outputs.passed || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
echo "| βοΈ Skipped | ${{ steps.pytest.outputs.skipped || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
echo "| β Failed | ${{ steps.pytest.outputs.failed || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Expected Behavior by Distribution:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Headless**: Some tests skipped (no server/Gremlin features)" >> $GITHUB_STEP_SUMMARY
echo "- **Minimal**: Few tests skipped (no Gremlin, has server/Studio)" >> $GITHUB_STEP_SUMMARY
echo "- **Full**: Minimal skipped tests (all features available)" >> $GITHUB_STEP_SUMMARY
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.distribution }}
path: |
bindings/python/pytest-output.txt
bindings/python/.coverage
retention-days: 7
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.distribution }}-test
path: bindings/python/dist/*.whl
retention-days: 7
# Summary job that checks all distributions
test-summary:
name: Test Summary
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Check test results
run: |
echo "## π― Overall Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.test.result }}" = "success" ]; then
echo "β
**All distributions passed testing!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All three Python distributions (headless, minimal, full) have been successfully built and tested." >> $GITHUB_STEP_SUMMARY
else
echo "β **Some distributions failed testing**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please check the individual test jobs for details." >> $GITHUB_STEP_SUMMARY
exit 1
fi