Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
209 lines (161 loc) · 7.15 KB
/
Copy pathMakefile
File metadata and controls
209 lines (161 loc) · 7.15 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
## REFERENCES:
## (1) Passing environment variable with fallback value to Makefile:
## https://stackoverflow.com/a/70772707/6366150
## (2) Export environment variables inside "make environment"
## https://stackoverflow.com/a/49524393/6366150
## (3) Uppercase to lowercase and vice versa
## https://community.unix.com/t/uppercase-to-lowercase-and-vice-versa/285278/6
## (4) How do I trim leading and trailing whitespace from each line of some output?
## https://unix.stackexchange.com/a/279222/233927
## (5) Pytest log levels:
## https://docs.pytest.org/en/latest/how-to/logging.html
############################################################################
## (1) ## Allowed values: info | warn | error | debug
LOG_LEVEL ?= info
## (3) (4)
LOG_LEVEL :=$(shell echo '${LOG_LEVEL}'| tr '[:lower:]' '[:upper:]'| tr -d '[:blank:]')
## (1) ## Allowed values: true | false
BRUTEFORCE ?= false
## (3) (4)
BRUTEFORCE :=$(shell echo '${BRUTEFORCE}'| tr '[:lower:]' '[:upper:]'| tr -d '[:blank:]')
# DOCKER
BUILDKIT_PROGRESS=plain
DOCKER_COMPOSE=docker compose
.MAIN: test
.PHONY: all clean dependencies help list test
.EXPORT_ALL_VARIABLES: # (2)
RUNTIME_TOOL=dotnet
PACKAGE_TOOL=dotnet
VERBOSITY_LEVEL=normal
define crono
@start=$$(date +%s); \
$(1); \
end=$$(date +%s); \
diff=$$((end - start)); \
printf "Total time: %02d:%02d:%02d\n" $$((diff/3600)) $$((diff%3600/60)) $$((diff%60))
endef
help: list
@echo ""
@echo "Note: create and activate the environment in your local shell type (example):"
@echo " python3 -m venv ./.venv"
@echo " source .venv/bin/activate"
@echo "See: "
@echo " https://docs.python.org/3/library/venv.html#creating-virtual-environments"
@echo " https://docs.python.org/3/library/venv.html#how-venvs-work"
list:
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
env:
@echo "################################################################################"
@echo "## Environment: ################################################################"
@echo "################################################################################"
@printenv | grep -E "LOG_LEVEL|BRUTEFORCE|BUILDKIT_PROGRESS"
@echo ""
@echo "################################################################################"
@echo "## Runtime: ####################################################################"
@echo "################################################################################"
@which $(PACKAGE_TOOL)
@which $(RUNTIME_TOOL)
@echo ""
install: dependencies
dependencies:
@echo "################################################################################"
@echo "## Dependencies: ###############################################################"
@echo "################################################################################"
${PACKAGE_TOOL} restore --verbosity ${VERBOSITY_LEVEL}
@echo "################################################################################"
lint/markdown:
markdownlint --config .markdownlint.json '**/*.md' && echo '✔ Your code looks good.'
lint/yaml:
yamllint --strict . && echo '✔ Your code looks good.'
lint/json:
prettier --check ./src/**/*.json
lint: test/styling test/static
lint/all: lint/markdown lint/yaml lint/json test/styling test/static
test/static: dependencies
test/styling: dependencies
${PACKAGE_TOOL} format --verify-no-changes --verbosity ${VERBOSITY_LEVEL}
format/json:
prettier --write ./**/*.json
format/sources:
${PACKAGE_TOOL} format --verbosity ${VERBOSITY_LEVEL}
format: format/sources format/json
build: env dependencies
${PACKAGE_TOOL} build --verbosity ${VERBOSITY_LEVEL}
release: dependencies
${PACKAGE_TOOL} publish --verbosity ${VERBOSITY_LEVEL}
test: build
${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL} \
--collect:"Code Coverage" \
--logger "console;verbosity=detailed"
coverage/test:
${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL} \
--collect:"Code Coverage" \
--logger "console;verbosity=detailed" \
--property:CollectCoverage=true
coverage/summary: coverage/test
@echo "################################################################################"
@echo "## Coverage Summary: ###########################################################"
@echo "################################################################################"
cat coverage-report/Summary.txt
@echo "################################################################################"
coverage: coverage/test coverage/summary
coverage/html: dependencies coverage/test
@if [ "$$(uname)" = "Darwin" ]; then \
open coverage-report/index.html; \
elif [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "mingw32" ] || [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "mingw64" ] || [ "$$(uname | tr '[:upper:]' '[:lower:]')" = "cygwin" ]; then \
cmd /c start coverage-report/index.html; \
else \
echo "Coverage HTML generated: coverage-report/index.html"; \
fi
outdated:
update:
upgrade:
clean:
${PACKAGE_TOOL} clean --verbosity ${VERBOSITY_LEVEL}
rm -vfr .mono/ || true
rm -vfr coverage-report/ || true
find ./src/ -path "*/TestResults/*" -type d -print -exec rm -vfr {} ';' || true
find ./src/ -path "*/bin/*" -print -exec rm -vfr {} ';' || true
find ./src/ -path "*/obj/*" -print -exec rm -vfr {} ';' || true
find ./src/ -path "*/coverage*" -print -exec rm -vfr {} ';' || true
find . -type d -print -empty -delete || true
compose/build: env
${DOCKER_COMPOSE} --profile lint build
${DOCKER_COMPOSE} --profile testing build
${DOCKER_COMPOSE} --profile production build
compose/rebuild: env
${DOCKER_COMPOSE} --profile lint build --no-cache
${DOCKER_COMPOSE} --profile testing build --no-cache
${DOCKER_COMPOSE} --profile production build --no-cache
compose/lint/markdown:
${DOCKER_COMPOSE} --profile lint run --rm \
--workdir /workspace \
-v "$$(pwd):/workspace" \
markdownlint --config /workspace/.markdownlint.json '/workspace/**/*.md' \
&& echo '✔ Your code looks good.'
compose/lint/yaml:
${DOCKER_COMPOSE} --profile lint run --rm \
--workdir /workspace \
-v "$$(pwd):/workspace" \
yamllint --strict . \
&& echo '✔ Your code looks good.'
compose/lint/json:
${DOCKER_COMPOSE} --profile lint run --rm \
--workdir /workspace \
-v "$$(pwd):/workspace" \
prettier --check /workspace/**/*.json \
&& echo '✔ Your code looks good.'
compose/test/styling: compose/build
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make test/styling
compose/test/static: compose/build
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make test/static
compose/lint: compose/test/styling compose/test/static
compose/lint/all: compose/lint/markdown compose/lint/yaml compose/lint/json compose/test/styling compose/test/static
compose/test: compose/build
${DOCKER_COMPOSE} --profile testing run --rm algorithm-exercises-csharp-test make test
compose/run: compose/build
${DOCKER_COMPOSE} --profile production run --rm algorithm-exercises-csharp make run
all:
$(call crono, make clean && make dependencies && make build && make test && make lint && make coverage/html)
run:
ls -alh