Skip to content

Commit

Permalink
Merge pull request #66 from stelligent/develop
Browse files Browse the repository at this point in the history
Migrate to CircleCI
  • Loading branch information
cplee authored Jan 25, 2017
2 parents e92fbd6 + b67e964 commit 738def6
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 68 deletions.
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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),)
Expand All @@ -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)

Expand All @@ -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)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.3
0.1.4
42 changes: 42 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 9 additions & 3 deletions common/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path"
"time"
"path/filepath"
)

var version string
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions common/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions examples/mu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
region: us-west-2

environments:
- name: sample-dev
cluster:
desiredCapacity: 1
maxSize: 2
10 changes: 5 additions & 5 deletions templates/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 738def6

Please sign in to comment.