luet/Makefile

98 lines
2.5 KiB
Makefile
Raw Normal View History

# go tool nm ./luet | grep Commit
2020-05-26 19:07:09 +00:00
override LDFLAGS += -X "github.com/mudler/luet/cmd.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
override LDFLAGS += -X "github.com/mudler/luet/cmd.BuildCommit=$(shell git rev-parse HEAD)"
2019-06-05 16:20:39 +00:00
NAME ?= luet
PACKAGE_NAME ?= $(NAME)
PACKAGE_CONFLICT ?= $(PACKAGE_NAME)-beta
REVISION := $(shell git rev-parse --short HEAD || echo dev)
VERSION := $(shell git describe --tags || echo $(REVISION))
2019-06-05 16:20:39 +00:00
VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g')
BUILD_PLATFORMS ?= -osarch="linux/amd64" -osarch="linux/386" -osarch="linux/arm"
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2019-06-05 16:20:39 +00:00
.PHONY: all
all: deps build
2019-11-05 16:21:06 +00:00
.PHONY: fmt
fmt:
go fmt ./...
2019-06-05 16:20:39 +00:00
.PHONY: test
test:
2019-11-10 17:04:06 +00:00
GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo
GO111MODULE=off go get github.com/onsi/gomega/...
ginkgo -race -r -flakeAttempts 3 ./...
2019-06-05 16:20:39 +00:00
2019-12-31 14:22:11 +00:00
.PHONY: test-integration
test-integration:
tests/integration/run.sh
2019-06-11 16:04:57 +00:00
.PHONY: coverage
coverage:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
.PHONY: test-coverage
test-coverage:
scripts/ginkgo.coverage.sh --codecov
2019-06-05 16:20:39 +00:00
.PHONY: help
help:
# make all => deps test lint build
# make deps - install all dependencies
# make test - run project tests
# make lint - check project code style
# make build - build project for all supported OSes
.PHONY: clean
clean:
rm -rf release/
2019-12-31 14:22:11 +00:00
rm -rf tests/integration/shunit2
rm -rf tests/integration/bin
2019-06-05 16:20:39 +00:00
.PHONY: deps
deps:
go env
# Installing dependencies...
2019-11-10 17:04:06 +00:00
GO111MODULE=off go get golang.org/x/lint/golint
GO111MODULE=off go get github.com/mitchellh/gox
GO111MODULE=off go get golang.org/x/tools/cmd/cover
GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo
GO111MODULE=off go get github.com/onsi/gomega/...
2019-06-05 16:20:39 +00:00
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)'
2020-05-26 19:07:09 +00:00
.PHONY: build-small
build-small:
@$(MAKE) LDFLAGS+="-s -w" build
2020-06-12 16:47:18 +00:00
upx --brute -1 $(NAME)
2020-05-26 19:07:09 +00:00
.PHONY: image
image:
docker build --rm -t luet/base .
2019-06-05 16:20:39 +00:00
.PHONY: lint
lint:
golint ./... | grep -v "be unexported"
2019-11-10 17:04:06 +00:00
.PHONY: vendor
vendor:
go mod vendor
.PHONY: test-docker
test-docker:
docker run -v $(ROOT_DIR):/go/src/github.com/mudler/luet \
--workdir /go/src/github.com/mudler/luet -ti golang:latest \
bash -c "make test"
multiarch-build:
2020-06-13 16:40:55 +00:00
CGO_ENABLED=0 gox $(BUILD_PLATFORMS) -ldflags '$(LDFLAGS)' -output="release/$(NAME)-$(VERSION)-{{.OS}}-{{.Arch}}"
multiarch-build-small:
@$(MAKE) LDFLAGS+="-s -w" multiarch-build
for file in $(ROOT_DIR)/release/* ; do \
upx --brute -1 $${file} ; \
done