diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d697a38..00000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: go - -go: - - 1.7.x - -os: - - linux - -## Encrypted GITHUB_TOKEN -env: - secure: Y2fHWCGvx3ngUdx2siNT55cQ6rJGjtwIQIvrfjtetaXUQw0D3WHc+7hU52horb7kutD1C2BG4OBPxMOl0PtS2+3fy0p2LSI6hy1UPoVs00YWkTIqlNzfdLv9ATi+xdF8VqpjgHB+bQRMohiBKdfN/oWcrszLdukAWwL4EsMinlRKol+RODduQruG9jXWBoQIyoiutargapyEaTLDxRcCsUome9LKlzwd+mQlpO1maQrvop/QYBinglkehJ1DSLtgzl7tdHm4tEix/4+7eGX8NL4dMiA6xxKQg4JT2kbRr5Tb35QEPonA9D1DJ9JPkX+KRiatGGw2FMBofMPBB/NkliRMg6nkqn2yPshXfvnin/RhyMbrlBLNRoeO0z3puyPdmy3whQMNqhnd0QC0y53t/MGNhhoPxJVrctljz9AyZ0WRGSdXW0oCGa91gnKUKobZs8foQA6LQXTCJzLUl5WP8iiWcXX8kWE8+XcO0NuD1Bo6i30HUTLk+H91b/pSK8ewvHfaXqsjNaMFdFvuFjfEGnm8O9II+Dvr2equo3TvhEY+TQ1EeUVeXR8tp33rSKhBeoaMNpTghmNueI0PzUyG/giqTVM81nysHTfe8lQE1bfTphu2mth4Zuq86jsPNorII2yAtlP6qvbV6uAGPvYJ5XYHG7OBeRIaeqRS480hbNg= - - -## Don't buid when new release tags are pushed -branches: - except: - - /^v[0-9]/ - -## Setup GitHub credentials so we can push tags -before_deploy: - - git config credential.helper "store --file=.git/credentials" - - echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials - -deploy: - ## Create 'pre-release' from 'develop' branch - - provider: script - skip_cleanup: true - script: make dev-release - on: - branch: develop - ## Create 'release' from 'master' branch - - provider: script - skip_cleanup: true - script: make release - on: - branch: master - -## Send notifications to 'builds' channel -notifications: - email: false - slack: - rooms: - - secure: g7a0GZU36Ix+6IhwWoPZCTDIG4JrqQj4ZW5yYU+nIwLahrxWm2FknztNrNBS/akswVAZFfvgFRsPJWY2SdLcCYGWmVb62VRlKrKiiXUFjXG2/RXRRk3Ivmm7ZMEWe9xFbvK8OwwV6aVK/A+lepB0ory5EE5kwdYCvDj2OWj3Hjeoy7vVMrVcFn+MnUek81XWRzdN0aiTeGZrDA/eT1BNyytk90Mc7AYsAsuMlRelo9s3x9bk0dVqjIpVJZ13+R/Kdoc/N8q1GznwaXScTfhG0UW/aLYLhlWy76QISsQUqM1wOPtuuRmnkezR7NOyEh8Bdo4NfuYfDFWhDru9mHuNMMXJKdh6R51uWmiTNxflZ2la2IoONDsQ/5PAhyVBqGbc30vqVF3IkLNkI+w3rGxI6+1dcBB+otpvwm6e/dQ0azHT8t5bdT2XJXndsdbDeVyAr2XHG01tHRrxZFG2eeEXCqabvNPI0vRqdo193W0eP0fnUDHUMrx1wHbVSEDrbzwM3DcOE9ZYzVv0YByXf8HHsRHNDUj+WjeeGFbYcOaGw3XQYZZ4ooqa9ttvA6dKvbrS9+JeePgfT/vKhEdUqbRZtn8zUBbNiEmT0cIaiF73kmjZh3+kep66hTji/NchAroTD/VQzgTmj2+8/p/uqU/7jSMa0COevb+xx1rgMPpHLV0= - on_success: change diff --git a/Makefile b/Makefile index d0e2f5cb..8308daaa 100644 --- a/Makefile +++ b/Makefile @@ -7,36 +7,44 @@ BRANCH := $(or $(TRAVIS_BRANCH), $(shell git rev-parse --abbrev-ref HEAD)) IS_MASTER := $(filter master, $(BRANCH)) VERSION := $(shell cat VERSION)$(if $(IS_MASTER),,-$(BRANCH)) ARCH := $(shell go env GOARCH) -BUILD_FILES = $(foreach os, $(TARGET_OS), .release/$(PACKAGE)-$(os)-$(ARCH)) +BUILD_DIR = $(if $(CIRCLE_ARTIFACTS),$(CIRCLE_ARTIFACTS),.release) +BUILD_FILES = $(foreach os, $(TARGET_OS), $(BUILD_DIR)/$(PACKAGE)-$(os)-$(ARCH)) UPLOAD_FILES = $(foreach os, $(TARGET_OS), $(PACKAGE)-$(os)-$(ARCH)) -GOLDFLAGS = "-X common.version=$(VERSION)" +GOLDFLAGS = "-X main.version=$(VERSION)" TAG_VERSION = v$(VERSION) default: build -setup: +deps: @echo "=== preparing $(VERSION) from $(BRANCH) ===" - mkdir -p .release - go get -u "github.com/golang/lint/golint" - go get -u "github.com/aktau/github-release" - go get -u "github.com/jteeuwen/go-bindata/..." + go get "github.com/jteeuwen/go-bindata/..." + go get "github.com/golang/lint/golint" + go get "github.com/jstemmer/go-junit-report" + go get "github.com/aktau/github-release" go get -t -d -v ./... go generate ./... -lint: setup +lint: @echo "=== linting ===" go vet ./... golint -set_exit_status ./... test: lint @echo "=== testing ===" +ifneq ($(CIRCLE_TEST_REPORTS),) + mkdir -p $(CIRCLE_TEST_REPORTS)/unit + go test -v -cover ./... | go-junit-report > $(CIRCLE_TEST_REPORTS)/unit/report.xml +else go test -cover ./... +endif + -build: test $(BUILD_FILES) +build: $(BUILD_FILES) -$(BUILD_FILES): setup +$(BUILD_FILES): @echo "=== building $(VERSION) - $@ ===" - GOOS=$(word 2,$(subst -, ,$@)) GOARCH=$(word 3,$(subst -, ,$@)) go build -ldflags=$(GOLDFLAGS) -o '$@' + mkdir -p $(BUILD_DIR) + GOOS=$(word 2,$(subst -, ,$(notdir $@))) GOARCH=$(word 3,$(subst -, ,$(notdir $@))) go build -ldflags=$(GOLDFLAGS) -o '$@' release-clean: ifeq ($(IS_MASTER),) @@ -54,7 +62,7 @@ release-create: release-clean $(TARGET_OS): release-create @echo "=== uploading $@ ===" - github-release upload -u $(ORG) -r $(PACKAGE) -t $(TAG_VERSION) -n "$(PACKAGE)-$@-$(ARCH)" -f ".release/$(PACKAGE)-$@-$(ARCH)" + github-release upload -u $(ORG) -r $(PACKAGE) -t $(TAG_VERSION) -n "$(PACKAGE)-$@-$(ARCH)" -f "$(BUILD_DIR)/$(PACKAGE)-$@-$(ARCH)" dev-release: $(TARGET_OS) @@ -69,6 +77,6 @@ endif clean: @echo "=== cleaning ===" - rm -rf .release + rm -rf $(BUILD_DIR) -.PHONY: default lint test build setup clean release-clean release-create dev-release release $(UPLOAD_FILES) $(TARGET_OS) +.PHONY: default lint test build deps clean release-clean release-create dev-release release $(UPLOAD_FILES) $(TARGET_OS) diff --git a/README.md b/README.md index 0627e62a..4eacfeae 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/stelligent/mu.svg?branch=develop)](https://travis-ci.org/stelligent/mu) +[![Build Status](https://circleci.com/gh/stelligent/mu.svg?style=svg)](https://circleci.com/gh/stelligent/mu) # Why? Amazon ECS (EC2 Container Service) provides an excellent platform for deploying microservices as containers. The challenge however is that there is a significant learning curve for microservice developers to deploy their applications in an efficient manner. Specifically, they must learn to use CloudFormation to orchestrate the management of ECS, ECR, EC2, ELB, VPC, and IAM resources. Additionally, tools like CodeBuild and CodePipeline must be mastered to create a continuous delivery pipeline for their microservices. diff --git a/VERSION b/VERSION index b1e80bb2..845639ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.3 +0.1.4 diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..c2a5c3fc --- /dev/null +++ b/circle.yml @@ -0,0 +1,42 @@ +## Don't build when new release tags are pushed +general: + branches: + ignore: + - /^v[0-9]/ + +## Run 'make deps' for resolving dependencies +dependencies: + override: + - make deps + +## Run 'make' for compile +compile: + override: + - make + +## Run 'make test' to test +test: + override: + - make test + + +## In order for deploy to work, you need an environment variable set in CircleCI named "GITHUB_TOKEN" that contains +## a token created from https://github.com/settings/tokens +## +## Also, an read/write SSH key needs to be created and private key added to circle ci +## as per https://circleci.com/docs/adding-read-write-deployment-key/ +## +## Suggest creating a machine user for the token and ssh key to limit access +## +deployment: + ## Create 'pre-release' from 'develop' branch + pre-release: + branch: develop + commands: + - make dev-release + + ## Create 'release' from 'master' branch + release: + branch: master + commands: + - make release diff --git a/common/context.go b/common/context.go index dee26dd9..66cd400a 100644 --- a/common/context.go +++ b/common/context.go @@ -8,6 +8,7 @@ import ( "os" "path" "time" + "path/filepath" ) var version string @@ -33,8 +34,13 @@ func NewContext() *Context { // InitializeFromFile loads config from file func (ctx *Context) InitializeFromFile(muFile string) error { + absMuFile,err := filepath.Abs(muFile) + if err != nil { + return err + } + // load yaml config - yamlFile, err := os.Open(muFile) + yamlFile, err := os.Open(absMuFile) if err != nil { return err } @@ -43,10 +49,10 @@ func (ctx *Context) InitializeFromFile(muFile string) error { }() // set the basedir - ctx.Config.Basedir = path.Dir(muFile) + ctx.Config.Basedir = path.Dir(absMuFile) ctx.Repo.Name = path.Base(ctx.Config.Basedir) ctx.Repo.Revision = time.Now().Format("20060102150405") - gitRevision, err := findGitRevision(muFile) + gitRevision, err := findGitRevision(absMuFile) if err == nil { ctx.Repo.Revision = gitRevision } diff --git a/common/git.go b/common/git.go index 54d761aa..a2381270 100644 --- a/common/git.go +++ b/common/git.go @@ -26,6 +26,7 @@ func findGitRevision(file string) (string, error) { } func findGitDirectory(fromFile string) (string, error) { + log.Debugf("Searching for git directory in %s",fromFile) fi, err := os.Stat(fromFile) if err != nil { return "", err diff --git a/examples/mu.yml b/examples/mu.yml new file mode 100644 index 00000000..71dacdd1 --- /dev/null +++ b/examples/mu.yml @@ -0,0 +1,8 @@ +--- +region: us-west-2 + +environments: + - name: sample-dev + cluster: + desiredCapacity: 1 + maxSize: 2 diff --git a/templates/assets.go b/templates/assets.go index 797e85f3..720fd994 100644 --- a/templates/assets.go +++ b/templates/assets.go @@ -204,9 +204,9 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "assets/cluster.yml": assetsClusterYml, - "assets/repo.yml": assetsRepoYml, + "assets/repo.yml": assetsRepoYml, "assets/service.yml": assetsServiceYml, - "assets/vpc.yml": assetsVpcYml, + "assets/vpc.yml": assetsVpcYml, } // AssetDir returns the file names below a certain @@ -248,13 +248,12 @@ type bintree struct { Func func() (*asset, error) Children map[string]*bintree } - var _bintree = &bintree{nil, map[string]*bintree{ "assets": &bintree{nil, map[string]*bintree{ "cluster.yml": &bintree{assetsClusterYml, map[string]*bintree{}}, - "repo.yml": &bintree{assetsRepoYml, map[string]*bintree{}}, + "repo.yml": &bintree{assetsRepoYml, map[string]*bintree{}}, "service.yml": &bintree{assetsServiceYml, map[string]*bintree{}}, - "vpc.yml": &bintree{assetsVpcYml, map[string]*bintree{}}, + "vpc.yml": &bintree{assetsVpcYml, map[string]*bintree{}}, }}, }} @@ -304,3 +303,4 @@ func _filePath(dir, name string) string { cannonicalName := strings.Replace(name, "\\", "/", -1) return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) } +