...

Text file src/github.com/datawire/ambassador/v2/build-aux/lint.mk

Documentation: github.com/datawire/ambassador/v2/build-aux

     1include build-aux/tools.mk
     2
     3#
     4# Go
     5
     6lint-deps += $(tools/golangci-lint)
     7lint-goals += lint/go
     8lint/go: $(tools/golangci-lint)
     9	$(tools/golangci-lint) run ./...
    10.PHONY: lint/go
    11
    12format-goals += format/go
    13format/go: $(tools/golangci-lint)
    14	$(tools/golangci-lint) run --fix ./... || true
    15.PHONY: format/go
    16
    17#
    18# Python
    19
    20lint-deps += $(OSS_HOME)/venv
    21
    22lint-goals += lint/mypy
    23lint/mypy: $(OSS_HOME)/venv
    24	set -e; { \
    25	  . $(OSS_HOME)/venv/bin/activate; \
    26	  time mypy \
    27	    --cache-fine-grained \
    28	    --follow-imports=skip \
    29	    --ignore-missing-imports \
    30	    ./python/; \
    31	}
    32.PHONY: lint/mypy
    33clean: .dmypy.json.rm .mypy_cache.rm-r
    34
    35lint-goals += lint/black
    36lint/black: $(OSS_HOME)/venv
    37	. $(OSS_HOME)/venv/bin/activate && black --check ./python/
    38.PHONY: lint/black
    39
    40format-goals += format/black
    41format/black: $(OSS_HOME)/venv
    42	. $(OSS_HOME)/venv/bin/activate && black ./python/
    43.PHONY: format/black
    44
    45lint-goals += lint/isort
    46lint/isort: $(OSS_HOME)/venv
    47	. $(OSS_HOME)/venv/bin/activate && isort --check --diff ./python/
    48.PHONY: lint/isort
    49
    50format-goals += format/isort
    51format/isort: $(OSS_HOME)/venv
    52	. $(OSS_HOME)/venv/bin/activate && isort ./python/
    53.PHONY: format/isort
    54
    55#
    56# Helm
    57
    58lint-deps += $(tools/ct) $(chart_dir)
    59lint-goals += lint/chart
    60lint/chart: $(tools/ct) $(chart_dir)
    61	cd $(chart_dir) && $(abspath $(tools/ct)) lint --config=./ct.yaml
    62.PHONY: lint/chart
    63
    64#
    65# All together now
    66
    67lint-deps: ## (QA) Everything necessary to lint (useful to separate out in the logs)
    68lint-deps: $(lint-deps)
    69.PHONY: lint-deps
    70
    71lint: ## (QA) Run the linters
    72lint: lint-deps
    73	@printf "$(GRN)==> $(BLU)Running linters...$(END)\n"
    74	@{ \
    75	  r=0; \
    76	  for goal in $(lint-goals); do \
    77	    printf " $(BLU)=> $${goal}$(END)\n"; \
    78	    echo "$(MAKE) $${goal}"; \
    79	    $(MAKE) "$${goal}" || r=$$?; \
    80	  done; \
    81	  exit $$r; \
    82	}
    83.PHONY: lint
    84
    85format: ## (QA) Automatically fix linter complaints
    86format: $(format-goals)
    87.PHONY: format

View as plain text