-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
244 lines (206 loc) · 8.77 KB
/
Makefile
File metadata and controls
244 lines (206 loc) · 8.77 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
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
244
TARGET_HEADER=@echo -e '===== \e[34m' $@ '\e[0m'
TARGET_OK=@echo -e '\e[32mOK\e[0m'
YARN=@docker-compose run --rm node yarn
YARN_PLAYWRIGHT=@docker-compose run --rm playwright yarn
COVERAGE_PARTS_DIR=coverage/.parts
COVERAGE_UNIT_DIR=coverage/unit
COVERAGE_E2E_REACT_DIR=coverage/e2e-react
COVERAGE_E2E_VUE_DIR=coverage/e2e-vue
NYC_OUTPUT_DIR=.nyc_output
.PHONY: up
up: ## Starts storybook
$(TARGET_HEADER)
docker-compose up -d
.PHONY: restart
restart: ## Restarts all docker services or a particular service, if argument "service" is specified (example: make restart service="storybook").
$(TARGET_HEADER)
ifdef service
yes | docker-compose rm -s -v $(service) && docker-compose up -d $(service)
else
docker-compose stop && docker-compose up -d
endif
.PHONY: stop
stop: ## Stops all docker services
$(TARGET_HEADER)
docker-compose stop
.PHONY: .yarnrc.yml
.yarnrc.yml: ## Creates yarn configuration
@cp .yarnrc.yml.dist .yarnrc.yml
.PHONY: node_modules
node_modules: package.json yarn.lock ## Installs dependencies
$(TARGET_HEADER)
$(YARN) install
@touch node_modules || true
@echo ""
.PHONY: build
build: node_modules ## Creates a dist catalogue with library build
$(TARGET_HEADER)
$(YARN) build
.PHONY: storybook-build-test
storybook-build-test: node_modules ## Builds Storybook in --test mode for all UI workspaces
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-react storybook:build --test --quiet
$(YARN) workspace @modulify/m3-vue storybook:build --test --quiet
.PHONY: storybook-build-test-react
storybook-build-test-react: node_modules ## Builds Storybook in --test mode for @modulify/m3-react
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-react storybook:build --test --quiet
.PHONY: storybook-build-test-vue
storybook-build-test-vue: node_modules ## Builds Storybook in --test mode for @modulify/m3-vue
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-vue storybook:build --test --quiet
.PHONY: test-smoke
test-smoke: node_modules ## Runs smoke tests for all UI workspaces
$(TARGET_HEADER)
$(YARN) test:smoke
.PHONY: test-runtime-parity
test-runtime-parity: ## Checks Node/Yarn parity across docker services (node, storybook, playwright)
$(TARGET_HEADER)
./runtime-parity.test.sh
.PHONY: husky
husky: node_modules ## Adds husky git hooks with commit content checks
@docker-compose run --rm node npx husky init
.PHONY: eslint
eslint: node_modules ## Runs eslint
$(TARGET_HEADER)
$(YARN) eslint
.PHONY: tsc
tsc: node_modules ## Runs type checks in all workspaces
$(TARGET_HEADER)
$(YARN) tsc
.PHONY: tsc-foundation
tsc-foundation: node_modules ## Runs type checks in @modulify/m3-foundation
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-foundation tsc
.PHONY: tsc-react
tsc-react: node_modules ## Runs type checks in @modulify/m3-react
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-react tsc
.PHONY: tsc-vue
tsc-vue: node_modules ## Runs type checks in @modulify/m3-vue
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-vue tsc
.PHONY: tsc-tests
tsc-tests: node_modules ## Runs type checks for tests in all UI workspaces
$(TARGET_HEADER)
$(YARN) tsc:tests
.PHONY: tsc-tests-react
tsc-tests-react: node_modules ## Runs type checks for tests in @modulify/m3-react
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-react tsc:tests
.PHONY: tsc-tests-vue
tsc-tests-vue: node_modules ## Runs type checks for tests in @modulify/m3-vue
$(TARGET_HEADER)
$(YARN) workspace @modulify/m3-vue tsc:tests
.PHONY: tsc-e2e
tsc-e2e: node_modules ## Runs type checks for Playwright Vitest configs
$(TARGET_HEADER)
$(YARN) exec tsc -p tsconfig.e2e.json --skipLibCheck
.PHONY: test
test: node_modules ## Runs autotests
$(TARGET_HEADER)
ifdef cli
@echo "${YARN} test ${cli}"
$(YARN) test $(cli)
else
@echo "${YARN} test"
$(YARN) test
endif
.PHONY: test-coverage
test-coverage: node_modules ## Runs merged coverage for unit and Playwright e2e tests
$(TARGET_HEADER)
@rm -rf coverage $(NYC_OUTPUT_DIR) artifacts
@mkdir -p $(COVERAGE_PARTS_DIR) $(NYC_OUTPUT_DIR)
$(YARN) test --coverage --coverage.provider=istanbul --coverage.reporter=json --coverage.reportsDirectory=$(COVERAGE_UNIT_DIR)
$(YARN_PLAYWRIGHT) test:e2e:coverage
@cp $(COVERAGE_UNIT_DIR)/coverage-final.json $(COVERAGE_PARTS_DIR)/unit.json
@cp $(COVERAGE_E2E_REACT_DIR)/coverage-final.json $(COVERAGE_PARTS_DIR)/e2e-react.json
@cp $(COVERAGE_E2E_VUE_DIR)/coverage-final.json $(COVERAGE_PARTS_DIR)/e2e-vue.json
@$(YARN) nyc merge $(COVERAGE_PARTS_DIR) $(NYC_OUTPUT_DIR)/coverage-final.json >/dev/null
$(YARN) nyc report
@$(YARN) nyc report --reporter=json-summary >/dev/null
@$(YARN) node --experimental-strip-types scripts/show-total-coverage.ts
.PHONY: test-e2e
test-e2e: node_modules ## Runs Playwright-based e2e tests (Vitest browser mode)
$(TARGET_HEADER)
ifdef cli
@$(YARN_PLAYWRIGHT) test:e2e $(cli)
else
@$(YARN_PLAYWRIGHT) test:e2e
endif
.PHONY: test-e2e-react
test-e2e-react: node_modules ## Runs Playwright-based e2e tests for @modulify/m3-react
$(TARGET_HEADER)
ifdef cli
@$(YARN_PLAYWRIGHT) workspace @modulify/m3-react test:e2e $(cli)
else
@$(YARN_PLAYWRIGHT) workspace @modulify/m3-react test:e2e
endif
.PHONY: test-e2e-vue
test-e2e-vue: node_modules ## Runs Playwright-based e2e tests for @modulify/m3-vue
$(TARGET_HEADER)
ifdef cli
@$(YARN_PLAYWRIGHT) workspace @modulify/m3-vue test:e2e $(cli)
else
@$(YARN_PLAYWRIGHT) workspace @modulify/m3-vue test:e2e
endif
.PHONY: test-e2e-stop
test-e2e-stop: ## Stops stuck Playwright E2E host processes and run containers
$(TARGET_HEADER)
@pkill -TERM -f "docker-compose run --rm playwright yarn test:[e]2e" || true
@pkill -TERM -f "docker-compose run --rm playwright yarn workspace @modulify/m3-react test:[e]2e" || true
@pkill -TERM -f "docker-compose run --rm playwright yarn workspace @modulify/m3-vue test:[e]2e" || true
@docker ps -q --filter "name=m3-web-playwright-run" | xargs -r docker rm -f
.PHONY: ci-actionlint
ci-actionlint: ## Lints GitHub Actions workflows locally (actionlint binary or docker image)
$(TARGET_HEADER)
@if command -v actionlint >/dev/null 2>&1; then \
actionlint; \
elif command -v docker >/dev/null 2>&1; then \
docker run --rm -v "$$(pwd):/repo" -w /repo rhysd/actionlint:latest; \
else \
echo "actionlint is not installed and docker is unavailable"; \
exit 1; \
fi
$(TARGET_OK)
.PHONY: ci-act-plan
ci-act-plan: ## Shows act execution plan for tests workflow without running jobs
$(TARGET_HEADER)
@if command -v act >/dev/null 2>&1; then \
act -P ubuntu-latest=catthehacker/ubuntu:act-latest -n pull_request -W .github/workflows/tests.yml; \
elif command -v docker >/dev/null 2>&1; then \
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$$(pwd):/repo" -w /repo alpine:3.20 sh -lc "apk add --no-cache curl tar >/dev/null && curl -fsSL https://github.com/nektos/act/releases/download/v0.2.84/act_Linux_x86_64.tar.gz | tar -xz -C /tmp && /tmp/act -P ubuntu-latest=catthehacker/ubuntu:act-latest -n pull_request -W .github/workflows/tests.yml"; \
else \
echo "act is not installed and docker is unavailable"; \
exit 1; \
fi
$(TARGET_OK)
.PHONY: ci-act-tests
ci-act-tests: ## Runs tests workflow locally via act (pr-check, eslint, tests, storybook-tests)
$(TARGET_HEADER)
@if command -v act >/dev/null 2>&1; then \
act -P ubuntu-latest=catthehacker/ubuntu:act-latest pull_request -W .github/workflows/tests.yml -j pr-check -j eslint -j tests -j storybook-tests; \
elif command -v docker >/dev/null 2>&1; then \
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$$(pwd):/repo" -w /repo alpine:3.20 sh -lc "apk add --no-cache curl tar >/dev/null && curl -fsSL https://github.com/nektos/act/releases/download/v0.2.84/act_Linux_x86_64.tar.gz | tar -xz -C /tmp && /tmp/act -P ubuntu-latest=catthehacker/ubuntu:act-latest pull_request -W .github/workflows/tests.yml -j pr-check -j eslint -j tests -j storybook-tests"; \
else \
echo "act is not installed and docker is unavailable"; \
exit 1; \
fi
$(TARGET_OK)
.PHONY: ci-check
ci-check: ci-actionlint ci-act-plan ## Validates CI workflow config and prints local act plan
$(TARGET_OK)
.PHONY: help
help: ## Calls recipes list
@cat $(MAKEFILE_LIST) | grep -e "^[-a-zA-Z_\.]*: *.*## *" | awk '\
BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# Colors
$(call computable,CC_BLACK,$(shell tput -Txterm setaf 0 2>/dev/null))
$(call computable,CC_RED,$(shell tput -Txterm setaf 1 2>/dev/null))
$(call computable,CC_GREEN,$(shell tput -Txterm setaf 2 2>/dev/null))
$(call computable,CC_YELLOW,$(shell tput -Txterm setaf 3 2>/dev/null))
$(call computable,CC_BLUE,$(shell tput -Txterm setaf 4 2>/dev/null))
$(call computable,CC_MAGENTA,$(shell tput -Txterm setaf 5 2>/dev/null))
$(call computable,CC_CYAN,$(shell tput -Txterm setaf 6 2>/dev/null))
$(call computable,CC_WHITE,$(shell tput -Txterm setaf 7 2>/dev/null))
$(call computable,CC_END,$(shell tput -Txterm sgr0 2>/dev/null))