rollbar-hs/Makefile
joneshf b968bb53a4
Split out test targets
It looks like,
when we switch jobs in CI the new checkout has newer timestamps
than what's in the make cache.
Rather than dealing with that anymore, we alter the targets.

We can change `test` to ensure builds are up to date.
Then we can leave the individual test targets to run whatever is there.

In CI this means we can set the workflow to run the tests separately.
2018-07-29 13:17:19 -07:00

74 lines
1.5 KiB
Makefile

BIN ?= bin
CABAL ?= cabal
DIST ?= dist
EMPTY ?= .make
PROJECT_NAME ?= rollbar-hs
STACK ?= stack
STACK_WORK ?= .stack-work
VERBOSITY ?= warn
CABAL_FILE := $(PROJECT_NAME).cabal
DOC_TEST := $(DIST)/build/doc-test/doc-test
GHCID := $(BIN)/ghcid
STACK_FLAGS := --verbosity $(VERBOSITY)
.DEFAULT_GOAL := build
$(BIN) $(DIST) $(EMPTY):
mkdir -p $@
$(CABAL_FILE): package.yaml
# `stack` has no way to run `hpack` directly.
# We can run `hpack` indirectly with little overhead.
$(STACK) $(STACK_FLAGS) build --dry-run
$(DOC_TEST):
rm -f $(EMPTY)/build
$(MAKE) $(EMPTY)/build
$(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST)
$(STACK) $(STACK_FLAGS) build --no-run-tests --test
cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)
touch $@
$(EMPTY)/stack-setup: | $(EMPTY)
$(STACK) $(STACK_FLAGS) setup
touch $@
$(GHCID): $(EMPTY)/stack-setup | $(BIN)
$(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN)
.PHONT: build
build: $(EMPTY)/build
.PHONY: cabal-check
cabal-check: $(CABAL_FILE)
$(CABAL) check
.PHONY: clean
clean:
rm -f $(CABAL_FILE)
rm -fr $(BIN)
rm -fr $(DIST)
rm -fr $(EMPTY)
rm -fr $(STACK_WORK)
.PHONY: sdist
sdist: cabal-check | $(DIST)
$(CABAL) sdist
.PHONY: test
test: $(EMPTY)/build test-doc-test
.PHONY: test-doc-test
test-doc-test: $(DOC_TEST)
$<
.PHONY: upload-hackage
upload-hackage: sdist
@ $(CABAL) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
.PHONY: watch
watch: $(GHCID)
$(GHCID)