fleet/Makefile

155 lines
4.2 KiB
Makefile
Raw Normal View History

.PHONY: build
2016-09-20 18:03:42 +00:00
PATH := $(GOPATH)/bin:$(shell npm bin):$(PATH)
VERSION = 0.0.0-development
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
REVSHORT = $(shell git rev-parse --short HEAD)
USER = $(shell whoami)
DOCKER_IMAGE_NAME = kolide/kolide
2016-09-20 18:03:42 +00:00
ifneq ($(OS), Windows_NT)
# If on macOS, set the shell to bash explicitly
2016-09-20 18:03:42 +00:00
ifeq ($(shell uname), Darwin)
SHELL := /bin/bash
endif
# The output binary name is different on Windows, so we're explicit here
2016-09-20 02:37:47 +00:00
OUTPUT = build/kolide
# To populate version metadata, we use unix tools to get certain data
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
else
# The output binary name is different on Windows, so we're explicit here
OUTPUT = build/kolide.exe
2016-09-20 02:37:47 +00:00
# To populate version metadata, we use windows tools to get the certain data
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)
endif
ifndef CIRCLE_PR_NUMBER
DOCKER_IMAGE_TAG = ${REVSHORT}
else
DOCKER_IMAGE_TAG = dev-${CIRCLE_PR_NUMBER}-${REVSHORT}
2016-09-20 02:37:47 +00:00
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
2016-10-31 13:56:13 +00:00
make lint - Run all linters
2016-09-20 02:37:47 +00:00
make lint-go - Run the Go linters
make lint-js - Run the JavaScript linters
2016-10-31 13:56:13 +00:00
make lint-scss - Run the SCSS linters
make lint-ts - Run the TypeScript linters
2016-09-20 02:37:47 +00:00
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: export GOGC = off
build: .prefix
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
2016-10-31 21:02:06 +00:00
lint-ts:
tslint frontend/**/*.tsx frontend/**/*.ts
lint-scss:
sass-lint --verbose
lint-go:
go vet $(shell glide nv)
2016-10-31 21:02:06 +00:00
lint: lint-go lint-js lint-scss lint-ts
test-go:
go test -cover $(shell glide nv)
test-js: export NODE_PATH = ./frontend
test-js:
_mocha --compilers js:babel-core/register,tsx:typescript-require \
--recursive "frontend/**/*.tests.js*" \
--require ignore-styles \
--require "frontend/.test.setup.js" \
--require "frontend/test/loaderMock.js"
2016-10-31 13:56:13 +00:00
test: lint 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/...
go-bindata -pkg=kolide -o=server/kolide/bindata.go server/mail/templates
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/...
go-bindata -pkg=kolide -o=server/kolide/bindata.go server/mail/templates
webpack --progress --colors --watch --notify
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}"