From 06b466d847c46dc384cdef95658dade68111b173 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 28 Dec 2020 12:44:53 -0800 Subject: [PATCH] ci: also test compilation of bin/ add-on scripts --- .github/workflows/linux.yml | 2 +- .github/workflows/mac.yml | 2 +- .github/workflows/push.yml | 2 +- .github/workflows/windows.yml | 2 +- Makefile | 2 +- bin/compile.sh | 20 +++++++++++++------- bin/scripts.test | 12 ++++++++++++ 7 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 bin/scripts.test diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2d1733589..1cce3288f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -214,7 +214,7 @@ jobs: stack: ${{ matrix.plan.stack }} run: | export PATH=~/.local/bin:$PATH - COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /bin -x /addons + COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /addons - name: Test haddock generation env: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 842f533be..9e347e3ac 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -158,7 +158,7 @@ jobs: stack: ${{ matrix.plan.stack }} run: | export PATH=~/.local/bin:$PATH - COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /bin -x /addons + COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /addons # artifacts: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b9856e537..2daa6d533 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -151,4 +151,4 @@ jobs: stack: ${{ matrix.plan.stack }} run: | export PATH=~/.local/bin:$PATH - COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /bin -x /addons + COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /addons diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f06d07f0c..46273c276 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -161,7 +161,7 @@ jobs: # run hledger-lib/hledger functional tests, skipping the ones for addons ## - export PATH=~/.local/bin:$PATH - #- COLUMNS=80 stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /bin -x /addons + #- COLUMNS=80 stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /addons # artifacts: diff --git a/Makefile b/Makefile index 58cf63fe3..a57e4a2f1 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ builtintest: $(call def-help,builtintest, run hledgers built in test command) functest: hledger/test/addons/hledger-addon \ $(call def-help,functest, build hledger quickly and run the functional tests (and some unit tests) ) @$(STACK) build --fast hledger - @($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` hledger/test/ \ + @($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` hledger/test/ bin/ \ && echo $@ PASSED) || (echo $@ FAILED; false) functest-%: hledger/test/addons/hledger-addon \ diff --git a/bin/compile.sh b/bin/compile.sh index bc503eb17..1f54298af 100755 --- a/bin/compile.sh +++ b/bin/compile.sh @@ -1,9 +1,15 @@ #!/bin/sh -# Run this script (or "make addons") to compile all addons in this directory. -cd "$(dirname "$0")" -echo "building dependencies" +# Compile all add-on scrips in this directory. + +cd "$(dirname "$0")" || exit + +echo "building hledger libraries" stack build hledger -# additional deps needed by addons -stack install Diff here #Chart Chart-diagrams colour -echo "building add-on commands" -for f in hledger-*.hs; do stack ghc -- -Wall -Werror $f; done + +echo "installing extra libraries needed by scripts" +stack install string-qq + +echo "compiling hledger-* scripts" +for f in hledger-*.hs; do stack ghc -- "$f"; done + # stack script --compile would install extra libs more automatically + # but would also run scripts, which we don't want diff --git a/bin/scripts.test b/bin/scripts.test new file mode 100644 index 000000000..54ca44b5b --- /dev/null +++ b/bin/scripts.test @@ -0,0 +1,12 @@ +# Functional tests for the add-on scripts in this directory. + +# Check that they all (or at least these ones) still compile with this version of hledger. +# stdout and exit code are ignored for cleaner failure output. +# $ ./compile.sh >/dev/null +$ stack ghc -- hledger-balance-as-budget.hs >/dev/null || true +$ stack ghc -- hledger-check-fancyassertions.hs >/dev/null || true +$ stack ghc -- hledger-check-tagfiles.hs >/dev/null || true +$ stack ghc -- hledger-combine-balances.hs >/dev/null || true +$ stack ghc --package string-qq -- hledger-print-location.hs >/dev/null || true +$ stack ghc --package string-qq -- hledger-smooth.hs >/dev/null || true +$ stack ghc --package string-qq -- hledger-swap-dates.hs >/dev/null || true