Skip to content

Commit eec4c4a

Browse files
authored
CI: move dependencies build to a separate workflow (#530)
Signed-off-by: Evgeny Malygin <[email protected]>
1 parent e86bea8 commit eec4c4a

File tree

2 files changed

+110
-54
lines changed

2 files changed

+110
-54
lines changed

.github/workflows/build.yaml

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,64 +13,22 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16-
build_dependencies:
17-
name: Build deps [ubuntu]
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
- name: Get dependencies hash
22-
id: get-hash
23-
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT
24-
- name: Cache lookup
25-
uses: actions/cache/restore@v4
26-
id: cache-lookup
27-
with:
28-
path: deps
29-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
30-
lookup-only: true
31-
- name: Set up dependencies
32-
if: steps.cache-lookup.outputs.cache-hit != 'true'
33-
run: |
34-
sudo apt-get update
35-
sudo apt-get install -qy build-essential \
36-
gdb \
37-
curl \
38-
python3.10 \
39-
python3-pip \
40-
cmake \
41-
ninja-build \
42-
pkg-config \
43-
bison \
44-
libfl-dev \
45-
libbenchmark-dev \
46-
libgmock-dev \
47-
libz-dev
48-
- name: Fetch & Build non packaged dependencies
49-
if: steps.cache-lookup.outputs.cache-hit != 'true'
50-
run: |
51-
mkdir -p deps
52-
cd deps
53-
../docker/build_deps.sh
54-
- name: Cache save
55-
if: steps.cache-lookup.outputs.cache-hit != 'true'
56-
uses: actions/cache/save@v4
57-
with:
58-
path: deps
59-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
16+
get_dependencies:
17+
name: "Dependencies"
18+
uses: ./.github/workflows/dependencies.yaml
6019

6120
build_ubuntu:
6221
name: Build [ubuntu]
6322
runs-on: ubuntu-latest
64-
needs: build_dependencies
23+
needs: get_dependencies
6524
steps:
6625
- uses: actions/checkout@v4
67-
- name: Get dependencies hash
68-
id: get-hash
69-
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT
26+
7027
- uses: actions/cache/restore@v4
7128
with:
7229
path: deps
73-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
30+
key: ${{ needs.get_dependencies.outputs.cache_key }}
31+
7432
- name: Set up dependencies
7533
run: |
7634
sudo apt-get update
@@ -87,9 +45,11 @@ jobs:
8745
libbenchmark-dev \
8846
libgmock-dev \
8947
libz-dev
48+
9049
- name: Install cached non packaged dependencies
9150
working-directory: deps
9251
run: ../docker/build_deps.sh
52+
9353
- name: Build BlazingMQ
9454
env:
9555
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig
@@ -103,10 +63,12 @@ jobs:
10363
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/srcs/bde-tools/BdeBuildSystem \
10464
-DCMAKE_INSTALL_LIBDIR=lib64
10565
cmake --build build/blazingmq --parallel 8 --target all
66+
10667
- name: Clean-up build directories before caching
10768
run: |
10869
find . -name "*.o" -type f -delete
10970
find . -name "*.a" -type f -delete
71+
11072
- uses: actions/cache@v4
11173
with:
11274
path: |
@@ -118,16 +80,15 @@ jobs:
11880
unit_tests_cxx:
11981
name: UT [c++]
12082
runs-on: ubuntu-latest
121-
needs: build_dependencies
83+
needs: get_dependencies
12284
steps:
12385
- uses: actions/checkout@v4
124-
- name: Get dependencies hash
125-
id: get-hash
126-
run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT
86+
12787
- uses: actions/cache/restore@v4
12888
with:
12989
path: deps
130-
key: deps-${{ steps.get-hash.outputs.deps_hash }}
90+
key: ${{ needs.get_dependencies.outputs.cache_key }}
91+
13192
- name: Set up dependencies
13293
run: |
13394
sudo apt-get update
@@ -144,9 +105,11 @@ jobs:
144105
libbenchmark-dev \
145106
libgmock-dev \
146107
libz-dev
108+
147109
- name: Install cached non packaged dependencies
148110
working-directory: deps
149111
run: ../docker/build_deps.sh
112+
150113
- name: Build BlazingMQ UTs
151114
env:
152115
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig
@@ -160,6 +123,7 @@ jobs:
160123
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/srcs/bde-tools/BdeBuildSystem \
161124
-DCMAKE_INSTALL_LIBDIR=lib64
162125
cmake --build build/blazingmq --parallel 8 --target all.t
126+
163127
- name: Run C++ Unit Tests
164128
run: |
165129
cd ${{ github.workspace }}/build/blazingmq
@@ -171,13 +135,15 @@ jobs:
171135
needs: build_ubuntu
172136
steps:
173137
- uses: actions/checkout@v4
138+
174139
- uses: actions/cache/@v4
175140
with:
176141
path: |
177142
build/blazingmq
178143
deps
179144
/opt/bb/include
180145
key: cache-${{ github.sha }}
146+
181147
- name: Run Python Unit Tests
182148
env:
183149
PYTHONPATH: ${{ github.workspace }}/src/python
@@ -200,13 +166,15 @@ jobs:
200166
needs: build_ubuntu
201167
steps:
202168
- uses: actions/checkout@v4
169+
203170
- uses: actions/cache/@v4
204171
with:
205172
path: |
206173
build/blazingmq
207174
deps
208175
/opt/bb/include
209176
key: cache-${{ github.sha }}
177+
210178
- name: Run Integration Tests
211179
run: |
212180
pip install -r ${{ github.workspace }}/src/python/requirements.txt
@@ -239,13 +207,15 @@ jobs:
239207
needs: build_ubuntu
240208
steps:
241209
- uses: actions/checkout@v4
210+
242211
- uses: actions/cache/@v4
243212
with:
244213
path: |
245214
build/blazingmq
246215
deps
247216
/opt/bb/include
248217
key: cache-${{ github.sha }}
218+
249219
- name: Run Fuzz Test
250220
run: |
251221
pip install -r ${{ github.workspace }}/src/python/requirements.txt
@@ -262,6 +232,7 @@ jobs:
262232
arch: arm64
263233
steps:
264234
- uses: actions/checkout@v4
235+
265236
- name: Set up dependencies
266237
run: |
267238
brew install \
@@ -271,6 +242,7 @@ jobs:
271242
bison \
272243
flex \
273244
google-benchmark
245+
274246
- name: Build BlazingMQ
275247
run: bin/build-darwin.sh
276248

@@ -280,13 +252,15 @@ jobs:
280252
needs: build_ubuntu
281253
steps:
282254
- uses: actions/checkout@v4
255+
283256
- uses: actions/cache/@v4
284257
with:
285258
path: |
286259
build/blazingmq
287260
deps
288261
/opt/bb/include
289262
key: cache-${{ github.sha }}
263+
290264
- name: Set up plugins dependencies
291265
run: |
292266
sudo apt-get update
@@ -304,11 +278,14 @@ jobs:
304278
libz-dev \
305279
autoconf \
306280
libtool
281+
307282
- name: Create dependency fetcher working directory
308283
run: mkdir -p deps
284+
309285
- name: Fetch & Build non packaged plugins dependencies
310286
working-directory: deps
311287
run: ${{ github.workspace }}/src/plugins/bmqprometheus/build_prometheus_deps.sh
288+
312289
- name: Build plugins
313290
env:
314291
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig
@@ -323,23 +300,30 @@ jobs:
323300
-DCMAKE_INSTALL_LIBDIR=lib64 \
324301
-DINSTALL_TARGETS=prometheus
325302
cmake --build build/blazingmq --parallel 8 --target all
303+
326304
- name: Create prometheus dir
327305
run: mkdir -p prometheus_dir
306+
328307
- name: Download Prometheus
329308
run: curl -SL "https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gz" | tar -xzC prometheus_dir/
309+
330310
- name: Run Prometheus
331311
run: ./prometheus_dir/prometheus-2.45.1.linux-amd64/prometheus --config.file=${{ github.workspace }}/src/plugins/bmqprometheus/tests/prometheus_localhost.yaml --web.enable-lifecycle --storage.tsdb.path=${{ github.workspace }}/prometheus_dir/data &
312+
332313
- name: Run Pushgateway
333314
run: |
334315
docker pull prom/pushgateway
335316
docker run -d -p 9091:9091 prom/pushgateway
317+
336318
- name: Run BMQPrometheus plugin integration test in "pull" mode
337319
run: ${{ github.workspace }}/src/plugins/bmqprometheus/tests/bmqprometheus_prometheusstatconsumer_test.py -p ${{ github.workspace }}/build/blazingmq -m pull --no-docker
320+
338321
- name: Clear Prometheus database and restart
339322
run: |
340323
curl -X POST "http://localhost:9090/-/quit"
341324
rm -rf prometheus_dir/data
342325
./prometheus_dir/prometheus-2.45.1.linux-amd64/prometheus --config.file=${{ github.workspace }}/src/plugins/bmqprometheus/tests/prometheus_localhost.yaml --web.enable-lifecycle --storage.tsdb.path=${{ github.workspace }}/prometheus_dir/data &
326+
343327
- name: Run Prometheus plugin integration test in "push" mode
344328
run: ${{ github.workspace }}/src/plugins/bmqprometheus/tests/bmqprometheus_prometheusstatconsumer_test.py -p ${{ github.workspace }}/build/blazingmq -m push --no-docker
345329

@@ -348,13 +332,16 @@ jobs:
348332
runs-on: ubuntu-latest
349333
steps:
350334
- uses: actions/checkout@v4
335+
351336
- name: Set up dependencies
352337
run: |
353338
sudo apt-get update
354339
sudo apt-get install -qy doxygen
340+
355341
- name: Set up output directory
356342
run: |
357343
mkdir -p docs/docs/apidocs
344+
358345
- name: Build docs
359346
run: |
360347
doxygen Doxyfile
@@ -364,6 +351,7 @@ jobs:
364351
runs-on: ubuntu-latest
365352
steps:
366353
- uses: actions/checkout@v4
354+
367355
- name: Run ShellCheck
368356
uses: ludeeus/action-shellcheck@master
369357

@@ -372,7 +360,9 @@ jobs:
372360
runs-on: ubuntu-latest
373361
steps:
374362
- uses: actions/checkout@v4
363+
375364
- name: Docker Single-Node Workflow
376365
run: docker compose -f docker/single-node/docker-compose.yaml up --build -d
366+
377367
- name: Docker Cluster Workflow
378368
run: docker compose -f docker/cluster/docker-compose.yaml up --build -d
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Dependencies
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
cache_key:
7+
description: "GH Actions Cache key associated with the built dependencies"
8+
value: ${{ jobs.build_dependencies.outputs.cache_key }}
9+
10+
concurrency:
11+
group: deps-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build_dependencies:
16+
name: Build [ubuntu]
17+
runs-on: ubuntu-latest
18+
outputs:
19+
cache_key: ${{ steps.get-cache-key.outputs.cache_key }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Generate dependencies cache key
24+
id: get-cache-key
25+
run: |
26+
echo "cache_key=deps-`date +%y-%m-%d`-`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT
27+
28+
- name: Cache lookup
29+
uses: actions/cache/restore@v4
30+
id: cache-lookup
31+
with:
32+
path: deps
33+
key: ${{ steps.get-cache-key.outputs.cache_key }}
34+
lookup-only: true
35+
36+
- name: Set up build dependencies
37+
if: steps.cache-lookup.outputs.cache-hit != 'true'
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -qy build-essential \
41+
gdb \
42+
curl \
43+
python3.10 \
44+
python3-pip \
45+
cmake \
46+
ninja-build \
47+
pkg-config \
48+
bison \
49+
libfl-dev \
50+
libbenchmark-dev \
51+
libgmock-dev \
52+
libz-dev
53+
54+
- name: Fetch & build non packaged dependencies
55+
if: steps.cache-lookup.outputs.cache-hit != 'true'
56+
run: |
57+
mkdir -p deps
58+
cd deps
59+
../docker/build_deps.sh
60+
61+
- name: Cache save
62+
if: steps.cache-lookup.outputs.cache-hit != 'true'
63+
uses: actions/cache/save@v4
64+
with:
65+
path: deps
66+
key: ${{ steps.get-cache-key.outputs.cache_key }}

0 commit comments

Comments
 (0)