forked from TrueCloudLab/frostfs-api
Bruk Ori
3cb6553234
Add additional description to compatibility linter. Change the release name to reflect the new convention. Signed-off-by: Ori Bruk <o.bruk@yadro.com>
75 lines
2.5 KiB
Makefile
Executable file
75 lines
2.5 KiB
Makefile
Executable file
#!/usr/bin/make -f
|
|
SHELL=bash
|
|
|
|
include help.mk
|
|
|
|
.PHONY: doc fmt check-version compatibility pre-commit unpre-commit pre-commit-run
|
|
|
|
# Regenerate documentation for proto files:
|
|
doc:
|
|
@for f in `find . -type f -name '*.proto' -exec dirname {} \; | sort -u `; do \
|
|
echo "⇒ Documentation for $$(basename $$f)"; \
|
|
protoc \
|
|
--doc_opt=.github/markdown.tmpl,$${f}.md \
|
|
--proto_path=.:/usr/local/include \
|
|
--doc_out=proto-docs/ $${f}/*.proto; \
|
|
done
|
|
|
|
# Run clang-format
|
|
fmt:
|
|
@for f in `ls **/*.proto`; do \
|
|
echo "⇒ Formatting $$f"; \
|
|
clang-format -i $$f; \
|
|
done
|
|
|
|
# Run version update check in version.json file
|
|
check-version:
|
|
@version=$$(git show remotes/origin/master:version.json); \
|
|
if [ -z "$$version" ]; then \
|
|
exit; \
|
|
fi; \
|
|
masterMilestone=$$(jq -n --argjson data "$$version" '$$data.milestone'); \
|
|
masterPatch=$$(jq -n --argjson data "$$version" '$$data.patch'); \
|
|
milestone=$$(jq -r '.milestone' version.json); \
|
|
patch=$$(jq -r '.patch' version.json); \
|
|
if [ "$$masterMilestone" -eq "$$milestone" -a "$$masterPatch" -eq "$$patch" ]; then \
|
|
echo "⇒ You need to update the api version in the version.json file"; \
|
|
exit 1; \
|
|
elif [ "$$masterMilestone" -gt "$$milestone" ]; then \
|
|
echo "⇒ The milestone cannot be decrement in the version.json file"; \
|
|
exit 1; \
|
|
elif [ "$$masterMilestone" -eq "$$milestone" -a "$$masterPatch" -gt "$$patch" ]; then \
|
|
echo "⇒ The patch cannot be decrement without milestone increment in the version.json file"; \
|
|
exit 1; \
|
|
elif [ "$$masterMilestone" -lt "$$milestone" -a "$$patch" -ne 0 ]; then \
|
|
echo "⇒ The patch should be 0 after milestone increment in the version.json file"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
# Run a compatibility information check \
|
|
Checks that the files that describe compatibility in the compatibility package \
|
|
have the current version information added in the version.json file
|
|
compatibility:
|
|
@version=$$(jq -r '.milestone' version.json).$$(jq -r '.patch' version.json); \
|
|
conflicts=0; \
|
|
for f in `ls **/*.json`; do \
|
|
for rpc in $$(jq -r '.[] | to_entries | .[].key' $$f); do \
|
|
if $$(jq -r '.[].'$$rpc' | has("v'$$version'") | not' $$f); then \
|
|
echo "⇒ No compatibility information found for version" $$version "in file" $$f "for rpc" $$rpc; \
|
|
conflicts=$$(($conflicts+1)); \
|
|
fi \
|
|
done \
|
|
done; \
|
|
exit $$conflicts;
|
|
|
|
# Activate pre-commit hooks
|
|
pre-commit:
|
|
pre-commit install --hook-type pre-commit
|
|
|
|
# Deactivate pre-commit hooks
|
|
unpre-commit:
|
|
pre-commit uninstall --hook-type pre-commit
|
|
|
|
# Run pre-commit hooks
|
|
pre-commit-run:
|
|
@pre-commit run --all-files --hook-stage manual
|