From 028d8e1da04ded5ee691b731c750f6312e5aa2ce Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sat, 17 Aug 2024 14:09:58 +0200 Subject: [PATCH] fix CI (#6) --- .github/FUNDING.yml | 1 - Makefile | 2 ++ scripts/format.mk | 2 +- scripts/lint.mk | 2 +- scripts/test.mk | 19 ++++++++++++++++++- test/Makefile | 34 ---------------------------------- test/Makefile.src | 5 ++--- 7 files changed, 24 insertions(+), 41 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 test/Makefile diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 4a83b95..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ["https://www.buymeacoffee.com/aler9"] diff --git a/Makefile b/Makefile index 65cfc5b..926fe77 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +RPI_IMAGE = balenalib/raspberry-pi:bullseye +UBUNTU_IMAGE = ubuntu:22.04 .PHONY: $(shell ls) diff --git a/scripts/format.mk b/scripts/format.mk index d1e981c..e52a2fa 100644 --- a/scripts/format.mk +++ b/scripts/format.mk @@ -1,5 +1,5 @@ define DOCKERFILE_FORMAT -FROM ubuntu:20.04 +FROM $(UBUNTU_IMAGE) RUN apt update && apt install -y --no-install-recommends \ clang-format diff --git a/scripts/lint.mk b/scripts/lint.mk index 4a999ca..6f0494a 100644 --- a/scripts/lint.mk +++ b/scripts/lint.mk @@ -1,5 +1,5 @@ define DOCKERFILE_LINT -FROM ubuntu:20.04 +FROM $(UBUNTU_IMAGE) RUN apt update && apt install -y --no-install-recommends \ clang-format diff --git a/scripts/test.mk b/scripts/test.mk index cc73265..bf396fd 100644 --- a/scripts/test.mk +++ b/scripts/test.mk @@ -1,2 +1,19 @@ +define DOCKERFILE_TEST +FROM $(RPI_IMAGE) +RUN apt-get update && apt-get install -y --no-install-recommends \ + make \ + gcc \ + libc6-dev \ + libi2c-dev +WORKDIR /s +COPY . . +RUN make test-nodocker +endef +export DOCKERFILE_TEST + test: - cd test && make build-cross + docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes >/dev/null + echo "$$DOCKERFILE_TEST" | docker build . -f - -t temp + +test-nodocker: + @$(MAKE) -C test -f Makefile.src diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index cbde82f..0000000 --- a/test/Makefile +++ /dev/null @@ -1,34 +0,0 @@ - -all: build-cross - -build-direct: - @$(MAKE) -f Makefile.src - -define DOCKERFILE -FROM balenalib/raspberry-pi-debian:stretch -RUN apt-get update && apt-get install -y --no-install-recommends \ - make \ - gcc \ - libc6-dev \ - libi2c-dev -WORKDIR /s -COPY *.h *.c ./ -COPY test ./test -WORKDIR ./test -RUN make build-direct -endef -export DOCKERFILE - -build-cross: - docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes >/dev/null - echo "$$DOCKERFILE" | docker build ../ -f - -t temp - -TARGET ?= pi@192.168.2.170 -BIN = test-imu - -deploy: build-cross - ssh $(TARGET) "killall $(BIN) || exit 0" - docker run --rm temp cat /s/test/$(BIN) \ - | ssh $(TARGET) "tee ./$(BIN) >/dev/null" - ssh $(TARGET) "chmod +x ./$(BIN)" - ssh $(TARGET) "./$(BIN)" diff --git a/test/Makefile.src b/test/Makefile.src index 69ecfc5..7b698d5 100644 --- a/test/Makefile.src +++ b/test/Makefile.src @@ -1,4 +1,3 @@ - BIN = test-imu OBJECTS = \ @@ -16,7 +15,7 @@ LDFLAGS += all: $(BIN) $(BIN): $(OBJECTS) - gcc $(OBJECTS) $(LDFLAGS) -o $@ + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ %.o: %.c - gcc $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@