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 3fe4c31
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ 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

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
2 changes: 1 addition & 1 deletion src/modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
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 3fe4c31

Please sign in to comment.