This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
243 lines (200 loc) · 6.74 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
_docs:
cd docs-sources && pip install -r requirements.txt
storybook/build:
npm run storybook:build -w packages/ui
docs/build: _docs
cd docs-sources && mkdocs build -d ../docs
GIT_SHA=dontcare $(MAKE) storybook/build
docs/serve: _docs
cd docs-sources && mkdocs serve -a localhost:8080
docs/generate-schema:
# Planter vient de https://github.com/achiku/planter
docker run --net=camino_default --rm agileek/planter planter postgres://postgres:password@camino_api_db/camino?sslmode=disable > docs-sources/assets/database/camino-db.uml
cat docs-sources/assets/database/camino-db.uml | docker run --rm -i agileek/plantuml:1.2022.3 > docs-sources/docs/img/camino-db.svg
cat docs-sources/assets/keycloak_impersonate.uml | docker run --rm -i agileek/plantuml:1.2022.3 > docs-sources/docs/img/keycloak_impersonate.svg
cat docs-sources/assets/architecture.puml | docker run --rm -i agileek/plantuml:1.2022.3 > docs-sources/docs/img/architecture.svg
daily:
ifdef CAMINO_STAGE
npm run daily -w packages/api
else
@echo 'lancement du daily en mode local avec la migration'
npm run db:migrate -w packages/api
npm run daily -w packages/api
endif
daily/debug:
npm run daily-debug -w packages/api
monthly:
npm run monthly -w packages/api
db/migrate:
npm run db:migrate -w packages/api
db/check-queries:
ifndef CI
npm run db:watch -w packages/api
else
npm run db:check -w packages/api
endif
test: test/ui test/api test/common
test/api: test/api-unit test/api-integration
test/ui:
ifndef CI
npm run test -w packages/ui
else
npm run test -w packages/ui -- --coverage
endif
storybook/test:
ifndef CI
npm run storybook:test -w packages/ui
else
# TODO 2024-07-04 on peut surement mieux faire, avec un sidecar
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" "npx http-server packages/ui/storybook-static --port 6006 --silent" "npx wait-on tcp:6006 && npm run storybook:test -w packages/ui"
endif
test/common:
npm run test -w packages/common
test/api-unit:
ifndef CI
npm run test:unit -w packages/api
else
npm run test:unit -w packages/api -- --coverage
endif
test/api-integration:
ifndef CI
npm run test:integration -w packages/api
else
npm run test:integration -w packages/api -- --coverage
endif
lint/ui:
ifndef CI
npm run lint --workspace=packages/ui
else
npm run lint:check --workspace=packages/ui
endif
lint/api:
ifndef CI
npm run lint --workspace=packages/api
else
npm run ci:lint --workspace=packages/api
endif
lint/detect-dead-code:
npm run knip
lint/common:
ifndef CI
npm run format --workspace=packages/common
else
npm run lint --workspace=packages/common
endif
lint: lint/ui lint/api lint/common
install:
ifdef CI
# On a enlevé --ignore-scripts car pg-formatter fait un truc très étrange en postinstall, il curl une version de pg-format en perl et le met à côté de lui pour s'en servir
HUSKY=0 npm ci
else
npm ci
endif
install/prod:
ifdef CI
HUSKY=0 npm ci --omit=dev --ignore-scripts
else
npm ci --omit=dev
endif
build: build/common build/api build/ui
build/common:
npm run build -w packages/common
build/ui:
npm run build -w packages/ui
build/api:
ifdef CI
# https://github.com/microsoft/TypeScript/issues/53087
NODE_OPTIONS=--max-old-space-size=4096 npm run build -w packages/api
endif
npm run build -w packages/api
start/api:
ifdef CAMINO_STAGE
@echo 'lancement du backend en mode prod'
npm start -w packages/api
else
@echo 'lancement du backend en mode dev(local)'
npm run dev -w packages/api
endif
start/ui:
ifdef CAMINO_STAGE
@echo 'lancement du frontend en mode prod'
npm start -w packages/ui
else
@echo 'lancement du frontend en mode dev(local)'
npm run dev -w packages/ui
endif
ifeq (${INPUT_ENV}, dev)
CD_TOKEN:=${CD_TOKEN_DEV}
endif
ifeq (${INPUT_ENV}, preprod)
CD_TOKEN:=${CD_TOKEN_PREPROD}
endif
ifeq (${INPUT_ENV}, prod)
CD_TOKEN:=${CD_TOKEN_PROD}
endif
deploy/ci:
@echo "Déploiement de la version ${INPUT_SHA} en ${INPUT_ENV}"
@GIT_SHA=${INPUT_SHA} CD_TOKEN=${CD_TOKEN} $(MAKE) deploy/${INPUT_ENV}
_deploy:
ifndef DEPLOY_URL
@echo 'DEPLOY_URL est obligatoire'
@exit 1
endif
ifndef CD_TOKEN
@echo 'CD_TOKEN est obligatoire'
@exit 1
endif
ifndef GIT_SHA
@echo 'GIT_SHA est obligatoire'
@exit 1
endif
@echo 'on déploie sur ${DEPLOY_URL} la version ${GIT_SHA}'
@curl --fail-with-body http://${DEPLOY_URL}:3030/update/${GIT_SHA} -H 'authorization: ${CD_TOKEN}'
deploy/dev:
$(MAKE) DEPLOY_URL=dev.camino.beta.gouv.fr _deploy
deploy/preprod:
$(MAKE) DEPLOY_URL=preprod.camino.beta.gouv.fr _deploy
deploy/prod:
$(MAKE) DEPLOY_URL=camino.beta.gouv.fr _deploy
dsfr/generate_keycloak:
wget https://github.com/GouvernementFR/dsfr/releases/download/v1.10.2/dsfr-v1.10.2.zip
unzip dsfr-v1.10.2.zip -d dsfr
rm -rf infra/roles/camino/files/keycloak_theme/login/resources/css/
mkdir -p infra/roles/camino/files/keycloak_theme/login/resources/css/utility
mv dsfr/dist/dsfr.min.css infra/roles/camino/files/keycloak_theme/login/resources/css/dsfr.min.css
mv dsfr/dist/utility/utility.min.css infra/roles/camino/files/keycloak_theme/login/resources/css/utility/utility.min.css
mv dsfr/dist/icons infra/roles/camino/files/keycloak_theme/login/resources/css/
mv dsfr/dist/fonts infra/roles/camino/files/keycloak_theme/login/resources/css/
rm -rf dsfr
rm dsfr-v1.10.2.zip
dsfr/generate:
mkdir tmp
cp node_modules/@gouvfr/dsfr/dist/dsfr.css tmp/_dsfr.scss
cp node_modules/@gouvfr/dsfr/dist/utility/utility.css tmp/_utility.scss
sed -i 's/..\/icons/.\/icons/g' tmp/_utility.scss
sed -n "/\@font-face {/,/}/p" tmp/_dsfr.scss > tmp/font-face.scss
sed -i "/\@font-face {/,/}/d" tmp/_dsfr.scss
echo "@import './font-face.scss'; @import './_dsfr.scss'; @import './_utility.scss'" > tmp/dsfr.scss
npx sass --no-source-map tmp/dsfr.scss packages/ui/src/styles/dsfr/dsfr.css
rm -r tmp
cp -r node_modules/@gouvfr/dsfr/dist/icons packages/ui/src/styles/dsfr/
cp -r node_modules/@gouvfr/dsfr/dist/fonts packages/ui/src/styles/dsfr/
$(MAKE) icons/generate
$(MAKE) dsfr/generate_keycloak
icons/generate:
npm run generate-icon-types -w packages/ui
matrices:
npm run matrices -w packages/api
graphql/check:
npm i --global --force @graphql-inspector/ci@3.4.0 @graphql-inspector/validate-command@3.4.0 @graphql-inspector/graphql-loader@3.4.0 @graphql-inspector/code-loader@3.4.0 graphql
graphql-inspector validate --noStrictFragments packages/ui/src/api packages/api/src/api/graphql/schemas/index.graphql
for f in $(shell find ./packages/ui/src -name '*-api-client.ts'); do \
if grep -q gql "$$f"; then \
echo $$f; \
graphql-inspector validate --onlyErrors --noStrictFragments "$$f" packages/api/src/api/graphql/schemas/index.graphql || exit 1; \
fi \
done
for f in packages/api/tests/queries/*.graphql; do \
echo $$f; \
graphql-inspector validate --noStrictFragments "$$f" packages/api/src/api/graphql/schemas/index.graphql || exit 1; \
done