-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
135 lines (115 loc) · 4.52 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
SHELL = /bin/sh
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
export CURRENT_UID
export CURRENT_GID
docker-base = docker-compose -p dh -f docker-compose.base.yml
docker-mock = docker-compose -p dh -f docker-compose.base.yml -f docker-compose.mock.yml
docker-e2e = docker-compose -p dh -f docker-compose.base.yml -f docker-compose.e2e.frontend.yml -f docker-compose.e2e.backend.yml -f docker-compose.services.yml
docker-dev = COMPOSE_HTTP_TIMEOUT=300 docker-compose -p dh -f docker-compose.base.yml -f docker-compose.frontend.dev.yml
wait-for-frontend = dockerize -wait tcp://localhost:3000/healthcheck -timeout 5m -wait-retry-interval 5s
wait-for-redis = dockerize -wait tcp://redis:6379 -timeout 5m
ifdef CI
start-command = up --build --force-recreate -d
cypress-args = -- --parallel --record --key $(CYPRESS_DASHBOARD_KEY) --ci-build-id $(CIRCLE_BUILD_NUM)
log-command = logs --follow
else
start-command = up --build --force-recreate
cypress-args =
log-command = version
endif
ifdef CI
start-command = up --build --force-recreate -d
cypress-spec-args = -- --spec $(SPEC_FILES)
log-command = logs --follow
else
start-command = up --build --force-recreate
cypress-spec-args =
log-command = version
endif
# Helper commands to execute docker-compose for a specific setup
# e.g. "`make base` logs"
base:
@echo $(docker-base)
mock:
@echo $(docker-mock)
e2e:
@echo $(docker-e2e)
dev:
@echo $(docker-dev)
start-base:
@echo "*** To stop this stack run 'make stop-base' ***"
$(docker-base) $(start-command)
$(docker-base) $(log-command) &
start-mock:
@echo "*** To stop this stack run 'make stop-mock' ***"
$(docker-mock) $(start-command)
$(docker-mock) $(log-command) &
start-e2e-lep:
@echo "*** To stop this stack run 'make stop-e2e' ***"
OAUTH2_DEV_TOKEN=lepStaffToken $(docker-e2e) $(start-command)
$(docker-e2e) $(log-command) &
start-e2e-da:
@echo "*** To stop this stack run 'make stop-e2e' ***"
OAUTH2_DEV_TOKEN=daStaffToken $(docker-e2e) $(start-command)
$(docker-e2e) $(log-command) &
start-e2e-dit:
@echo "*** To stop this stack run 'make stop-e2e' ***"
OAUTH2_DEV_TOKEN=ditStaffToken $(docker-e2e) $(start-command)
$(docker-e2e) $(log-command) &
start-dev:
@echo "*** To stop this stack run 'make stop-dev' ***"
@echo "*** IMPORTANT This will now use ../data-hub-api/.env for 'api' and 'rq' services ***"
$(MAKE) -C ../data-hub-api start-dev
$(docker-dev) $(start-command)
stop-base:
$(docker-base) down -v --remove-orphans
stop-mock:
$(docker-mock) down -v --remove-orphans
stop-e2e:
$(docker-e2e) down -v --remove-orphans
stop-dev:
$(MAKE) -C ../data-hub-api stop-dev
$(docker-dev) down -v --remove-orphans
lint:
ifdef CI
$(docker-base) build frontend
endif
$(docker-base) run --no-deps --rm frontend bash -c 'mkdir -p reports && npm run lint:js -- --format junit --output-file reports/eslint.xml'
unit-tests:
ifdef CI
$(docker-base) build frontend
$(docker-base) run --rm frontend bash -c '$(wait-for-redis) && npx nyc --reporter=lcov --reporter=json --report-dir=coverage npm run test:unit -- --reporter mocha-junit-reporter'
else
$(docker-base) run --rm frontend bash -c '$(wait-for-redis) && npm run test:unit'
endif
unit-client-tests:
ifdef CI
$(docker-base) build frontend
endif
$(docker-base) run --no-deps --rm frontend bash -c 'npm run test:unit-client -- --reporter mocha-junit-reporter'
functional-tests:
@echo "*** Requires the mock stack, it can be started with 'make start-mock' ***"
$(docker-mock) exec frontend bash -c '$(wait-for-frontend) && npm run test:functional $(cypress-spec-args)'
a11y-tests:
@echo "*** Requires the mock stack, it can be started with 'make start-mock' ***"
$(docker-mock) exec frontend bash -c '$(wait-for-frontend) && npm run test:a11y'
e2e-tests-lep:
@echo "*** Requires the e2e stack with the LEP role, it can be started with 'make start-e2e-lep' ***"
$(docker-e2e) exec frontend bash -c '$(wait-for-frontend) && npm run test:e2e:lep $(cypress-args)'
e2e-tests-da:
@echo "*** Requires the e2e stack with the DA role, it can be started with 'make start-e2e-da' ***"
$(docker-e2e) exec frontend bash -c '$(wait-for-frontend) && npm run test:e2e:da $(cypress-args)'
e2e-tests-dit:
@echo "*** Requires the e2e stack with the DBT role, it can be started with 'make start-e2e-dit' ***"
$(docker-e2e) exec frontend bash -c '$(wait-for-frontend) && npm run test:e2e:dit $(cypress-args)'
component-tests:
ifdef CI
$(docker-base) build frontend
endif
$(docker-base) run --no-deps --rm frontend bash -c 'npm run test:component'
clean:
make stop-base
make stop-mock
make stop-e2e
make stop-dev