Skip to content

Commit

Permalink
Fix GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
infertux committed Dec 7, 2023
1 parent 0051a0b commit 227756f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -15,12 +15,12 @@ growatt: $(SRCS)
$(CC) $(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)
test: growatt $(TESTS)
$(CC) -Wall -Werror -o tests/mock-server $(TESTS) $(shell pkg-config --libs --cflags libmodbus)
./tests/mock-server &
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
Expand Down
3 changes: 2 additions & 1 deletion src/modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <modbus.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <threads.h>
#include <time.h>
#include <unistd.h> // sleep()
Expand Down Expand Up @@ -400,7 +401,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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 227756f

Please sign in to comment.