github.com/google/cadvisor@v0.49.1/Makefile (about)

     1  # Copyright 2015 Google Inc. All rights reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  GO := go
    16  GOLANGCI_VER := v1.56.2
    17  GO_TEST ?= $(GO) test $(or $(GO_FLAGS),-race)
    18  arch ?= $(shell go env GOARCH)
    19  
    20  all: presubmit build test
    21  
    22  test:
    23  	@echo ">> running tests"
    24  	@# Filter out integration.
    25  	$(GO) list ./... | grep -vw integration | xargs $(GO_TEST)
    26  	cd cmd && $(GO_TEST) ./...
    27  
    28  test-with-libpfm: GO_FLAGS=-race -tags libpfm
    29  test-with-libpfm: test
    30  
    31  container-test:
    32  	@echo ">> runinng tests in a container"
    33  	@./build/unit-in-container.sh
    34  
    35  docker-test: container-test
    36  	@echo "docker-test target is deprecated, use container-test instead"
    37  
    38  test-integration:
    39  	GO_FLAGS=$(or $(GO_FLAGS),-race) ./build/build.sh
    40  	$(GO_TEST) -c github.com/google/cadvisor/integration/tests/api
    41  	$(GO_TEST) -c github.com/google/cadvisor/integration/tests/healthz
    42  	@./build/integration.sh
    43  
    44  docker-test-integration:
    45  	@./build/integration-in-docker.sh
    46  
    47  test-runner:
    48  	@$(GO) build github.com/google/cadvisor/integration/runner
    49  
    50  tidy:
    51  	@$(GO) mod tidy
    52  	@cd cmd && $(GO) mod tidy
    53  
    54  format:
    55  	@echo ">> formatting code"
    56  	@# goimports is a superset of gofmt.
    57  	@goimports -w -local github.com/google/cadvisor .
    58  
    59  build: assets
    60  	@echo ">> building binaries"
    61  	@./build/build.sh $(arch)
    62  
    63  assets:
    64  	@echo ">> building assets"
    65  	@./build/assets.sh
    66  
    67  release:
    68  	@echo ">> building release binaries"
    69  	@./build/release.sh
    70  
    71  docker-%:
    72  	@docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile .
    73  
    74  docker-build:
    75  	@docker run --rm -w /go/src/github.com/google/cadvisor -v ${PWD}:/go/src/github.com/google/cadvisor golang:1.22 make build
    76  
    77  presubmit: lint
    78  	@echo ">> checking go mod tidy"
    79  	@./build/check_gotidy.sh
    80  	@echo ">> checking file boilerplate"
    81  	@./build/check_boilerplate.sh
    82  
    83  lint:
    84  	@# This assumes GOPATH/bin is in $PATH -- if not, the target will fail.
    85  	@if ! golangci-lint version | grep $(GOLANGCI_VER); then \
    86  		echo ">> installing golangci-lint $(GOLANGCI_VER)"; \
    87  		curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_VER); \
    88  	fi
    89  	@echo ">> running golangci-lint using configuration at .golangci.yml"
    90  	@golangci-lint run
    91  	@cd cmd && golangci-lint run
    92  
    93  clean:
    94  	@rm -f *.test cadvisor
    95  	@rm -rf _output/
    96  
    97  .PHONY: all build docker format release test test-integration lint presubmit tidy