Skip to content

Commit cf9b1f1

Browse files
committed
CI: makefile improvements
- detects changes to ino files - detects failures from individual targets - allows more parallel operation - clones required git repos at specific commit points - moves UnixHostDuino path assignment to parent makefile
1 parent 77f38c0 commit cf9b1f1

File tree

4 files changed

+58
-30
lines changed

4 files changed

+58
-30
lines changed

.github/workflows/aunit_tests.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: arduino-timer unit tests
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
@@ -10,16 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212

13-
- name: Setup
14-
run: |
15-
cd ..
16-
git clone https://github.com/bxparks/UnixHostDuino
17-
git clone https://github.com/bxparks/AUnit
18-
- name: Build Tests
13+
- name: Build
1914
run: |
2015
make -C extras/tests
21-
- name: Run Tests
16+
- name: Run
2217
run: |
23-
make -C extras/tests
2418
make -C extras/tests runtests
2519

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ $(NAME)-$(VERSION).zip:
66

77
tag:
88
git tag $(VERSION)
9+
10+
test:
11+
$(MAKE) -C extras/tests/ test

extras/tests/Makefile

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
1-
tests:
2-
set -e; \
3-
for i in *Test/Makefile; do \
4-
echo '==== Making:' $$(dirname $$i); \
5-
make -C $$(dirname $$i) -j; \
6-
done
7-
8-
runtests:
9-
set -e; \
10-
for i in *Test/Makefile; do \
11-
echo '==== Running:' $$(dirname $$i); \
12-
$$(dirname $$i)/$$(dirname $$i).out; \
13-
done
14-
15-
clean:
16-
set -e; \
17-
for i in *Test/Makefile; do \
18-
echo '==== Cleaning:' $$(dirname $$i); \
19-
make -C $$(dirname $$i) clean; \
20-
done
1+
TESTS := $(wildcard *Test)
2+
3+
UNIXHOSTDUINO := ../../../UnixHostDuino/UnixHostDuino.mk
4+
UNIXHOSTDUINO_URL := https://github.com/bxparks/UnixHostDuino
5+
UNIXHOSTDUINO_TAG := 1936444e0097a37ad268e5e3d6e6cca8d957a86b
6+
AUNIT := ../../../AUnit/
7+
AUNIT_URL := https://github.com/bxparks/AUnit
8+
AUNIT_TAG := e0aa8dfb635101d170cdb9fd9669e1d8047e2db1
9+
10+
### ### ###
11+
12+
UHD_DIR := $(dir $(UNIXHOSTDUINO))
13+
AU_DIR := $(dir $(AUNIT))
14+
SUB_DIRS := $(addsuffix /, $(TESTS))
15+
TEST_DIRS := $(join $(SUB_DIRS), $(TESTS))
16+
17+
INOS := $(addsuffix .ino, $(join $(SUB_DIRS), $(TESTS)))
18+
BINS := $(addsuffix .out, $(TEST_DIRS))
19+
RUNS := $(addsuffix .run, $(BINS))
20+
CLEANS := $(addsuffix .clean, $(SUB_DIRS))
21+
22+
all: $(BINS)
23+
24+
$(UHD_DIR):
25+
git clone $(UNIXHOSTDUINO_URL) $@
26+
cd $@; git checkout $(UNIXHOSTDUINO_TAG)
27+
28+
$(AU_DIR):
29+
git clone $(AUNIT_URL) $@
30+
cd $@; git checkout $(AUNIT_TAG)
31+
32+
$(BINS): $(INOS) $(UHD_DIR) $(AU_DIR)
33+
# ==== Building: $(dir $@)
34+
$(MAKE) UNIXHOSTDUINO=../$(UNIXHOSTDUINO) -C $(dir $@)
35+
36+
$(RUNS): $(BINS)
37+
# ==== Running: $(@:.run=)
38+
$(@:.run=)
39+
40+
$(CLEANS):
41+
# ==== Cleaning: $(@:.clean=)
42+
$(MAKE) UNIXHOSTDUINO=../$(UNIXHOSTDUINO) -C $(@:.clean=) clean
43+
44+
tests: $(BINS)
45+
46+
runtests: $(RUNS)
47+
48+
clean: $(CLEANS)
49+
50+
test: runtests clean

extras/tests/timerTest/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
APP_NAME := timerTest
66
ARDUINO_LIBS := AUnit arduino-timer
77
CPPFLAGS += -Werror
8-
include ../../../../UnixHostDuino/UnixHostDuino.mk
8+
9+
include $(UNIXHOSTDUINO)

0 commit comments

Comments
 (0)