From 7d8ccc47701bebf1cf6ee373c7fac4478c2a1ed0 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Mon, 16 Dec 2024 17:24:59 +0100 Subject: [PATCH] chore(injector): add lint check for injector C sources --- Makefile | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8c53f133..20117623 100644 --- a/Makefile +++ b/Makefile @@ -172,6 +172,10 @@ golangci-lint: golangci-lint-install @echo "-------------------------------- (linting Go code)" $(GOLANGCI_LINT) run +.PHONY: golang-lint-fix +golang-lint-fix: golangci-lint-install + $(GOLANGCI_LINT) run --fix + .PHONY: helm-chart-lint helm-chart-lint: @echo "-------------------------------- (linting Helm charts)" @@ -200,12 +204,28 @@ prometheus-crd-version-check: @echo "-------------------------------- (verifying the Prometheus CRD version is in sync)" ./test-resources/bin/prometheus-crd-version-check.sh +.PHONY: c-lint-installed +c-lint-installed: + @set +x + @if ! clang-format --version > /dev/null; then \ + echo "error: clang-format is not installed. Run 'brew install clang-format' or similar."; \ + exit 1; \ + fi + +.PHONY: c-lint +c-lint: c-lint-installed + @echo "-------------------------------- (linting C source files)" + clang-format --dry-run --Werror images/instrumentation/injector/src/*.c + +.PHONY: c-lint-fix +c-lint-fix: c-lint-installed + clang-format -i images/instrumentation/injector/src/*.c + .PHONY: lint -lint: golangci-lint helm-chart-lint shellcheck-lint prometheus-crd-version-check +lint: golangci-lint helm-chart-lint shellcheck-lint prometheus-crd-version-check c-lint .PHONY: lint-fix -lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes - $(GOLANGCI_LINT) run --fix +lint-fix: golang-lint-fix c-lint-fix ##@ Build