Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (128 loc) · 5.9 KB
/
Copy pathMakefile
File metadata and controls
183 lines (128 loc) · 5.9 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
CONFIG ?= flora.kdl
CONFIG_TEST := flora_test.kdl
init: ## Set up git hooks properly - needs calling once when cloning the repo
@git config core.hooksPath .githooks
start-server: ## Start flora backend server
@cabal run exe:flora-server -- -c $(CONFIG)
start-jobs: ## Start jobs runner
@cabal run exe:flora-jobs-runner -- -c $(CONFIG)
build: ## Build the server
@cabal build
clean: ## Remove the cabal build artifacts
@rm -rf assets/node_modules
@cabal clean
assets-deps: ## Install the dependencies of the frontend
@cd assets/ && npm clean-install
@cd docs/ && npm clean-install
build-assets: assets-deps ## Build the web assets
@cd assets/ && npm run build
@cd docs/ && npm run build
watch-assets: ## Continuously rebuild the web assets
@cd assets/ && npm run watch
clean-assets: ## Remove JS artifacts
@cd assets/ && rm -R node_modules
@cd docs/ && rm -R node_modules
db-start:
@rm -rf .postgres
@mkdir -p .postgres
@initdb -D .postgres
@echo "unix_socket_directories = '.'" >> .postgres/postgresql.conf
@pg_ctl start -D .postgres -l ./postgres.log
@createuser -h localhost postgres -s
db-stop:
@pg_ctl stop -D .postgres -l ./postgres.log
@rm -rf .postgres
db-setup: db-create db-migrate ## Setup the dev database
db-create: ## Create the database
@cabal run flora-cli -- -c $(CONFIG) create-db
db-drop: ## Drop the database
@cabal run flora-cli -- -c $(CONFIG) drop-db
db-migrate: ## Apply database migrations
@cabal run flora-migrate -- -c $(CONFIG)
db-reset: db-drop db-setup db-provision ## Reset the dev database
db-provision: ## Create categories and repositories
./scripts/db-provision.sh $(CONFIG)
db-provision-advisories: ## Load HSEC advisories in the database
@cabal run flora-cli -- -c $(CONFIG) provision advisories
db-provision-packages: ## Load development data in the dev database
@cabal run flora-cli -- -c $(CONFIG) provision test-packages --repository "hackage"
@cabal run flora-cli -- -c $(CONFIG) provision test-packages --repository "cardano"
@cabal run flora-cli -- -c $(CONFIG) provision test-packages --repository "mlabs"
db-test-create: ## Create the test database
@cabal run flora-cli -- -c $(CONFIG_TEST) create-db
db-test-setup: db-test-create db-test-migrate ## Setup the dev database
db-test-drop: ## Drop the test database
@cabal run flora-cli -- -c $(CONFIG_TEST) drop-db
db-test-migrate: ## Apply test database migrations
@cabal run flora-migrate -- -c $(CONFIG_TEST)
db-test-reset: db-test-drop db-test-setup db-test-provision ## Reset the test database
db-test-provision: ## Create categories and repositories
./scripts/db-provision.sh $(CONFIG_TEST)
db-test-provision-advisories: ## Load HSEC advisories in the test database
@cabal run flora-cli -- -c $(CONFIG_TEST) provision advisories
db-test-provision-packages: ## Load development data in the database
@cabal run flora-cli -- -c $(CONFIG_TEST) provision test-packages --repository "hackage"
@cabal run flora-cli -- -c $(CONFIG_TEST) provision test-packages --repository "cardano"
@cabal run flora-cli -- -c $(CONFIG_TEST) provision test-packages --repository "mlabs"
import-from-hackage: ## Imports every cabal file from the ./index-01 directory
@cabal run flora-cli -- -c $(CONFIG) import-packages ./01-index
repl: ## Start a cabal REPL
@cabal repl lib:flora
ghci: repl ## Start a cabal REPL (alias for `make repl`)
watch: ## Load the main library and reload on file change
@ghcid --target flora-server --restart="src" -l
test: ## Run the test suite
@cabal test --ghc-option "-Werror=unused-imports" --test-options="-c $(CONFIG_TEST)"
watch-test: ## Load the tests in ghcid and reload them on file change
@ghcid --command='cabal v2-repl flora-test --ghc-option "-Werror=unused-imports"' --test 'Main.main' --setup ':set args -c $(CONFIG_TEST)'
watch-server: ## Start flora-server in ghcid
@ghcid --target=flora-server --restart="src" --test 'FloraWeb.Server.runFlora "$(CONFIG)"'
lint-hs: ## Run the code linter (HLint)
@find app test src -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}
style-hs-quick: ## Run the haskell code formatters (fourmolu, cabal-gild)
@cabal-gild --io=flora.cabal
@git diff origin --name-only src test/**/*.hs app | xargs -P $(PROCS) -I {} fourmolu -q -i {}
style-hs: ## Run the haskell code formatters (fourmolu, cabal-gild)
@cabal-gild --io=flora.cabal
@find app test src -name '*.hs' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
style-css: ## Run the CSS code formatter (stylelint)
@cd assets ; npm run lint:fix
style: style-hs style-css ## Run all the code formatters
docker-build: ## Build and start the container cluster
@docker compose build devel
docker-up: ## Start the container cluster
@docker compose up -d
docker-stop: ## Stop the container cluster without removing the containers
@docker compose stop
docker-down: ## Stop and remove the container cluster
@docker compose down
docker-enter: ## Enter the docker environment
docker compose exec devel zsh
start-tmux: ## Start a Tmux session with hot code reloading
./scripts/start-tmux.sh
tags: ## Generate ctags for the project with `ghc-tags`
@ghc-tags -c src app
design-system: ## Generate the HTML components used by the design system
@cabal run flora-cli -- -c $(CONFIG) gen-design-system
start-design-system: ## Start storybook.js
@cd design; npm run storybook
migration: ## Generate timestamped database migration boilerplate files
@if test -z "$$name"; then \
echo "Usage: make migration name=some-name"; \
else \
migName="`date -u '+%Y%m%d%H%M%S'`_$$name"; \
fname="migrations/$$migName.sql"; \
touch "$$fname"; \
echo "Touched $$fname";\
fi
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.* ?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
UNAME := $(shell uname)
SHELL := /usr/bin/env bash
ifeq ($(UNAME), Darwin)
PROCS := $(shell sysctl -n hw.logicalcpu)
else
PROCS := $(shell nproc)
endif
.PHONY: all $(MAKECMDGOALS)
.DEFAULT_GOAL := help