-
Notifications
You must be signed in to change notification settings - Fork 8
253 lines (215 loc) · 8.17 KB
/
ci.yml
File metadata and controls
253 lines (215 loc) · 8.17 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
name: CI
on:
push:
workflow_dispatch:
inputs:
build-static:
description: "Build static version of mgconsole"
type: boolean
required: false
default: false
workflow_call:
inputs:
build-static:
description: "Build static version of mgconsole"
type: boolean
required: false
default: false
run-name: "CI: Build and test mgconsole"
jobs:
build_and_test_ubuntu:
name: Build and test mgconsole on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Pull latest memgraph image
run: |
docker pull memgraph/memgraph:latest
echo "MEMGRAPH_IMAGE=memgraph/memgraph:latest" >> $GITHUB_ENV
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install and test mgconsole
run: |
cmake -B build -G Ninja -DMEMGRAPH_USE_DOCKER=ON -DMEMGRAPH_DOCKER_IMAGE=$MEMGRAPH_IMAGE
cmake --build build
sudo cmake --install build
ctest --verbose --test-dir build
- name: Save mgconsole test results
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole_ctest.log"
path: build/Testing/Temporary/LastTest.log
build_windows_mingw:
name: Build and test mgconsole on Windows
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Set-up repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0
with:
msystem: MINGW64
update: true
install: >-
git base-devel
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-openssl
- name: Build and install mgconsole
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release .
cmake --build build --parallel
cmake --install build
- name: Save mgconsole Windows build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole Windows build"
path: build/src/mgconsole.exe
build_apple_arm64:
name: Build and test mgconsole on Apple ARM64
runs-on: macos-15
steps:
- name: Set-up repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# NOTE: CI can't execute end2end tests because there is no way to run
# Memgraph on CI MacOS machines.
- name: Install openssl
run: |
brew update
brew install openssl
- name: Build mgconsole
run: |
cmake -B build -G Ninja -DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" -DCMAKE_BUILD_TYPE=Release .
cmake --build build
sudo cmake --install build
- name: Save mgconsole MacOS build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole MacOS build ARM64"
path: build/src/mgconsole
build_apple_x86_64:
name: Build and test mgconsole on Apple X86_64
runs-on: macos-15-intel
steps:
- name: Set-up repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# NOTE: CI can't execute end2end tests because there is no way to run
# Memgraph on CI MacOS machines.
- name: Install openssl
run: |
brew update
brew install openssl
- name: Build mgconsole
run: |
cmake -B build -G Ninja -DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" -DCMAKE_BUILD_TYPE=Release .
cmake --build build
sudo cmake --install build
- name: Save mgconsole MacOS build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole MacOS build X86_64"
path: build/src/mgconsole
build_apple_universal:
needs: [build_apple_arm64, build_apple_x86_64]
name: Build Apple universal binary (ARM64 and X86_64)
runs-on: macos-15
steps:
- name: Set-up repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download artifacts Apple ARM64
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: "mgconsole MacOS build ARM64"
path: temp-macos-arm64
- name: Download artifacts Apple X86_64
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: "mgconsole MacOS build X86_64"
path: temp-macos-x86_64
- name: Organize binaries
run: |
mkdir -p macos
lipo -create temp-macos-arm64/mgconsole temp-macos-x86_64/mgconsole -output macos/mgconsole
- name: List architecture of the binary
run: |
lipo -info macos/mgconsole
- name: Save mgconsole MacOS universal build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole MacOS universal build"
path: macos/mgconsole
build_and_test_static:
if: ${{ inputs.build-static }}
name: Build and test mgconsole static build
strategy:
fail-fast: false
matrix:
arch: [X64, ARM64]
runs-on: [self-hosted, Linux, "${{ matrix.arch }}" ]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: build mgconsole static
run: |
./build-generic-linux.sh
- name: Save mgconsole static build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: "mgconsole static Linux build ${{ matrix.arch }}"
path: build/generic/mgconsole
- name: Pull latest memgraph image
run: |
docker pull memgraph/memgraph:latest
echo "MEMGRAPH_IMAGE=memgraph/memgraph:latest" >> $GITHUB_ENV
- name: Test mgconsole static build
run: |
./tests/test-static.sh --docker $MEMGRAPH_IMAGE
./tests/test-static.sh --use-ssl --docker $MEMGRAPH_IMAGE
- name: Cleanup docker images
run: |
docker rmi $MEMGRAPH_IMAGE || true
if [[ "${{ matrix.arch }}" == "X64" ]]; then
docker rmi memgraph/mgbuild:v7_centos-9 || true
elif [[ "${{ matrix.arch }}" == "ARM64" ]]; then
docker rmi memgraph/mgbuild:v7_debian-12-arm || true
fi
docker_build_and_test:
name: Build and test mgconsole in Docker container
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build and test mgconsole in Docker container
run: |
docker build -t mgconsole .
- name: Run latest Memgraph Docker container
run: |
docker run --rm -d --name memgraph --network host memgraph/memgraph:latest --telemetry-enabled=false
- name: Wait for Memgraph Bolt
run: |
host=127.0.0.1
port=7687
max_attempts=120
delay=1
for attempt in $(seq 1 "$max_attempts"); do
if bash -c "echo >/dev/tcp/${host}/${port}" 2>/dev/null; then
echo "Memgraph Bolt port open at ${host}:${port}"
exit 0
fi
sleep "$delay"
done
echo "Timeout waiting for Memgraph Bolt at ${host}:${port}"
exit 1
- name: Test mgconsole in Docker container
run: |
# Test pipe directly into docker run
echo "RETURN 1;" | docker run --network host mgconsole:latest
# Test entrypoint override with echo
docker run --network host --rm --entrypoint sh mgconsole:latest -c "echo 'RETURN 1;' | mgconsole"
- name: Cleanup docker images
run: |
docker rmi mgconsole || true
docker stop memgraph || true
docker rm memgraph || true
docker rmi memgraph/memgraph:latest || true