forked from DamengDB/dmPython
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (147 loc) · 6.28 KB
/
Copy pathintegration-tests.yml
File metadata and controls
167 lines (147 loc) · 6.28 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
name: Integration Tests
on:
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: "0 18 * * *"
jobs:
pr-lightweight:
if: github.event_name == 'pull_request'
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache-dependency-path: dpi_bridge/go.sum
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Check DM secrets availability
id: dm_ready
run: |
if [ -n "${{ secrets.DM_TEST_HOST }}" ] && [ -n "${{ secrets.DM_TEST_PORT }}" ] && [ -n "${{ secrets.DM_TEST_USER }}" ] && [ -n "${{ secrets.DM_TEST_PASSWORD }}" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
- name: Decode DPI headers
if: steps.dm_ready.outputs.available == 'true'
env:
DPI_HEADERS_TAR_B64: ${{ secrets.DPI_HEADERS_TAR_B64 }}
run: |
mkdir -p dpi_include
echo "$DPI_HEADERS_TAR_B64" | base64 -d | tar xzf - -C dpi_include/
- name: Build Go bridge library
if: steps.dm_ready.outputs.available == 'true'
run: |
cd dpi_bridge && go build -buildmode=c-shared -o libdmdpi.dylib .
install_name_tool -id @rpath/libdmdpi.dylib libdmdpi.dylib
- name: Build extension and run P0/P1
if: steps.dm_ready.outputs.available == 'true'
env:
DYLD_LIBRARY_PATH: ${{ github.workspace }}/dpi_bridge
DM_TEST_HOST: ${{ secrets.DM_TEST_HOST }}
DM_TEST_PORT: ${{ secrets.DM_TEST_PORT }}
DM_TEST_USER: ${{ secrets.DM_TEST_USER }}
DM_TEST_PASSWORD: ${{ secrets.DM_TEST_PASSWORD }}
DM_TEST_BOUNDARY_SIZES: ${{ secrets.DM_TEST_BOUNDARY_SIZES }}
run: |
python -m pip install pytest pytest-timeout pytest-cov
python setup.py build_ext --inplace
python -m pytest -q tests/integration -m "p0_stability or p1_contract" --junitxml=pytest-pr.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml
- name: Upload coverage report (PR)
if: steps.dm_ready.outputs.available == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-pr
path: |
coverage.xml
pytest-pr.xml
- name: Skip lightweight integration tests
if: steps.dm_ready.outputs.available != 'true'
run: |
echo "::notice::SKIP_DM_INTEGRATION: PR integration tests are skipped because DM secrets are not configured."
full-regression:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache-dependency-path: dpi_bridge/go.sum
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Check DM secrets availability
id: dm_ready
run: |
if [ -n "${{ secrets.DM_TEST_HOST }}" ] && [ -n "${{ secrets.DM_TEST_PORT }}" ] && [ -n "${{ secrets.DM_TEST_USER }}" ] && [ -n "${{ secrets.DM_TEST_PASSWORD }}" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
- name: Decode DPI headers
if: steps.dm_ready.outputs.available == 'true'
env:
DPI_HEADERS_TAR_B64: ${{ secrets.DPI_HEADERS_TAR_B64 }}
run: |
mkdir -p dpi_include
echo "$DPI_HEADERS_TAR_B64" | base64 -d | tar xzf - -C dpi_include/
- name: Build Go bridge library
if: steps.dm_ready.outputs.available == 'true'
run: |
cd dpi_bridge && go build -buildmode=c-shared -o libdmdpi.dylib .
install_name_tool -id @rpath/libdmdpi.dylib libdmdpi.dylib
- name: Build extension and run P0/P1/P2
if: steps.dm_ready.outputs.available == 'true'
env:
DYLD_LIBRARY_PATH: ${{ github.workspace }}/dpi_bridge
DM_TEST_HOST: ${{ secrets.DM_TEST_HOST }}
DM_TEST_PORT: ${{ secrets.DM_TEST_PORT }}
DM_TEST_USER: ${{ secrets.DM_TEST_USER }}
DM_TEST_PASSWORD: ${{ secrets.DM_TEST_PASSWORD }}
DM_TEST_BOUNDARY_SIZES: ${{ secrets.DM_TEST_BOUNDARY_SIZES }}
DM_TEST_STRESS_ROWS: ${{ secrets.DM_TEST_STRESS_ROWS }}
DM_TEST_STRESS_WORKERS: ${{ secrets.DM_TEST_STRESS_WORKERS }}
DM_TEST_CHURN_LOOPS: ${{ secrets.DM_TEST_CHURN_LOOPS }}
DM_TEST_GC_LOOPS: ${{ secrets.DM_TEST_GC_LOOPS }}
run: |
python -m pip install pytest pytest-timeout pytest-cov
python setup.py build_ext --inplace
start_ts=$(date +%s)
python -m pytest -q tests/integration -m "p0_stability or p1_contract or p2_scale" --junitxml=pytest-full.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml
end_ts=$(date +%s)
duration=$((end_ts - start_ts))
python - <<PY
import json
import xml.etree.ElementTree as ET
root = ET.parse("pytest-full.xml").getroot()
attrs = root.attrib
trend = {
"tests": int(float(attrs.get("tests", "0"))),
"failures": int(float(attrs.get("failures", "0"))),
"errors": int(float(attrs.get("errors", "0"))),
"skipped": int(float(attrs.get("skipped", "0"))),
"pytest_reported_seconds": float(attrs.get("time", "0")),
"wall_clock_seconds": int(${duration}),
}
with open("trend-full-regression.json", "w", encoding="utf-8") as f:
json.dump(trend, f, indent=2, ensure_ascii=False)
print(trend)
PY
- name: Upload coverage report (full)
if: steps.dm_ready.outputs.available == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-full
path: |
coverage.xml
pytest-full.xml
trend-full-regression.json
- name: Skip full integration tests
if: steps.dm_ready.outputs.available != 'true'
run: |
echo "::notice::SKIP_DM_INTEGRATION: Full regression is skipped because DM secrets are not configured."