-
Notifications
You must be signed in to change notification settings - Fork 5
447 lines (389 loc) · 16.7 KB
/
ci.yml
File metadata and controls
447 lines (389 loc) · 16.7 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
name: CI
concurrency:
group: ${{ github.head_ref || github.sha }}
cancel-in-progress: true
on:
pull_request:
workflow_dispatch:
# schedule:
# - cron: "0 1 * * *"
jobs:
build_and_test_linux:
if: ${{ github.event_name == 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
include:
- {platform: 'ubuntu-22.04', python_version: '3.10', mgversion: 'latest'}
- {platform: 'ubuntu-24.04', python_version: '3.10', mgversion: 'latest'}
- {platform: 'ubuntu-24.04', python_version: '3.11', mgversion: 'latest'}
- {platform: 'ubuntu-24.04', python_version: '3.12', mgversion: 'latest'}
- {platform: 'ubuntu-24.04', python_version: '3.13', mgversion: 'latest'}
- {platform: 'fedora-41', python_version: '3.13', mgversion: 'latest'}
runs-on: ["self-hosted", "X64"]
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set Memgraph Version
run: |
if [[ "${{ matrix.mgversion }}" == "latest" ]]; then
mgversion=$(curl -s https://api.github.com/repos/memgraph/memgraph/releases/latest | jq -r .tag_name)
mgversion=${mgversion#v}
else
mgversion="${{ matrix.mgversion }}"
fi
echo "MGVERSION=$mgversion" >> $GITHUB_ENV
- name: Download Memgraph
run: |
if [[ "${{ matrix.platform }}" == "fedora-41" ]]; then
MEMGRAPH_PACKAGE_NAME="memgraph-${{ env.MGVERSION }}_1-1.x86_64.rpm"
LOCAL_PACKAGE_NAME=memgraph.rpm
else
MEMGRAPH_PACKAGE_NAME="memgraph_${{ env.MGVERSION }}-1_amd64.deb"
LOCAL_PACKAGE_NAME=memgraph.deb
fi
curl -L "https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/${{ matrix.platform }}/${MEMGRAPH_PACKAGE_NAME}" > "${LOCAL_PACKAGE_NAME}"
echo "LOCAL_PACKAGE_NAME=$LOCAL_PACKAGE_NAME" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Launch Docker Container
run: |
platform="${{ matrix.platform }}"
tag=${platform//-/:}
docker run -d --rm --name testcontainer "$tag" sleep infinity
- name: Set Environment Variables
run: |
break_packages=""
static_ssl=""
if [[ "${{ matrix.platform }}" == "ubuntu-24.04" ]]; then
# this option is specific to ubuntu, not fedora
break_packages="--break-system-packages"
elif [[ "${{ matrix.platform }}" == fedora* ]]; then
# rpm distros do not ship with static lib for openssl
static_ssl="--no-build-isolation --global-option=build_ext --global-option '--static-openssl=False'"
fi
echo "BREAK_PACKAGES=$break_packages" >> $GITHUB_ENV
echo "STATIC_SSL=$static_ssl" >> $GITHUB_ENV
- name: Install system dependencies
run: |
docker cp $LOCAL_PACKAGE_NAME testcontainer:/$LOCAL_PACKAGE_NAME
if [[ "${{ matrix.platform }}" == "fedora-41" ]]; then
docker exec -i testcontainer \
bash -c "dnf install -y python${{ matrix.python_version }} python3-pip python3-setuptools python3-wheel python3-devel cmake g++ openssl-devel nmap-ncat"
docker exec -i testcontainer \
bash -c "pip3 install --upgrade networkx pytest pyopenssl sphinx"
docker exec -i testcontainer \
bash -c "mkdir -p /etc/systemd/system && ln -s /dev/null /etc/systemd/system/memgraph.service" # Prevents Memgraph from starting.
docker exec -i testcontainer \
bash -c "dnf install -y /$LOCAL_PACKAGE_NAME"
else
if [[ "${{ matrix.platform }}" == "ubuntu-22.04" ]]; then
curl_package=libcurl4
else
curl_package=libcurl4t64
fi
docker exec -i testcontainer \
bash -c "apt update && apt install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa"
docker exec -i testcontainer \
bash -c "apt update && apt install -y libpython${{ matrix.python_version }} python3-pip python3-setuptools $curl_package cmake libssl-dev netcat-traditional"
docker exec -i testcontainer \
bash -c "pip3 install --upgrade networkx pytest pyopenssl sphinx ${{ env.BREAK_PACKAGES }}"
docker exec -i testcontainer \
bash -c "mkdir -p /etc/systemd/system && ln -s /dev/null /etc/systemd/system/memgraph.service" # Prevents Memgraph from starting.
docker exec -i testcontainer \
bash -c "dpkg -i /$LOCAL_PACKAGE_NAME"
fi
rm -v $LOCAL_PACKAGE_NAME
- name: Copy Repo Into Container
run: |
docker cp . testcontainer:/pymgclient
- name: Build source distribution
run: |
docker exec -i testcontainer \
bash -c "cd /pymgclient && python3 setup.py sdist"
- name: Install pymgclient
run: |
docker exec -i testcontainer \
bash -c "python3 -m pip install ${{ env.STATIC_SSL }} ./pymgclient/dist/pymgclient-* ${{ env.BREAK_PACKAGES }}"
- name: Import mgclient to validate installation
run: |
docker exec -i testcontainer \
bash -c "python3 -c 'import mgclient'"
- name: Run tests
run: |
MEMGRAPH_PORT=10000 # what's this for?
docker exec -i testcontainer \
bash -c "cd /pymgclient && python3 -m pytest -v"
- name: Build docs
run: |
docker exec -i testcontainer \
bash -c "cd /pymgclient/docs && make html"
- name: Copy Package
run: |
docker cp testcontainer:/pymgclient/dist .
- name: Save source distribution package
uses: actions/upload-artifact@v4
with:
name: pymgclient
path: dist/${{ matrix.platform }}-${{ matrix.python_version }}
- name: Cleanup
if: always()
run: |
docker stop testcontainer || echo "Container does not exist"
docker wait testcontainer || echo "Container does not exist"
docker rmi ${{ env.MGVERSION }} || echo "Image does not exist"
build_and_test_windows:
name: Build and Test on Windows
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2022]
python-version: ["3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: >
git
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-openssl
- name: Add MSYS2 mingw64/bin to PATH
shell: msys2 {0}
run: |
echo "/mingw64/bin" >> $GITHUB_PATH
- name: Set up Windows Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Debug Find OpenSSL DLLs
shell: msys2 {0}
run: |
find /mingw64/bin -iname "*ssl*.dll"
find /mingw64/bin -iname "*crypto*.dll"
- name: Add Windows Python to PATH
shell: msys2 {0}
run: |
echo "$pythonLocation" >> $GITHUB_PATH
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Install Python build tools
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python -m pip install --upgrade pip setuptools wheel pyopenssl pytest
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Build pymgclient Wheel
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python setup.py bdist_wheel
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Install built wheel
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):$PATH"
python -m pip install dist/*.whl
env:
pythonLocation: ${{ env.pythonLocation }}
- name: Check mgclient.pyd DLL Dependencies (MSYS2)
run: |
mgclient_path=$(find $pythonLocation -name "mgclient.cp*.pyd" | head -n1)
if [ -z "$mgclient_path" ]; then
echo "mgclient.pyd not found!"
exit 1
fi
echo "Found: $mgclient_path"
objdump -p "$mgclient_path" | grep 'DLL Name'
shell: msys2 {0}
- name: Check that required DLLs are in PATH
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):/mingw64/bin:$PATH"
echo "🔎 Checking for required DLLs in PATH:"
for dll in libssl-3-x64.dll libcrypto-3-x64.dll python311.dll; do
found=0
for dir in $(echo $PATH | tr ':' '\n'); do
if [ -f "$dir/$dll" ]; then
echo "✅ Found $dll in $dir"
found=1
break
fi
done
if [ "$found" -eq 0 ]; then
echo "❌ Missing $dll!"
exit 1
fi
done
env:
pythonLocation: ${{ env.pythonLocation }}
# - name: Setup WSL Ubuntu
# uses: Vampire/setup-wsl@v5
# with:
# distribution: Ubuntu-24.04
# - name: Set Memgraph Version
# shell: bash -l {0}
# run: |
# mgversion=$(
# curl -s https://api.github.com/repos/memgraph/memgraph/releases/latest \
# | grep -m1 '"tag_name":' \
# | sed -E 's/.*"([^"]+)".*/\1/' \
# | sed 's/^v//'
# )
# echo "MGVERSION=$mgversion" >> $GITHUB_ENV
# - name: Install and Run Memgraph in WSL
# shell: wsl-bash {0}
# run: |
# mkdir -p $HOME/memgraph/data
# sudo apt update
# sudo apt install -y curl
# curl -L https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/ubuntu-24.04/memgraph_${{ env.MGVERSION }}-1_amd64.deb -o memgraph.deb
# sudo mkdir -p /etc/systemd/system && sudo ln -s /dev/null /etc/systemd/system/memgraph.service # Prevents Memgraph from starting.
# sudo apt install ./memgraph.deb
# # openssl req -x509 -newkey rsa:4096 -days 3650 -nodes -keyout key.pem -out cert.pem -subj "/C=GB/ST=London/L=London/O=Testing Corp./CN=PymgclientTest"
# # nohup /usr/lib/memgraph/memgraph --bolt-port 7687 --bolt-cert-file="cert.pem" --bolt-key-file="key.pem" --data-directory="~/memgraph/data" --storage-properties-on-edges=true --storage-snapshot-interval-sec=0 --storage-wal-enabled=false --storage-snapshot-on-exit=false --telemetry-enabled=false --log-file='' &
# nohup /usr/lib/memgraph/memgraph --bolt-port 7687 --bolt-cert-file="" --bolt-key-file="" --data-directory="~/memgraph/data" --storage-properties-on-edges=true --storage-snapshot-interval-sec=0 --storage-wal-enabled=false --data-recovery-on-startup=false --storage-snapshot-on-exit=false --telemetry-enabled=false --log-level=TRACE --log-file='$HOME/memgraph/memgraph.log' &
# sleep 10
# ps aux | grep memgraph
# cat $HOME/memgraph/memgraph.log || true
- name: Copy required DLLs from MSYS2 to Python site-packages
shell: msys2 {0}
run: |
set -e
PY_SITE_PACKAGES=$(cygpath -u "$pythonLocation")/Lib/site-packages
for dll in libssl-3-x64.dll libcrypto-3-x64.dll; do
if [ -f /mingw64/bin/$dll ]; then
cp /mingw64/bin/$dll "$PY_SITE_PACKAGES"
echo "✅ Copied $dll to site-packages."
else
echo "❌ $dll not found in /mingw64/bin!"
exit 1
fi
done
env:
pythonLocation: ${{ env.pythonLocation }}
# - name: Verify Memgraph is running under WSL
# shell: wsl-bash {0}
# run: |
# # process
# ps aux | grep memgraph
# if ! pgrep -f /usr/lib/memgraph/memgraph; then
# echo "❌ Memgraph not running" >&2
# cat $HOME/memgraph/memgraph.log || true
# exit 1
# fi
# echo "✅ Memgraph check passed"
# echo "🔍 Checking if port 7687 is open..."
# if command -v ss >/dev/null 2>&1; then
# ss -tln | grep ':7687' || (echo "❌ Port 7687 not open!" && exit 1)
# elif command -v netstat >/dev/null 2>&1; then
# netstat -an | grep ':7687' || (echo "❌ Port 7687 not open!" && exit 1)
# else
# echo "⚠️ Warning: Neither ss nor netstat is available to check ports."
# exit 1
# fi
# echo "✅ Memgraph port 7687 is open."
# - name: Verify Memgraph is reachable from Windows (MSYS2)
# shell: msys2 {0}
# run: |
# echo "🔍 Checking connection to Memgraph from MSYS2 shell..."
# timeout 3 bash -c "</dev/tcp/localhost/7687" && echo "✅ Memgraph is reachable on port 7687." || (echo "❌ Cannot connect to Memgraph on localhost:7687!" && exit 1)
- name: Run Tests
shell: msys2 {0}
run: |
export PATH="$(cygpath -u "$pythonLocation"):/mingw64/bin:$PATH"
echo $PATH
cd ..
python -c "import mgclient"
# python -m pytest -v
env:
pythonLocation: ${{ env.pythonLocation }}
MEMGRAPH_HOST: localhost
MEMGRAPH_STARTED_WITH_SSL:
- name: Upload Wheel Artifact
uses: actions/upload-artifact@v4
with:
name: pymgclient-win-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/
# - name: Print Log
# shell: wsl-bash {0}
# if: always()
# run: |
# cat $HOME/memgraph/memgraph.log || true
build_macos:
if: ${{ github.event_name == 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
#platform: [macos-15, macos-14]
#python_version:
#- '3.9' # this does work, but is old
# - '3.10'
# - '3.11'
# - '3.12'
# - '3.13'
include:
- {platform: [self-hosted, macos-12, ARM64], python_version: '3.13'}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Install python and OpenSSL
run: |
brew install python@${{ matrix.python_version }} openssl@1.1
brew link --force --overwrite openssl@1.1
openssl version -a
- name: Manage OpenSSL 3 on ARM machines
if: ${{ contains(matrix.platform, 'ARM64') }}
run: |
brew install openssl@3
brew link --force --overwrite openssl@3
openssl version -a
- name: Make used python version default
run: |
brew unlink python@3 && brew link --force python@${{ matrix.python_version }}
python${{ matrix.python_version }} --version
- name: Install pytest and pyopenssl
run: |
export PIP_BREAK_SYSTEM_PACKAGES=1
python${{ matrix.python_version }} -m pip install pyopenssl pytest setuptools
- name: Build pymgclient
run: python${{ matrix.python_version }} setup.py sdist
- name: Install pymgclient
run: |
export PIP_BREAK_SYSTEM_PACKAGES=1
python${{ matrix.python_version }} -m pip install dist/*
- name: Import mgclient to validate installation
run: python${{ matrix.python_version }} -c "import mgclient"
- name: Save artifact name on x86 machines
if: ${{ !contains(matrix.platform, 'ARM64') }}
run: echo "OS_TYPE=${{ matrix.platform }}" >> $GITHUB_ENV
- name: Save artifact name on ARM64 machines
if: ${{ contains(matrix.platform, 'ARM64') }}
# Convert macOS-11.6-ARM64 to macos-11.6-arm64 to be consistent with full lowercase naming
run: echo OS_TYPE=`echo "${{ matrix.platform[0] }}-${{ matrix.platform[1] }}" | tr "[:upper:]" "[:lower:]"` >> $GITHUB_ENV
- name: Save wheel package
uses: actions/upload-artifact@v4
with:
name: pymgclient-${{ env.OS_TYPE }}-${{ matrix.python_version }}
path: dist/