-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
52 lines (41 loc) · 1.74 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-include .env
.DEFAULT_GOAL := help
.PHONY: help
.EXPORT_ALL_VARIABLES:
DOCKER_WORKSPACE := "/markdown"
MOUNTS = --volume ${PWD}:${DOCKER_WORKSPACE} \
--volume ${DOCKER_WORKSPACE}/node_modules
ifeq ($(USE_LEGACY), true)
dockerfile = -f Dockerfile.legacy
endif
ifeq ($(USE_LEGACY), true)
dockerfile = -f Dockerfile.legacy
endif
build:
@echo USE_LEGACY=$(USE_LEGACY)
docker build -t markdown $(dockerfile) --build-arg REACT_VERSION=${REACT_VERSION} .
# This lets us call `make run test.browser`. Make expects cmdline args
# to be targets. So this creates noop targets out of args. Copied from
# SO.
ifeq (run,$(firstword $(MAKECMDGOALS)))
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(RUN_ARGS):;@:)
endif
run: build ## Run npm scripts in a docker container. (default: make test.browser)
docker run -it --rm ${MOUNTS} markdown $(RUN_ARGS)
ci: build ## CI runner for `npm run test.browser -- --ci`
# We don't mount root because CI doesn't care about live changes,
# except for grabbing the snapshot diffs, so we mount __tests__.
# Mounting root would break `make emoji` in the Dockerfile.
docker run -i \
--volume ${PWD}/__tests__:${DOCKER_WORKSPACE}/__tests__ \
--env NODE_VERSION=${NODE_VERSION} \
markdown test.browser -- --ci
# I would like this to be `updateSnapshots` but I think it's better to
# be consistent with jest.
updateSnapshot: build ## Run `npm run test.browser -- --updateSnapshot`
docker run -i --rm ${MOUNTS} markdown test.browser -- --updateSnapshot
shell: build ## Docker shell.
docker run -it --rm ${MOUNTS} --entrypoint /bin/bash markdown
help: ## Show this help.
@grep -E '^[a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'