Skip to content

Commit 972fff3

Browse files
authored
Add modularity checks in CI (#268)
1 parent 2ee5282 commit 972fff3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+470
-54
lines changed

.github/workflows/build-check.yaml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Copyright (c) 2022 ZettaScale Technology
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Eclipse Public License 2.0 which is available at
6+
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
8+
#
9+
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10+
#
11+
# Contributors:
12+
# ZettaScale Zenoh Team, <[email protected]>
13+
#
14+
name: build-check
15+
16+
on:
17+
push:
18+
branches: [ '**' ]
19+
pull_request:
20+
branches: [ '**' ]
21+
22+
jobs:
23+
modular_build:
24+
name: Modular build on ubuntu-latest
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
feature_publication: [1, 0]
29+
feature_subscription: [1, 0]
30+
feature_queryable: [1, 0]
31+
feature_query: [1, 0]
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Run docker image
37+
run: docker run --name zenoh_router --init --net host -d eclipse/zenoh:master
38+
39+
- name: Build project
40+
run: |
41+
make all
42+
python3 ./build/tests/modularity.py --pub $Z_FEATURE_PUBLICATION --sub $Z_FEATURE_SUBSCRIPTION --queryable $Z_FEATURE_QUERYABLE --query $Z_FEATURE_QUERY
43+
timeout-minutes: 5
44+
env:
45+
Z_FEATURE_PUBLICATION: ${{ matrix.feature_publication }}
46+
Z_FEATURE_SUBSCRIPTION: ${{ matrix.feature_subscription }}
47+
Z_FEATURE_QUERYABLE: ${{ matrix.feature_queryable }}
48+
Z_FEATURE_QUERY: ${{ matrix.feature_query }}
49+
50+
- name: Stop docker image
51+
if: always()
52+
run: |
53+
docker stop zenoh_router
54+
docker rm zenoh_router

.github/workflows/build-shared.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ jobs:
5050
env:
5151
BUILD_TYPE: Debug
5252
BUILD_SHARED_LIBS: ON
53-
ZENOH_DEBUG: 3
53+
ZENOH_DEBUG: 3

.github/workflows/freertos_plus_tcp.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ jobs:
4040
cmake -Bbuild -G"Ninja Multi-Config"
4141
cmake --build ./build --config Debug
4242
cmake --build ./build --config Release
43+
env:
44+
Z_FEATURE_PUBLICATION: 1
45+
Z_FEATURE_SUBSCRIPTION: 1
46+
Z_FEATURE_QUERYABLE: 1
47+
Z_FEATURE_QUERY: 1

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ endif()
102102

103103
add_definition(ZENOH_DEBUG=${ZENOH_DEBUG})
104104

105+
# Zenoh pico feature configuration options
106+
option(Z_FEATURE_PUBLICATION "Toggle publication feature" 1)
107+
option(Z_FEATURE_SUBSCRIPTION "Toggle subscription feature" 1)
108+
option(Z_FEATURE_QUERY "Toggle query feature" 1)
109+
option(Z_FEATURE_QUERYABLE "Toggle queryable feature" 1)
110+
add_definition(Z_FEATURE_PUBLICATION=${Z_FEATURE_PUBLICATION})
111+
add_definition(Z_FEATURE_SUBSCRIPTION=${Z_FEATURE_SUBSCRIPTION})
112+
add_definition(Z_FEATURE_QUERY=${Z_FEATURE_QUERY})
113+
add_definition(Z_FEATURE_QUERYABLE=${Z_FEATURE_QUERYABLE})
114+
message(STATUS "Building with feature confing:\n\
115+
* PUBLICATION: ${Z_FEATURE_PUBLICATION}\n\
116+
* SUBSCRIPTION: ${Z_FEATURE_SUBSCRIPTION}\n\
117+
* QUERY: ${Z_FEATURE_QUERY}\n\
118+
* QUERYABLE: ${Z_FEATURE_QUERYABLE}")
119+
105120
# Print summary of CMAKE configurations
106121
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
107122
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
@@ -284,6 +299,8 @@ if(UNIX OR MSVC)
284299
target_link_libraries(z_api_null_drop_test ${Libname})
285300
target_link_libraries(z_api_double_drop_test ${Libname})
286301

302+
configure_file(${PROJECT_SOURCE_DIR}/tests/modularity.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/modularity.py COPYONLY)
303+
287304
enable_testing()
288305
add_test(z_data_struct_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_data_struct_test)
289306
add_test(z_endpoint_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_endpoint_test)

GNUmakefile

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ BUILD_TOOLS?=OFF
4545
# 3: DEBUG + INFO + ERROR
4646
ZENOH_DEBUG?=0
4747

48+
# Feature config toggle
49+
# Accepted values: 0, 1
50+
Z_FEATURE_PUBLICATION?=1
51+
Z_FEATURE_SUBSCRIPTION?=1
52+
Z_FEATURE_QUERY?=1
53+
Z_FEATURE_QUERYABLE?=1
54+
4855
# zenoh-pico/ directory
4956
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
5057

@@ -58,7 +65,9 @@ CROSSIMG_PREFIX=zenoh-pico_
5865
# NOTES:
5966
# - ARM: old versions of dockcross/dockcross were creating some issues since they used an old GCC (4.8.3) which lacks <stdatomic.h> (even using -std=gnu11)
6067

61-
CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_MULTICAST=$(BUILD_MULTICAST) -DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.
68+
CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_MULTICAST=$(BUILD_MULTICAST)\
69+
-DZ_FEATURE_PUBLICATION=$(Z_FEATURE_PUBLICATION) -DZ_FEATURE_SUBSCRIPTION=$(Z_FEATURE_SUBSCRIPTION) -DZ_FEATURE_QUERY=$(Z_FEATURE_QUERY) -DZ_FEATURE_QUERYABLE=$(Z_FEATURE_QUERYABLE)\
70+
-DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.
6271

6372
all: make
6473

examples/freertos_plus_tcp/include/FreeRTOSConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define configUSE_PREEMPTION 1
2121
#define configTICK_RATE_HZ ((TickType_t)1000)
2222
#define configMAX_PRIORITIES (56)
23-
#define configMINIMAL_STACK_SIZE ((uint16_t) PTHREAD_STACK_MIN)
23+
#define configMINIMAL_STACK_SIZE ((uint16_t)PTHREAD_STACK_MIN)
2424
#define configMAX_TASK_NAME_LEN (16)
2525
#define configUSE_16_BIT_TICKS 0
2626
#define configQUEUE_REGISTRY_SIZE 0

examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
// Set ipconfigBUFFER_PADDING on 64-bit platforms
5050
#if INTPTR_MAX == INT64_MAX
51-
#define ipconfigBUFFER_PADDING 14U
51+
#define ipconfigBUFFER_PADDING 14U
5252
#endif
5353

5454
#endif /* FREERTOS_IP_CONFIG_H */

examples/freertos_plus_tcp/z_get.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "FreeRTOS.h"
1818

19+
#if Z_FEATURE_QUERY == 1
1920
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
2021
#if CLIENT_OR_PEER == 0
2122
#define MODE "client"
@@ -47,7 +48,7 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) {
4748
}
4849
}
4950

50-
void app_main() {
51+
void app_main(void) {
5152
z_owned_config_t config = z_config_default();
5253
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
5354
if (strcmp(CONNECT, "") != 0) {
@@ -92,4 +93,9 @@ void app_main() {
9293
zp_stop_lease_task(z_loan(s));
9394

9495
z_close(z_move(s));
95-
}
96+
}
97+
#else
98+
void app_main(void) {
99+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
100+
}
101+
#endif

examples/freertos_plus_tcp/z_pub.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "FreeRTOS.h"
1818

19+
#if Z_FEATURE_PUBLICATION == 1
1920
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
2021
#if CLIENT_OR_PEER == 0
2122
#define MODE "client"
@@ -30,7 +31,7 @@
3031
#define KEYEXPR "demo/example/zenoh-pico-pub"
3132
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"
3233

33-
void app_main() {
34+
void app_main(void) {
3435
z_owned_config_t config = z_config_default();
3536
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
3637
if (strcmp(CONNECT, "") != 0) {
@@ -104,3 +105,8 @@ void app_main() {
104105

105106
z_close(z_move(s));
106107
}
108+
#else
109+
void app_main(void) {
110+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
111+
}
112+
#endif

examples/freertos_plus_tcp/z_pub_st.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "FreeRTOS.h"
1818

19+
#if Z_FEATURE_PUBLICATION == 1
1920
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
2021
#if CLIENT_OR_PEER == 0
2122
#define MODE "client"
@@ -30,7 +31,7 @@
3031
#define KEYEXPR "demo/example/zenoh-pico-pub"
3132
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"
3233

33-
void app_main() {
34+
void app_main(void) {
3435
z_owned_config_t config = z_config_default();
3536
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
3637
if (strcmp(CONNECT, "") != 0) {
@@ -72,3 +73,8 @@ void app_main() {
7273

7374
z_close(z_move(s));
7475
}
76+
#else
77+
void app_main(void) {
78+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
79+
}
80+
#endif

examples/freertos_plus_tcp/z_pull.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zenoh-pico.h>
1616

17+
#if Z_FEATURE_PUBLICATION == 1
1718
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
1819
#if CLIENT_OR_PEER == 0
1920
#define MODE "client"
@@ -35,7 +36,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
3536
z_drop(z_move(keystr));
3637
}
3738

38-
void app_main() {
39+
void app_main(void) {
3940
z_owned_config_t config = z_config_default();
4041
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
4142
if (strcmp(CONNECT, "") != 0) {
@@ -77,3 +78,8 @@ void app_main() {
7778

7879
z_close(z_move(s));
7980
}
81+
#else
82+
void app_main(void) {
83+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
84+
}
85+
#endif

examples/freertos_plus_tcp/z_put.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zenoh-pico.h>
1616

17+
#if Z_FEATURE_PUBLICATION == 1
1718
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
1819
#if CLIENT_OR_PEER == 0
1920
#define MODE "client"
@@ -28,7 +29,7 @@
2829
#define KEYEXPR "demo/example/zenoh-pico-put"
2930
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"
3031

31-
void app_main() {
32+
void app_main(void) {
3233
z_owned_config_t config = z_config_default();
3334
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
3435
if (strcmp(CONNECT, "") != 0) {
@@ -74,3 +75,8 @@ void app_main() {
7475

7576
z_close(z_move(s));
7677
}
78+
#else
79+
void app_main(void) {
80+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
81+
}
82+
#endif

examples/freertos_plus_tcp/z_queryable.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zenoh-pico.h>
1616

17+
#if Z_FEATURE_QUERYABLE == 1
1718
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
1819
#if CLIENT_OR_PEER == 0
1920
#define MODE "client"
@@ -43,7 +44,7 @@ void query_handler(const z_query_t *query, void *ctx) {
4344
z_drop(z_move(keystr));
4445
}
4546

46-
void app_main() {
47+
void app_main(void) {
4748
z_owned_config_t config = z_config_default();
4849
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
4950
if (strcmp(CONNECT, "") != 0) {
@@ -89,3 +90,8 @@ void app_main() {
8990

9091
z_close(z_move(s));
9192
}
93+
#else
94+
void app_main(void) {
95+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
96+
}
97+
#endif

examples/freertos_plus_tcp/z_scout.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void drop(void *context) {
8282
}
8383
}
8484

85-
void app_main() {
85+
void app_main(void) {
8686
int *context = (int *)pvPortMalloc(sizeof(int));
8787
*context = 0;
8888
z_owned_scouting_config_t config = z_scouting_config_default();

examples/freertos_plus_tcp/z_sub.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zenoh-pico.h>
1616

17+
#if Z_FEATURE_SUBSCRIPTION == 1
1718
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
1819
#if CLIENT_OR_PEER == 0
1920
#define MODE "client"
@@ -35,7 +36,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
3536
z_drop(z_move(keystr));
3637
}
3738

38-
void app_main() {
39+
void app_main(void) {
3940
z_owned_config_t config = z_config_default();
4041
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
4142
if (strcmp(CONNECT, "") != 0) {
@@ -75,3 +76,8 @@ void app_main() {
7576

7677
z_close(z_move(s));
7778
}
79+
#else
80+
void app_main(void) {
81+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
82+
}
83+
#endif

examples/freertos_plus_tcp/z_sub_st.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <zenoh-pico.h>
1616

17+
#if Z_FEATURE_SUBSCRIPTION == 1
1718
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
1819
#if CLIENT_OR_PEER == 0
1920
#define MODE "client"
@@ -35,7 +36,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
3536
z_drop(z_move(keystr));
3637
}
3738

38-
void app_main() {
39+
void app_main(void) {
3940
z_owned_config_t config = z_config_default();
4041
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
4142
if (strcmp(CONNECT, "") != 0) {
@@ -67,3 +68,8 @@ void app_main() {
6768

6869
z_close(z_move(s));
6970
}
71+
#else
72+
void app_main(void) {
73+
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
74+
}
75+
#endif

examples/mbed/z_get.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ int main(int argc, char **argv) {
9898
#else
9999
int main(void) {
100100
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it\n");
101-
return -1;
101+
return -2;
102102
}
103103
#endif

examples/mbed/z_pub.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ int main(int argc, char **argv) {
8989
#else
9090
int main(void) {
9191
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
92-
return -1;
92+
return -2;
9393
}
9494
#endif

examples/mbed/z_pull.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ int main(int argc, char **argv) {
9595
#else
9696
int main(void) {
9797
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
98-
return -1;
98+
return -2;
9999
}
100100
#endif

0 commit comments

Comments
 (0)