Skip to content

Commit

Permalink
Add modularity checks in CI (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored Nov 6, 2023
1 parent 2ee5282 commit 972fff3
Show file tree
Hide file tree
Showing 59 changed files with 470 additions and 54 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (c) 2022 ZettaScale Technology
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# ZettaScale Zenoh Team, <[email protected]>
#
name: build-check

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

jobs:
modular_build:
name: Modular build on ubuntu-latest
runs-on: ubuntu-latest
strategy:
matrix:
feature_publication: [1, 0]
feature_subscription: [1, 0]
feature_queryable: [1, 0]
feature_query: [1, 0]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run docker image
run: docker run --name zenoh_router --init --net host -d eclipse/zenoh:master

- name: Build project
run: |
make all
python3 ./build/tests/modularity.py --pub $Z_FEATURE_PUBLICATION --sub $Z_FEATURE_SUBSCRIPTION --queryable $Z_FEATURE_QUERYABLE --query $Z_FEATURE_QUERY
timeout-minutes: 5
env:
Z_FEATURE_PUBLICATION: ${{ matrix.feature_publication }}
Z_FEATURE_SUBSCRIPTION: ${{ matrix.feature_subscription }}
Z_FEATURE_QUERYABLE: ${{ matrix.feature_queryable }}
Z_FEATURE_QUERY: ${{ matrix.feature_query }}

- name: Stop docker image
if: always()
run: |
docker stop zenoh_router
docker rm zenoh_router
2 changes: 1 addition & 1 deletion .github/workflows/build-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
env:
BUILD_TYPE: Debug
BUILD_SHARED_LIBS: ON
ZENOH_DEBUG: 3
ZENOH_DEBUG: 3
5 changes: 5 additions & 0 deletions .github/workflows/freertos_plus_tcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ jobs:
cmake -Bbuild -G"Ninja Multi-Config"
cmake --build ./build --config Debug
cmake --build ./build --config Release
env:
Z_FEATURE_PUBLICATION: 1
Z_FEATURE_SUBSCRIPTION: 1
Z_FEATURE_QUERYABLE: 1
Z_FEATURE_QUERY: 1
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ endif()

add_definition(ZENOH_DEBUG=${ZENOH_DEBUG})

# Zenoh pico feature configuration options
option(Z_FEATURE_PUBLICATION "Toggle publication feature" 1)
option(Z_FEATURE_SUBSCRIPTION "Toggle subscription feature" 1)
option(Z_FEATURE_QUERY "Toggle query feature" 1)
option(Z_FEATURE_QUERYABLE "Toggle queryable feature" 1)
add_definition(Z_FEATURE_PUBLICATION=${Z_FEATURE_PUBLICATION})
add_definition(Z_FEATURE_SUBSCRIPTION=${Z_FEATURE_SUBSCRIPTION})
add_definition(Z_FEATURE_QUERY=${Z_FEATURE_QUERY})
add_definition(Z_FEATURE_QUERYABLE=${Z_FEATURE_QUERYABLE})
message(STATUS "Building with feature confing:\n\
* PUBLICATION: ${Z_FEATURE_PUBLICATION}\n\
* SUBSCRIPTION: ${Z_FEATURE_SUBSCRIPTION}\n\
* QUERY: ${Z_FEATURE_QUERY}\n\
* QUERYABLE: ${Z_FEATURE_QUERYABLE}")

# Print summary of CMAKE configurations
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
Expand Down Expand Up @@ -284,6 +299,8 @@ if(UNIX OR MSVC)
target_link_libraries(z_api_null_drop_test ${Libname})
target_link_libraries(z_api_double_drop_test ${Libname})

configure_file(${PROJECT_SOURCE_DIR}/tests/modularity.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/modularity.py COPYONLY)

enable_testing()
add_test(z_data_struct_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_data_struct_test)
add_test(z_endpoint_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_endpoint_test)
Expand Down
11 changes: 10 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ BUILD_TOOLS?=OFF
# 3: DEBUG + INFO + ERROR
ZENOH_DEBUG?=0

# Feature config toggle
# Accepted values: 0, 1
Z_FEATURE_PUBLICATION?=1
Z_FEATURE_SUBSCRIPTION?=1
Z_FEATURE_QUERY?=1
Z_FEATURE_QUERYABLE?=1

# zenoh-pico/ directory
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

Expand All @@ -58,7 +65,9 @@ CROSSIMG_PREFIX=zenoh-pico_
# NOTES:
# - 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)

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.
CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_MULTICAST=$(BUILD_MULTICAST)\
-DZ_FEATURE_PUBLICATION=$(Z_FEATURE_PUBLICATION) -DZ_FEATURE_SUBSCRIPTION=$(Z_FEATURE_SUBSCRIPTION) -DZ_FEATURE_QUERY=$(Z_FEATURE_QUERY) -DZ_FEATURE_QUERYABLE=$(Z_FEATURE_QUERYABLE)\
-DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.

all: make

Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define configUSE_PREEMPTION 1
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES (56)
#define configMINIMAL_STACK_SIZE ((uint16_t) PTHREAD_STACK_MIN)
#define configMINIMAL_STACK_SIZE ((uint16_t)PTHREAD_STACK_MIN)
#define configMAX_TASK_NAME_LEN (16)
#define configUSE_16_BIT_TICKS 0
#define configQUEUE_REGISTRY_SIZE 0
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set ipconfigBUFFER_PADDING on 64-bit platforms
#if INTPTR_MAX == INT64_MAX
#define ipconfigBUFFER_PADDING 14U
#define ipconfigBUFFER_PADDING 14U
#endif

#endif /* FREERTOS_IP_CONFIG_H */
10 changes: 8 additions & 2 deletions examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

#if Z_FEATURE_QUERY == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -47,7 +48,7 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) {
}
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -92,4 +93,9 @@ void app_main() {
zp_stop_lease_task(z_loan(s));

z_close(z_move(s));
}
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -104,3 +105,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -72,3 +73,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -77,3 +78,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -74,3 +75,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

#if Z_FEATURE_QUERYABLE == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -43,7 +44,7 @@ void query_handler(const z_query_t *query, void *ctx) {
z_drop(z_move(keystr));
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -89,3 +90,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
}
#endif
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void drop(void *context) {
}
}

void app_main() {
void app_main(void) {
int *context = (int *)pvPortMalloc(sizeof(int));
*context = 0;
z_owned_scouting_config_t config = z_scouting_config_default();
Expand Down
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -75,3 +76,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

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

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -67,3 +68,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif
2 changes: 1 addition & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ int main(int argc, char **argv) {
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it\n");
return -1;
return -2;
}
#endif
2 changes: 1 addition & 1 deletion examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ int main(int argc, char **argv) {
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
return -1;
return -2;
}
#endif
2 changes: 1 addition & 1 deletion examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ int main(int argc, char **argv) {
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
return -2;
}
#endif
Loading

0 comments on commit 972fff3

Please sign in to comment.