1+ name : Test TidesDB Python Bindings
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+ workflow_dispatch :
9+
10+ jobs :
11+ test :
12+ name : Test on ${{ matrix.os }} with Python ${{ matrix.python-version }}
13+ runs-on : ${{ matrix.os }}
14+ strategy :
15+ fail-fast : false
16+ matrix :
17+ os : [ubuntu-latest, macos-latest, windows-latest]
18+ python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
19+
20+ steps :
21+ - name : Checkout Python bindings
22+ uses : actions/checkout@v4
23+
24+ - name : Checkout TidesDB main repo
25+ uses : actions/checkout@v4
26+ with :
27+ repository : tidesdb/tidesdb
28+ path : tidesdb-core
29+
30+ - name : Set up Python ${{ matrix.python-version }}
31+ uses : actions/setup-python@v5
32+ with :
33+ python-version : ${{ matrix.python-version }}
34+
35+ # Ubuntu dependencies
36+ - name : Install dependencies (Ubuntu)
37+ if : runner.os == 'Linux'
38+ run : |
39+ sudo apt-get update
40+ sudo apt-get install -y \
41+ build-essential \
42+ cmake \
43+ libzstd-dev \
44+ liblz4-dev \
45+ libsnappy-dev \
46+ libssl-dev
47+
48+ # macOS dependencies
49+ - name : Install dependencies (macOS)
50+ if : runner.os == 'macOS'
51+ run : |
52+ brew install \
53+ cmake \
54+ zstd \
55+ lz4 \
56+ snappy \
57+ openssl@3
58+
59+ # Windows dependencies
60+ - name : Install dependencies (Windows)
61+ if : runner.os == 'Windows'
62+ run : |
63+ choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
64+ vcpkg install zstd:x64-windows lz4:x64-windows snappy:x64-windows openssl:x64-windows
65+ shell : powershell
66+
67+ # Build and install TidesDB C library (Ubuntu/macOS)
68+ - name : Build TidesDB (Unix)
69+ if : runner.os != 'Windows'
70+ working-directory : tidesdb-core
71+ run : |
72+ rm -rf build
73+ cmake -S . -B build \
74+ -DCMAKE_BUILD_TYPE=Release \
75+ -DTIDESDB_WITH_SANITIZER=OFF \
76+ -DTIDESDB_BUILD_TESTS=OFF
77+ cmake --build build
78+ sudo cmake --install build
79+
80+ # Build and install TidesDB C library (Windows)
81+ - name : Build TidesDB (Windows)
82+ if : runner.os == 'Windows'
83+ working-directory : tidesdb-core
84+ run : |
85+ cmake -S . -B build `
86+ -DCMAKE_BUILD_TYPE=Release `
87+ -DTIDESDB_WITH_SANITIZER=OFF `
88+ -DTIDESDB_BUILD_TESTS=OFF `
89+ -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
90+ cmake --build build --config Release
91+ cmake --install build --config Release
92+ shell : powershell
93+
94+ # Update library paths (Ubuntu)
95+ - name : Update library cache (Ubuntu)
96+ if : runner.os == 'Linux'
97+ run : sudo ldconfig
98+
99+ # Update library paths (macOS)
100+ - name : Set library path (macOS)
101+ if : runner.os == 'macOS'
102+ run : |
103+ echo "DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
104+
105+ # Update library paths (Windows)
106+ - name : Set library path (Windows)
107+ if : runner.os == 'Windows'
108+ run : |
109+ echo "$env:ProgramFiles\TidesDB\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
110+ shell : powershell
111+
112+ # Install Python dependencies
113+ - name : Install Python dependencies
114+ run : |
115+ python -m pip install --upgrade pip
116+ pip install pytest pytest-cov
117+
118+ # Install Python bindings
119+ - name : Install TidesDB Python bindings
120+ run : |
121+ pip install -e .
122+
123+ # Run tests
124+ - name : Run tests
125+ run : |
126+ pytest test_tidesdb.py -v --cov=tidesdb --cov-report=xml --cov-report=term
127+
128+ # Upload coverage
129+ - name : Upload coverage to Codecov
130+ if : matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
131+ uses : codecov/codecov-action@v4
132+ with :
133+ file : ./coverage.xml
134+ flags : unittests
135+ name : codecov-umbrella
136+ fail_ci_if_error : false
137+
138+ lint :
139+ name : Lint and Format Check
140+ runs-on : ubuntu-latest
141+ steps :
142+ - uses : actions/checkout@v4
143+
144+ - name : Set up Python
145+ uses : actions/setup-python@v5
146+ with :
147+ python-version : ' 3.11'
148+
149+ - name : Install linting tools
150+ run : |
151+ python -m pip install --upgrade pip
152+ pip install black flake8 mypy
153+
154+ - name : Check formatting with black
155+ run : |
156+ black --check --line-length 100 tidesdb.py test_tidesdb.py
157+
158+ - name : Lint with flake8
159+ run : |
160+ flake8 tidesdb.py test_tidesdb.py --max-line-length=100 --ignore=E203,W503
161+
162+ - name : Type check with mypy
163+ run : |
164+ mypy tidesdb.py --ignore-missing-imports
165+ continue-on-error : true
166+
167+ package :
168+ name : Build Package
169+ runs-on : ubuntu-latest
170+ steps :
171+ - uses : actions/checkout@v4
172+
173+ - name : Set up Python
174+ uses : actions/setup-python@v5
175+ with :
176+ python-version : ' 3.11'
177+
178+ - name : Install build tools
179+ run : |
180+ python -m pip install --upgrade pip
181+ pip install build twine
182+
183+ - name : Build package
184+ run : |
185+ python -m build
186+
187+ - name : Check package
188+ run : |
189+ twine check dist/*
190+
191+ - name : Upload artifacts
192+ uses : actions/upload-artifact@v4
193+ with :
194+ name : python-package
195+ path : dist/
0 commit comments