-
Notifications
You must be signed in to change notification settings - Fork 6
309 lines (285 loc) · 11.2 KB
/
ci.yml
File metadata and controls
309 lines (285 loc) · 11.2 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
name: CI
on:
push:
pull_request:
workflow_dispatch:
inputs:
apple:
type: boolean
default: false
description: "Build and test on Mac OS"
windows:
type: boolean
default: false
description: "Build and test on Windows (VCPKG)"
windows_mingw:
type: boolean
default: false
description: "Build and test on Windows (MinGW)"
linux:
type: boolean
default: false
description: "Build and test on Linux"
linux_wasm:
type: boolean
default: false
description: "Build and test on Linux (Wasm)"
jobs:
clang_check:
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Set-up repository
uses: actions/checkout@v4
- name: Install environment
run: |
sudo apt install -y clang-format
- name: Run clang formatter
run: |
./tool/format.sh
build_and_test_apple:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.apple) }}
strategy:
matrix:
platform: [macos-14, macos-15]
runs-on: ${{ matrix.platform }}
steps:
- name: Set-up repository
uses: actions/checkout@v4
# NOTE: CI can't execute end2end tests because there is no way to run
# Memgraph on CI MacOS machines.
- name: Build and test mgclient
run: |
mkdir build
cd build
cmake -DOPENSSL_ROOT_DIR="$(ls -rd -- /usr/local/Cellar/openssl@1.1/* | head -n 1)" -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON ..
cmake --build . --parallel
ctest -E "example|integration"
sudo make install
build_windows_compiler:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.windows) }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
- os: windows-2025
runs-on: ${{ matrix.os }}
env:
VCPKG_ROOT: "${{ github.workspace }}\\vcpkg"
deps: "openssl:x64-windows"
steps:
- name: Set-up repository
uses: actions/checkout@v4
- name: Restore vcpkg and its artifacts
uses: actions/cache@v4
id: vcpkg-cache
with:
path: ${{ env.VCPKG_ROOT }}
key: ${{ matrix.os }}-${{ env.deps }}
- name: Get vcpkg
if: ${{ steps.vcpkg-cache.outputs.cache-hit != 'true' }}
run: |
cd ${{ github.workspace }}
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
- name: Remove system vcpkg
run: rm -rf "$VCPKG_INSTALLATION_ROOT"
shell: bash
- name: Install vcpkg packages
run: |
${{ env.VCPKG_ROOT }}\vcpkg.exe install ${{ env.deps }}
- name: Build and test mgclient
run: |
mkdir build
cd build
cmake -DOPENSSL_ROOT_DIR="${{ env.VCPKG_ROOT }}\installed\x64-windows" ..
cmake --build .
build_and_test_linux:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.linux) }}
strategy:
matrix:
platform: [ubuntu-24.04, fedora-41]
mgversion: ["latest"]
packages: ["gcc g++ clang cmake git"]
gcc-postfix: [""]
clang-postfix: [""]
runs-on: ["self-hosted", "X64"]
env:
MEMGRAPH_NETWORK: "host"
steps:
- name: Set-up repository
uses: actions/checkout@v4
- 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: |
docker network create ${{ env.MEMGRAPH_NETWORK }} || true
platform="${{ matrix.platform }}"
tag=${platform//-/:}
docker run -d --rm --name testcontainer --network ${{ env.MEMGRAPH_NETWORK }} "$tag" sleep infinity
- name: Install environment
run: |
if [[ "${{ matrix.platform }}" == ubuntu* ]]; then
docker exec -i testcontainer bash -c "apt update && apt install -y ${{ matrix.packages }} libssl-dev"
else
docker exec -i testcontainer bash -c "dnf install -y ${{ matrix.packages }} openssl-devel"
fi
- name: Copy Repo Into Container
run: |
docker cp . testcontainer:/mgclient
- 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 Docker image
run: |
curl -L https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/docker/memgraph-${{ env.MGVERSION }}-docker.tar.gz > memgraph-docker.tar.gz
- name: Load and run Memgraph Docker image
run: |
docker load -i memgraph-docker.tar.gz
docker run -d --rm --name memgraphcontainer --network ${{ env.MEMGRAPH_NETWORK }} -p 7687:7687 memgraph/memgraph --telemetry-enabled=false
rm memgraph-docker.tar.gz
sleep 5
docker logs memgraphcontainer
- name: Build with gcc, test and install mgclient
run: |
cmake_configure="cmake \
-DCMAKE_C_COMPILER=gcc${{ matrix.gcc-postfix }} \
-DCMAKE_CXX_COMPILER=g++${{ matrix.gcc-postfix }} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_TESTING_INTEGRATION=ON \
-DC_WARNINGS_AS_ERRORS=ON \
-DCPP_WARNINGS_AS_ERRORS=ON \
.."
docker exec -i testcontainer bash -c "
mkdir /mgclient/build-gcc &&
cd /mgclient/build-gcc &&
$cmake_configure &&
cmake --build . --parallel &&
ctest --output-on-failure &&
make install"
- name: Build with clang, test and install mgclient
run: |
cmake_configure="cmake \
-DCMAKE_C_COMPILER=clang${{ matrix.clang-postfix }} \
-DCMAKE_CXX_COMPILER=clang++${{ matrix.clang-postfix }} \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=ON \
-DBUILD_TESTING_INTEGRATION=ON \
-DC_WARNINGS_AS_ERRORS=ON \
-DCPP_WARNINGS_AS_ERRORS=ON \
.."
docker exec -i testcontainer bash -c "
mkdir /mgclient/build-clang &&
cd /mgclient/build-clang &&
$cmake_configure &&
cmake --build . --parallel &&
ctest --output-on-failure &&
make install"
- name: Cleanup
if: always()
run: |
docker stop testcontainer || echo "testcontainer already stopped"
docker stop memgraphcontainer || echo "memgraphcontainer already stopped"
docker wait testcontainer || true
docker wait memgraphcontainer || true
docker rm "${{ env.MEMGRAPH_NETWORK }}" || echo "network already removed"
docker rmi "${{ matrix.platform }}" || echo "${{ matrix.platform }} image not found"
docker rmi memgraph/memgraph || echo "memgraph/memgraph image not found"
# GitHub actions can't run Linux Docker container on Windows machine
# https://github.com/actions/virtual-environments/issues/1143.
#
# The only option to test this project on GitHub Actions under Windows is to
# run Memgraph under [WSL](https://docs.microsoft.com/en-us/windows/wsl/).
# Memgraph has to be started manually because systemd is not available on
# WSL (init process does not exist).
# This particular test might be flaky (hence the additional memgraph process check)
build_and_test_windows_mingw:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.windows_mingw) }}
strategy:
fail-fast: false
matrix:
os: [windows-2022, windows-2025]
msystem: [MINGW64]
arch: [x86_64]
mgversion: ["latest"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: msys2 {0}
steps:
- name: Set-up repository
uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: git base-devel mingw-w64-${{ matrix.arch }}-toolchain mingw-w64-${{ matrix.arch }}-cmake mingw-w64-${{ matrix.arch }}-openssl
- uses: Vampire/setup-wsl@v5
with:
distribution: Ubuntu-24.04
- name: Set Memgraph Version
run: |
if [[ "${{ matrix.mgversion }}" == "latest" ]]; then
mgversion=$(
curl -s https://api.github.com/repos/memgraph/memgraph/releases/latest \
| grep -m1 '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/' \
| sed 's/^v//'
)
else
mgversion="${{ matrix.mgversion }}"
fi
echo "MGVERSION=$mgversion" >> $GITHUB_ENV
- name: Download, install and run Memgraph under WSL
shell: wsl-bash {0} # root shell
run: |
mkdir ~/memgraph
curl -L https://download.memgraph.com/memgraph/v${{ env.MGVERSION }}/ubuntu-24.04/memgraph_${{ env.MGVERSION }}-1_amd64.deb --output ~/memgraph/memgraph.deb
dpkg -i ~/memgraph/memgraph.deb
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-file='' &
sleep 1 # Wait for Memgraph a bit.
- name: Build and test mgclient
run: |
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DBUILD_TESTING=ON -DBUILD_TESTING_INTEGRATION=ON -DC_WARNINGS_AS_ERRORS=ON -DCPP_WARNINGS_AS_ERRORS=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build . --parallel
- name: Verify Memgraph is running under WSL
shell: wsl-bash {0}
run: |
# process
if ! pgrep -x memgraph; then
echo "❌ Memgraph not running" >&2
exit 1
fi
echo "✅ Memgraph check passed"
- name: Run Tests
run: |
ctest --verbose -R "allocator|value|example_basic|integration_basic"
build_and_test_linux_wasm:
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.linux_wasm) }}
strategy:
matrix:
platform: [ubuntu-24.04]
runs-on: ${{ matrix.platform }}
steps:
- name: Set-up repository
uses: actions/checkout@v4
- name: Build with clang
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DC_WARNINGS_AS_ERRORS=ON -DWASM=ON
make