-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (74 loc) · 2.73 KB
/
Makefile
File metadata and controls
103 lines (74 loc) · 2.73 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
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
.PHONY: \
lint \
lint-ci \
test \
test-coverage \
test-watch
##################################################
# Constants
##################################################
RAILS_CMD := cd spec/dummy && bundle exec rails
##################################################
# Setup
##################################################
install:
npm install --prefix spec/dummy
bundle install
spec/dummy/.env: spec/dummy/local.env.example
@([ -f spec/dummy/.env ] && echo "spec/dummy/.env file already exists, but spec/dummy/local.env.example is newer (or you just switched branches), \
check for any updates" && touch spec/dummy/.env) || cp spec/dummy/local.env.example spec/dummy/.env
setup: install spec/dummy/.env init-db
##################################################
# Database
##################################################
init-db: ## Initialize the project database
init-db: db-up wait-on-db db-migrate db-test-prepare db-seed
db-up: ## Run just the database container
docker compose -f spec/dummy/docker-compose.yml up --remove-orphans --detach $(DB_NAME)
db-create: ## Create the database
$(RAILS_CMD) db:create
db-migrate: ## Run database migrations
$(RAILS_CMD) db:migrate
db-rollback: ## Rollback a database migration
$(RAILS_CMD) db:rollback
db-test-prepare: ## Prepare the test database
$(RAILS_CMD) db:test:prepare
db-seed: ## Seed the database
$(RAILS_CMD) db:seed
db-reset: ## Reset the database
$(RAILS_CMD) db:reset
db-drop: ## Drop the database
$(RAILS_CMD) db:drop
db-console: ## Access the rails db console
$(RAILS_CMD) dbconsole
wait-on-db:
./spec/dummy/bin/wait-for-local-postgres.sh
##################################################
# Linting
##################################################
lint: ## Run the linter with auto-fixing
bundle exec rubocop -A
lint-ci: ## Run the linter, but don't fix anything
bundle exec rubocop
##################################################
# Testing
##################################################
test: ## Run the test suite and generate a coverage report
test: db-up
bundle exec rspec
test-watch: ## Watch for file changes and run the test suite
test-watch: db-up
bundle exec guard
test-coverage: ## Open the test coverage report
open coverage/index.html
##################################################
# Dummy App
##################################################
start: ## Start the dummy app server
start: db-up
$(RAILS_CMD) server
##################################################
# Other
##################################################
help: ## Prints the help documentation and info about each command
@grep -Eh '^[/a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'