You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.8 KiB

IMAGE_NAME ?= erikh/ldnsd:testing
RELEASE_IMAGE_NAME ?= erikh/ldnsd:$(shell cat VERSION)
CODE_PATH ?= /go/src/
GO_TEST := sudo go test -v ./... -race -count 1
GO_BENCH := sudo go test -v -bench ./... -benchtime 1m
VERSION ?= $(shell git rev-parse HEAD)
DOCKER_CMD := docker run -it \
--rm \
-e IN_DOCKER=1 \
-e SETUID=$$(id -u) \
-e SETGID=$$(id -g) \
-w $(CODE_PATH) \
-v ${PWD}/.go-cache:/tmp/go-build-cache \
-v ${PWD}:$(CODE_PATH) \
mkdir -p .go-cache
release: distclean generate-check mkcache
GOBIN=${PWD}/build/ldnsd-$$(cat VERSION) VERSION=$$(cat VERSION) make lint install
# FIXME include
cp example.conf build/ldnsd-$$(cat VERSION)
cd build && tar cvzf ../ldnsd-$$(cat ../VERSION).tar.gz ldnsd-$$(cat ../VERSION)
release-image: mkcache
VERSION=$$(cat VERSION) box -t $(RELEASE_IMAGE_NAME) box-release.rb
rm -rf build
GOBIN=${GOPATH}/bin go install -v
VERSION=${VERSION} go generate -v ./...
go install -v ./...
shell: build
mkdir -p .go-cache
build: get-box mkcache
box -t $(IMAGE_NAME) box.rb
@if [ -z "$${IN_DOCKER}" ]; then echo "You really don't want to do this"; exit 1; fi
start: docker-check stop
sudo ldnsd example.conf &
stop: docker-check
sudo pkill ldnsd || :
@if [ ! -f "$(shell which box)" ]; \
then \
echo "Need to install box to build the docker images we use. Requires root access."; \
curl -sSL | sudo bash; \
generate-check: generate
git diff --exit-code
if [ -z "$${IN_DOCKER}" ]; then make build && $(DOCKER_CMD) go generate -v ./...; else go generate -v ./...; fi
test: generate
if [ -z "$${IN_DOCKER}" ]; then make build && $(DOCKER_CMD) $(GO_TEST); else $(GO_TEST); fi
bench: generate
if [ -z "$${IN_DOCKER}" ]; then make build && $(DOCKER_CMD) $(GO_BENCH); else $(GO_BENCH); fi
golangci-lint run -v
apt-get update -qq && apt-get install unzip curl -y
curl -sSL -o /
ci-protobuf: ci-get-pkgs
unzip / -d /usr
chmod -R 755 /usr/bin/protoc /usr/include/google
# these tasks account for the standard golang container image not containing protobuf tools
ci-generate: ci-protobuf
go get -v
go generate -v ./...
ci-test: ci-generate mkcert
go test -v -race -count 1 ./...
ci-bench: ci-generate mkcert
go test -v -bench ./... -benchtime 1m
get-mkcert: ci-get-pkgs
curl -sSL -o /usr/local/bin/mkcert
chmod 755 /usr/local/bin/mkcert
mkcert: get-mkcert
.PHONY: test