From 3fe4c31e8e0dc94493981cce6fb1cc61ec07ae17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20F=C3=A9lizard?= Date: Thu, 7 Dec 2023 02:47:21 +0000 Subject: [PATCH] Fix GitHub workflow --- .github/workflows/make.yml | 2 +- Makefile | 18 +++++++++--------- src/modbus.h | 2 +- src/mqtt.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index afc7cfe..066e45e 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v3 - uses: awalsh128/cache-apt-pkgs-action@latest with: - packages: clang libbsd-dev libmodbus-dev libmosquitto-dev + packages: clang libbsd-dev libmodbus-dev libmosquitto-dev mosquitto-clients - name: make run: make - name: make lint diff --git a/Makefile b/Makefile index 5149676..70f714d 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ CC=clang RM=rm -fv CFLAGS=$(shell pkg-config --cflags libbsd libmodbus libmosquitto) LIBS=$(shell pkg-config --libs libbsd libmodbus libmosquitto) -pthread - -SRCS=src/*.c src/*.h +SRCS=src/* +TESTS=tests/*.c all: growatt @@ -12,18 +12,18 @@ doc: $(SRCS) doxygen .doxygen growatt: $(SRCS) - $(CC) $(CFLAGS) $(LIBS) -Wall -Werror -O3 -o growatt src/*.c + $(CC) -v $(CFLAGS) $(LIBS) -Wall -Werror -O3 -o growatt src/*.c lint: - clang-format --verbose --Werror -i --style=file src/*.{c,h} tests/*.c - clang-tidy --checks='*,-altera-id-dependent-backward-branch,-altera-unroll-loops,-bugprone-assignment-in-if-condition,-cert-err33-c,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-cppcoreguidelines-avoid-magic-numbers,-llvm-header-guard,-llvmlibc-restrict-system-libc-headers,-readability-function-cognitive-complexity' --format-style=llvm src/*.{c,h} tests/*.c -- $(CFLAGS) + clang-format --verbose --Werror -i --style=file $(SRCS) $(TESTS) + clang-tidy --checks='*,-altera-id-dependent-backward-branch,-altera-unroll-loops,-bugprone-assignment-in-if-condition,-cert-err33-c,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-cppcoreguidelines-avoid-magic-numbers,-llvm-header-guard,-llvmlibc-restrict-system-libc-headers,-readability-function-cognitive-complexity' --format-style=llvm $(SRCS) $(TESTS) -- $(CFLAGS) .PHONY: lint -test: growatt tests/*.c - $(CC) -Wall -Werror -o tests/mock-server tests/*.c $(shell pkg-config --libs --cflags libmodbus) - ./tests/mock-server & +test: growatt $(TESTS) + $(CC) -v $(shell pkg-config --libs --cflags libbsd libmodbus) -Wall -Werror -o tests/mock-server $(TESTS) timeout 30 mosquitto_sub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t homeassistant/sensor/growatt/state -d & - ./growatt 127.0.0.1:1502 --prometheus 1234 --mqtt test.mosquitto.org 1884 wo writeonly + ./tests/mock-server & + ./growatt 127.0.0.1:1502 --prometheus 1234 --mqtt test.mosquitto.org 1884 wo writeonly || true clean: $(RM) growatt tests/mock-server diff --git a/src/modbus.h b/src/modbus.h index d901b03..0793cb1 100644 --- a/src/modbus.h +++ b/src/modbus.h @@ -400,7 +400,7 @@ int start_modbus_thread(char device_or_uri[static 1]) { LOG(LOG_INFO, "Waiting %d seconds...", REFRESH_PERIOD); for (size_t i = 0; i < REFRESH_PERIOD; i++) { - sleep(REFRESH_PERIOD); // NOLINT(concurrency-mt-unsafe) + sleep(1); // NOLINT(concurrency-mt-unsafe) if (!keep_running) { return EXIT_SUCCESS; } diff --git a/src/mqtt.h b/src/mqtt.h index e8c8463..8f4631f 100644 --- a/src/mqtt.h +++ b/src/mqtt.h @@ -173,7 +173,7 @@ int start_mqtt_thread(void *config_ptr) { LOG(LOG_DEBUG, "Waiting %u seconds...", PUBLISH_PERIOD); for (size_t i = 0; i < PUBLISH_PERIOD; i++) { - sleep(PUBLISH_PERIOD); // NOLINT(concurrency-mt-unsafe) + sleep(1); // NOLINT(concurrency-mt-unsafe) if (!keep_running) { return EXIT_SUCCESS; }