Skip to content

Commit ee4c0bc

Browse files
authored
Improvements to cabal make targets (#1979)
* Improvements to cabal make targets - Speed up installation by using parallel xargs - Allow `package=all` to act on all packages
1 parent 402bdf7 commit ee4c0bc

File tree

6 files changed

+40
-20
lines changed

6 files changed

+40
-20
lines changed

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ BUILDAH_PUSH ?= 0
1919
KIND_CLUSTER_NAME := wire-server
2020
BUILDAH_KIND_LOAD ?= 1
2121

22+
package ?= all
2223
EXE_SCHEMA := ./dist/$(package)-schema
2324

2425
# This ensures that focused unit tests written in hspec fail. This is supposed
@@ -44,7 +45,7 @@ install: init
4445
ifeq ($(WIRE_BUILD_WITH_CABAL), 1)
4546
cabal build all
4647
./hack/bin/cabal-run-all-tests.sh
47-
./hack/bin/cabal-install-all-artefacts.sh
48+
./hack/bin/cabal-install-artefacts.sh all
4849
else
4950
stack install --pedantic --test --bench --no-run-benchmarks --local-bin-path=dist
5051
endif
@@ -71,11 +72,7 @@ endif
7172
# Usage: make ci package=brig test=1
7273
.PHONY: ci
7374
ci: c
74-
ifeq ("$(pattern)", "")
75-
make -C services/$(package) i
76-
else
77-
make -C services/$(package) i-$(pattern)
78-
endif
75+
./hack/bin/cabal-run-integration.sh $(package) $(pattern)
7976

8077
# reset db using cabal
8178
.PHONY: db-reset-package
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve cabal make targets: faster installation and better support for building and testing all packages

hack/bin/cabal-install-all-artefacts.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

hack/bin/cabal-install-artefacts.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@ TOP_LEVEL="$(cd "$DIR/../.." && pwd)"
66

77
DIST="$TOP_LEVEL/dist"
88

9-
cabal-plan list-bins "$1"':exe:*' | awk '{print $2}' | xargs -I '{}' rsync -a {} "$DIST"
9+
if [[ "$1" == "all" ]]; then
10+
pattern='*'
11+
else
12+
pattern="$1"
13+
fi
14+
15+
cabal-plan list-bins "$pattern:exe:*" |
16+
awk '{print $2}' |
17+
xargs -i sh -c 'test -f {} && echo {} || true' |
18+
xargs -P8 -i rsync -a {} "$DIST"

hack/bin/cabal-run-integration.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
TOP_LEVEL="$(cd "$DIR/../.." && pwd)"
6+
7+
package=${1:-all}
8+
pattern=${2:-}
9+
10+
opts=""
11+
12+
if [[ "$package" != "all" ]]; then
13+
opts="$opts -C services/$package"
14+
fi
15+
16+
if [[ -n "$pattern" ]]; then
17+
if [[ "$package" == "all" ]]; then
18+
echo -e "\e[31mGlobal pattern not supported\e[0m" >&2
19+
exit 1
20+
fi
21+
opts="$opts i-$pattern"
22+
else
23+
opts="$opts i"
24+
fi
25+
26+
exec make $opts

services/brig/brig.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ copyright: (c) 2017 Wire Swiss GmbH
1616
license: AGPL-3
1717
license-file: LICENSE
1818
build-type: Custom
19-
data-files:
20-
docs/swagger.md
2119

2220
custom-setup
2321
setup-depends:

0 commit comments

Comments
 (0)