-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
159 lines (112 loc) · 4.9 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
help: # Magic trick to gather command comments into a handy help message.
@grep -E '^[a-zA-Z_-]+:.*?#- .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?#- "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
venv = venv
bin = ${venv}/bin/
python = ${bin}python
pip = ${bin}pip
pysources = server/ tools/ tests/
git_current_ref = $(shell git rev-parse --verify --short HEAD)
install: install-server install-client #- Install all dependencies (server and client)
install-server: #- Install server dependencies
python3 -m venv ${venv}
${pip} install -U pip wheel setuptools
${pip} install -r requirements.txt
install-client: #- Install client dependencies
cd client && npm ci && npx playwright install firefox
build: #- Build production assets
cd client && npm run build
serve: #- Serve both the server and the client in parallel
make -j 2 serve-server serve-client
serve-server: #- Run API server
./tools/colorize_prefix.sh [server] 34 "${python} -m server.main"
serve-client: #- Run the client
./tools/colorize_prefix.sh [client] 33 "cd client && npm run dev"
serve-dist: #- Serve both the server and the built client in parallel
make -j 2 serve-server serve-dist-client
serve-dist-client: #- Run the built client
./tools/colorize_prefix.sh [client] 33 "cd client && npm start"
compose-up: #- Start Docker Compose setup
docker-compose up --build -d
docker-compose run migrate
docker-compose run initdata
compose-down: #- Stop and teardown Docker Compose setup
docker-compose down
migrate: #- Apply pending migrations
${bin}alembic upgrade head
migration: #- Create a migration
${bin}alembic revision --autogenerate -m $(name)
currentmigration: #- Show current migraiton
${bin}alembic show current
initdata: #- Initialize data
${bin}python -m tools.initdata tools/initdata.yml
dedupe-tags: #- Dedupe tags
${bin}python -m tools.remove_duplicated_tags
initdatareset: #- Initialize data, resetting any changed target entities
${bin}python -m tools.initdata --reset tools/initdata.yml
n ?= 500
randomdatasets: #- Add 500 random datasets
${bin}python -m tools.addrandomdatasets $(n) $(siret)
id: #- Generate an ID suitable for use in database entities
${bin}python -m tools.makeid
apikey: #- Generate an API key token
${bin}python -m tools.makeapikey
secretkey: #- Generate a cookie signing secret key using Django
${bin}python -m tools.makesecretkey
changepassword: #- Change password of a user account
${bin}python -m tools.changepassword
dbdiagram: #- Generate database diagram image
${bin}python -m tools.erd docs/db.erd.json -o docs/db.dot
dot docs/db.dot -T png -o docs/db.png
dsfr-icon-extras: #- Generate CSS for extra DSFR icons
${bin}python -m tools.iconextras \
--prefix fr-icon-x- \
--output client/src/styles/dsfr-icon-extras.css
test: test-server test-client #- Run the server and client test suite
test-ci: test-server test-client-ci #- Run the server and client test suite in CI mode
test-server: #- Run the server test suite
${bin}pytest
test-client: test-client-unit test-client-e2e #- Run the client's unit and e2e tests
test-client-ci: test-client-unit test-client-e2e-ci #- Run the client's unit and e2e tests in CI mode
test-client-unit: #- Run the client test suite
cd client && npm run test:coverage
test-client-e2e: #- Run the client e2e test suite
cd client && npm run test-e2e
test-client-e2e-ci: #- Run the client e2e test suite in a CI mode
cd client && npm run test-e2e:ci
format: format-server format-client #- Run code formatting on server and client sources
format-server: #- Run code formatting on the server sources
${bin}black ${pysources}
${bin}isort ${pysources}
format-client: #- Run code formatting on the client sources
cd client && npm run format
check: check-server check-client #- Run server and client code checks
check-server: #- Run server code checks
${bin}black --check ${pysources}
${bin}flake8 ${pysources}
${bin}mypy ${pysources}
${bin}isort --check --diff ${pysources}
check-client: #- Run client code checks
cd client && npm run lint && npm run check
ops-install: #- Install ops dependencies
cd ops && make install
ops-secrets: #- Edit environment secrets
cd ops && make secrets env=$(env)
ops-provision: #- Provision environment
cd ops && make provision env=$(env)
ops-deploy: #- Deploy environment
cd ops && make deploy env=$(env)
ops-initdata: #- Run initdata in environment
cd ops && make initdata env=$(env)
ops-dedupe-tags: #- Run initdata in environment
cd ops && make dedupe-tags env=$(env)
ops-staging: #- Sync staging branch with changes from current branch
git checkout staging
git pull --rebase origin staging
git merge --no-edit $(git_current_ref)
@echo "Success. You may now push and deploy"
ops-staging-sync: #- Sync staging branch with master
git checkout master
git pull --rebase origin master
git branch -D staging
git checkout -b staging
@echo "Almost done. You must now force-push (hint: git push --set-upstream origin staging --force)"