Skip to content
Snippets Groups Projects
Select Git revision
  • 579e061de146312a8804ecccfcb2f322c2077265
  • main default protected
  • drip-server-timing
  • compress-middleware
  • v2.11.0
  • v2.10.0
  • v2.9.2
  • v2.9.1
  • v2.9.0
  • v2.8.0
  • v2.7.0
  • v2.6.0
  • v2.5.6
  • v2.5.5
  • v2.5.4
  • v2.5.3
  • v2.5.2
  • v2.5.1
  • v2.5.0
  • v2.4.2
  • v2.4.1
  • v2.4.0
  • v2.3.0
  • v2.2.2
24 results

Makefile

Blame
  • Makefile 3.06 KiB
    # The version that will be used in docker tags (e.g. to push a
    # go-httpbin:latest image use `make imagepush VERSION=latest)`
    VERSION    ?= $(shell git rev-parse --short HEAD)
    DOCKER_TAG ?= mccutchen/go-httpbin:$(VERSION)
    
    # Built binaries will be placed here
    DIST_PATH  	  ?= dist
    
    # Default flags used by the test, testci, testcover targets
    COVERAGE_PATH ?= coverage.txt
    COVERAGE_ARGS ?= -covermode=atomic -coverprofile=$(COVERAGE_PATH)
    TEST_ARGS     ?= -race
    
    # Tool dependencies
    TOOL_BIN_DIR     ?= $(shell go env GOPATH)/bin
    TOOL_GOLINT      := $(TOOL_BIN_DIR)/golint
    TOOL_STATICCHECK := $(TOOL_BIN_DIR)/staticcheck
    
    
    # =============================================================================
    # build
    # =============================================================================
    build:
    	mkdir -p $(DIST_PATH)
    	CGO_ENABLED=0 go build -ldflags="-s -w" -o $(DIST_PATH)/go-httpbin ./cmd/go-httpbin
    .PHONY: build
    
    buildtests:
    	CGO_ENABLED=0 go test -ldflags="-s -w" -v -c -o $(DIST_PATH)/go-httpbin.test ./httpbin
    .PHONY: buildtests
    
    clean:
    	rm -rf $(DIST_PATH) $(COVERAGE_PATH)
    .PHONY: clean
    
    
    # =============================================================================
    # test & lint
    # =============================================================================
    test:
    	go test $(TEST_ARGS) ./...
    .PHONY: test
    
    
    # Test command to run for continuous integration, which includes code coverage
    # based on codecov.io's documentation:
    # https://github.com/codecov/example-go/blob/b85638743b972bd0bd2af63421fe513c6f968930/README.md
    testci: build
    	go test $(TEST_ARGS) $(COVERAGE_ARGS) ./...
    	git diff --exit-code
    .PHONY: testci
    
    testcover: testci
    	go tool cover -html=$(COVERAGE_PATH)
    .PHONY: testcover
    
    lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
    	test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1)
    	go vet ./...
    	$(TOOL_GOLINT) -set_exit_status ./...
    	$(TOOL_STATICCHECK) ./...
    .PHONY: lint
    
    
    # =============================================================================
    # run locally
    # =============================================================================
    run: build
    	$(DIST_PATH)/go-httpbin
    .PHONY: run