# 2019 Rackspace, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # Variables to be used throughout the makefile. Most of these will be passed in as # ldflags when building/compiling the application. app_name := DCM/gomigrate version := $(shell cat VERSION) hash := $(shell git rev-parse HEAD) timestamp := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p') flavor ?= swagger .PHONY: all lint test # Default call to GNU make. Basically displays that the variables needed to run the # subsequent make functions are being pulled correctly all: @echo $(app_name): v$(version) @echo "\tgit hash: $(hash)" @echo "\ttimestamp: $(timestamp)" @echo "\nTop-level commands:\n\tmake lint\n\tmake build\n\tmake test\n\tmake nagios" # Small function to run golint for the packages directories lint: ## Run golint on all sub-packages @echo "Running linters on all sub-packages\n" golangci-lint run --exclude-use-default=false check_for_pass: ifndef MAKE_PASS $(error MAKE_PASS environment variable not defined, please set with 'export MAKE_PASS=""') endif help: # Ref: https://github.rackspace.com/engineering/handbook/blob/master/Makefile @echo "" @echo "GO MIGRATE TOOL" @echo "" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' release: ## Release a new version and build, tag. golangci-lint run rm -rf build/* git tag $(version) goreleaser release --clean testrelease: ## Test a release golangci-lint run git tag $(version) goreleaser --snapshot git tag -d $(version) # Test related actions # This action should run all tests related to gomigrate test: \ test_exnetxlate \ test_changedc \ test_findha \ test_publicxlate \ test_uglyservers \ test_shared \ ## Run all test coverage and post results to gh-pages # Run test for the exnetxlate package test_exnetxlate: go test -v -short github.rackspace.com/$(app_name)/plugins/exnetxlate # Run test for the changedc package test_changedc: go test -v -short github.rackspace.com/$(app_name)/plugins/changedc # Run test for the findha package test_findha: go test -v -short github.rackspace.com/$(app_name)/plugins/findha # Run test for the publicxlate package test_publicxlate: go test -v -short github.rackspace.com/$(app_name)/plugins/publicxlate # Run test for the uglyservers package test_uglyservers: go test -v -short github.rackspace.com/$(app_name)/plugins/uglyservers # Run test for the shared package test_shared: go test -v -short github.rackspace.com/$(app_name)/shared