-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (53 loc) · 2.03 KB
/
Makefile
File metadata and controls
66 lines (53 loc) · 2.03 KB
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
.DEFAULT_GOAL := help
.PHONY: help
help:
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: setup-db
setup-db:
@echo "RACK_ENV is '${RACK_ENV}'"
@echo ">>>>> Creating DB"
@bundle exec rake db:create
@echo ">>>>> Migrating DB"
@bundle exec rake db:migrate
@echo ">>>>> Fixing 'scotland.public' references in schema.rb file"
@awk '{gsub(/scotland.public/,"public")}1' db/schema.rb > temp.txt && mv -f temp.txt db/schema.rb
@if [ "${RACK_ENV}" != "production" ]; then \
echo ">>>>> Preparing DB for tests"; \
RACK_ENV=test bundle exec rake db:create; \
RACK_ENV=test bundle exec rake db:migrate; \
echo ">>>>> Fixing 'scotland.public' references in schema.rb file"; \
awk '{gsub(/scotland.public/,"public")}1' db/schema.rb > temp.txt && mv -f temp.txt db/schema.rb; \
fi
@echo ">>>>> Seeding DB with fuel code mapping data"
@bundle exec rake db:seed
@printf "\nDB setup complete.\nTo load fuel price data run 'bundle exec rake maintenance:green_deal_update_fuel_data'.\n"
.PHONY: test
test:
@STAGE=test bundle exec rake spec
.PHONY: run
run:
$(if ${JWT_ISSUER},,$(error Must specify JWT_ISSUER))
$(if ${JWT_SECRET},,$(error Must specify JWT_SECRET))
$(if ${EPB_UNLEASH_URI},,$(error Must specify EPB_UNLEASH_URI))
@bundle exec rackup -p 9191
.PHONY: format
format:
@bundle exec rubocop --autocorrect || true
.PHONY: lint-api-spec
lint-api-spec:
@npx spectral lint api/apidoc.yml -r api/.spectral.yaml
.PHONY: setup-hooks
setup-hooks:
@scripts/setup-git-hooks.sh
.PHONY: seed-local-db
seed-local-db:
make setup-db
@echo ">>>>> Bootstrapping Dev Data"
@bundle exec rake tasks:bootstrap_dev_data
@echo ">>>>> Getting green deal fuel data"
@bundle exec rake maintenance:green_deal_update_fuel_data
@echo ">>>>> Seeding DB with fuel code mapping data"
@bundle exec rake db:seed
.PHONY: destroy-test-postgres-container-if-exists
destroy-test-postgres-container-if-exists:
@scripts/destroy-test-postgres-container-if-exists.sh