Skip to content

Commit c5b735b

Browse files
author
Gonzalo Diaz
committed
[CONFIG] Makefile added.
1 parent 70ec194 commit c5b735b

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

Makefile

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
## REFERENCES:
2+
## (1) Passing environment variable with fallback value to Makefile:
3+
## https://stackoverflow.com/a/70772707/6366150
4+
## (2) Export environment variables inside "make environment"
5+
## https://stackoverflow.com/a/49524393/6366150
6+
## (3) Uppercase to lowercase and vice versa
7+
## https://community.unix.com/t/uppercase-to-lowercase-and-vice-versa/285278/6
8+
## (4) How do I trim leading and trailing whitespace from each line of some output?
9+
## https://unix.stackexchange.com/a/279222/233927
10+
############################################################################
11+
12+
## (1) ## Allowed values: info | warn | error | debug
13+
LOG_LEVEL ?= info
14+
## (3) (4)
15+
LOG_LEVEL :=$(shell echo '${LOG_LEVEL}'| tr '[:lower:]' '[:upper:]'| tr -d '[:blank:]')
16+
17+
## (1) ## Allowed values: true | false
18+
BRUTEFORCE ?= false
19+
## (3) (4)
20+
BRUTEFORCE :=$(shell echo '${BRUTEFORCE}'| tr '[:lower:]' '[:upper:]'| tr -d '[:blank:]')
21+
22+
# DOCKER
23+
DOCKER_COMPOSE=docker compose
24+
25+
# Package Manager
26+
PACKAGE_MANAGER=cargo
27+
28+
# DOCKER
29+
# BUILDKIT_PROGRESS=plain
30+
# CGO_ENABLED=0
31+
32+
.MAIN: test/coverage
33+
.PHONY: all clean coverage dependencies help list test
34+
.EXPORT_ALL_VARIABLES: # (2)
35+
36+
help: list
37+
38+
list:
39+
@echo "Environment variables:"
40+
@echo "LOG_LEVEL = info | warn | error | debug"
41+
@echo "BRUTEFORCE = true | false"
42+
@echo ""
43+
@echo "Posible make commands:"
44+
@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 '^$@$$'
45+
46+
env:
47+
@echo "################################################################################"
48+
@echo "## Environment: ################################################################"
49+
@echo "################################################################################"
50+
@printenv | grep -E "LOG_LEVEL|BRUTEFORCE"
51+
@echo "################################################################################"
52+
53+
dependencies:
54+
@echo "################################################################################"
55+
@echo "## Dependencies: ###############################################################"
56+
@echo "################################################################################"
57+
$(PACKAGE_MANAGER) build --locked
58+
@echo "################################################################################"
59+
60+
lint/markdown:
61+
markdownlint '**/*.md' --ignore node_modules && echo '✔ Your code looks good.'
62+
63+
lint/yaml:
64+
yamllint --stric . && echo '✔ Your code looks good.'
65+
66+
lint: lint/markdown lint/yaml test/styling test/static
67+
68+
test/static: dependencies
69+
70+
test/styling: dependencies
71+
72+
format:
73+
74+
test: env dependencies
75+
$(PACKAGE_MANAGER) test
76+
77+
coverage: test
78+
$(PACKAGE_MANAGER) llvm-cov --all-features --workspace --lcov --output-path lcov.info
79+
80+
coverage/html:
81+
82+
outdated:
83+
84+
update: dependencies outdated
85+
86+
upgrade: update
87+
88+
clean:
89+
rm -vfr ./target || true
90+
mkdir -p ./target
91+
touch ./target/.gitkeep
92+
93+
build: env dependencies
94+
$(PACKAGE_MANAGER) build
95+
96+
# compose/build: env
97+
# ${DOCKER_COMPOSE} --profile lint build
98+
# ${DOCKER_COMPOSE} --profile testing build
99+
# ${DOCKER_COMPOSE} --profile production build
100+
101+
# compose/rebuild: env
102+
# ${DOCKER_COMPOSE} --profile lint build --no-cache
103+
# ${DOCKER_COMPOSE} --profile testing build --no-cache
104+
# ${DOCKER_COMPOSE} --profile production build
105+
106+
# compose/lint/markdown: compose/build
107+
# ${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-go-lint make lint/markdown
108+
109+
# compose/lint/yaml: compose/build
110+
# ${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-go-lint make lint/yaml
111+
112+
# compose/test/styling: compose/build
113+
# ${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-go-lint make test/styling
114+
115+
# compose/test/static: compose/build
116+
# ${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-go-lint make test/static
117+
118+
# compose/lint: compose/lint/markdown compose/lint/yaml compose/test/styling compose/test/static
119+
120+
# compose/test: compose/build
121+
# ${DOCKER_COMPOSE} --profile testing run --rm algorithm-exercises-go-test make test
122+
123+
# compose/run: compose/build
124+
# ${DOCKER_COMPOSE} --profile production run --rm algorithm-exercises-go
125+
126+
all: test coverage
127+
128+
run:
129+
ls -alh

0 commit comments

Comments
 (0)