fleet/Makefile

148 lines
3.5 KiB
Makefile
Raw Normal View History

.PHONY: build
2016-09-20 18:03:42 +00:00
PATH := $(GOPATH)/bin:$(shell npm bin):$(PATH)
ifeq ($(OS), Windows_NT)
GC_OFF = set GOGC=off &&
else
GC_OFF = GOGC=off
endif
2016-09-20 18:03:42 +00:00
ifneq ($(OS), Windows_NT)
ifeq ($(shell uname), Darwin)
SHELL := /bin/bash
endif
endif
ifeq ($(OS), Windows_NT)
2016-09-20 02:37:47 +00:00
OUTPUT = build/kolide.exe
else
2016-09-20 02:37:47 +00:00
OUTPUT = build/kolide
endif
2016-09-20 02:37:47 +00:00
VERSION = 0.0.0-development
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
USER = $(shell whoami)
ifeq ($(OS), Windows_NT)
2016-09-20 02:37:47 +00:00
GOVERSION_CMD = "(go version).Split()[2]"
GOVERSION = $(shell powershell $(GOVERSION_CMD))
NOW = $(shell powershell Get-Date -format s)
else
2016-09-20 02:37:47 +00:00
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
endif
DOCKER_IMAGE_NAME = kolide/kolide
ifndef CIRCLE_PR_NUMBER
DOCKER_IMAGE_TAG = latest
else
2016-09-20 02:37:47 +00:00
DOCKER_IMAGE_TAG = dev-${CIRCLE_PR_NUMBER}
endif
all: build
define HELP_TEXT
Makefile commands
make deps - Install depedent programs and libraries
make generate - Generate and bundle required code
make generate-dev - Generate and bundle required code in a watch loop
make distclean - Delete all build artifacts
make build - Build the code
make test - Run the full test suite
make test-go - Run the Go tests
make test-js - Run the JavaScript tests
make lint-go - Run the Go linters
make lint-js - Run the JavaScript linters
make run - Run the Kolide server in dev mode
2016-09-20 02:37:47 +00:00
endef
help:
$(info $(HELP_TEXT))
.prefix:
ifeq ($(OS), Windows_NT)
if not exist build mkdir build
else
2016-09-20 02:37:47 +00:00
mkdir -p build
endif
build: .prefix
${GC_OFF} go build -i -o ${OUTPUT} -ldflags "\
-X github.com/kolide/kolide-ose/server/version.version=${VERSION} \
-X github.com/kolide/kolide-ose/server/version.branch=${BRANCH} \
-X github.com/kolide/kolide-ose/server/version.revision=${REVISION} \
-X github.com/kolide/kolide-ose/server/version.buildDate=${NOW} \
-X github.com/kolide/kolide-ose/server/version.buildUser=${USER} \
-X github.com/kolide/kolide-ose/server/version.goVersion=${GOVERSION}"
lint-js:
2016-09-20 13:42:08 +00:00
eslint frontend --ext .js,.jsx
lint-scss:
sass-lint --verbose
lint-go:
go vet $(shell glide nv)
lint: lint-go lint-js
test-go:
go test -cover $(shell glide nv)
test-js:
2016-09-20 02:37:47 +00:00
_mocha --compilers js:babel-core/register \
--recursive 'frontend/**/*.tests.js*' \
--require ignore-styles \
--require 'frontend/.test.setup.js' \
--require 'frontend/test/loaderMock.js'
test: lint-go lint-js lint-scss test-go test-js
generate: .prefix
webpack --progress --colors
2016-09-26 18:48:55 +00:00
go-bindata -pkg=service \
-o=server/service/bindata.go \
2016-09-20 02:37:47 +00:00
frontend/templates/ assets/...
2016-09-06 15:08:11 +00:00
# we first generate the webpack bundle so that bindata knows to watch the
# output bundle file. then, generate debug bindata source file. finally, we
# run webpack in watch mode to continuously re-generate the bundle
2016-09-06 15:08:11 +00:00
generate-dev: .prefix
webpack --progress --colors
2016-09-26 18:48:55 +00:00
go-bindata -debug -pkg=service \
-o=server/service/bindata.go \
2016-09-20 02:37:47 +00:00
frontend/templates/ assets/...
webpack --progress --colors --watch
deps:
2016-09-08 02:57:05 +00:00
npm install
2016-09-20 02:37:47 +00:00
go get github.com/jteeuwen/go-bindata/...
go get github.com/Masterminds/glide
glide install
2016-08-10 15:31:27 +00:00
distclean:
2016-09-20 02:37:47 +00:00
ifeq ($(OS), Windows_NT)
if exist build rmdir /s/q build
if exist vendor rmdir /s/q vendor
if exist assets\bundle.js del assets\bundle.js
else
rm -rf build vendor
rm -f assets/bundle.js
endif
run:
$(OUTPUT) serve --dev
docker-build-circle:
@echo ">> building docker image"
docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" .
docker push "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"