Skip to content

Commit

Permalink
Merge pull request #73 from stelligent/develop
Browse files Browse the repository at this point in the history
Pipelines
  • Loading branch information
cplee authored Feb 1, 2017
2 parents 738def6 + e6da7c5 commit 37555ee
Show file tree
Hide file tree
Showing 41 changed files with 1,550 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.iml
.idea
.release/
vendor/
62 changes: 53 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,66 @@
# Contributing to Mu

Please review the following guidelines before contributing to Mu. Also, feel free to propose changes to these guidelines by updating this file and submitting a pull request.
Help wanted! We'd love your contributions to Mu. Please review the following guidelines before contributing. Also, feel free to propose changes to these guidelines by updating this file and submitting a pull request.

## Issues
* [I have a question...](#questions)
* [I found a bug...](#bugs)
* [I have a feature request...](#features)
* [I have a contribution to share...](#process)

TODO
## <a name="questions"></a> Have a Question?

## Pull Requests
Please don't open a GitHub issue for questions about how to use mu, as the goal is to use issues for managing bugs and feature requests. Issues that are related to general support will be closed and redirected to our gitter room.

TODO
For all support related questions, please ask the question in our gitter room: [stelligent/mu](https://gitter.im/stelligent/mu).

## Styleguide
## <a name="bugs"></a> Found a Bug?

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.
If you've identified a bug in mu, please [submit an issue](#issue) to our GitHub repo: [stelligent/mu](https://github.com/stelligent/mu/issues/new). Please also feel free to submit a [Pull Request](#pr) with a fix for the bug!

TODO
## <a name="features"></a> Have a Feature Request?

## License
All feature requests should start with [submitting an issue](#issue) documenting the user story and acceptance criteria. Again, feel free to submit a [Pull Request](#pr) with a proposed implementation of the feature.

## <a name="process"></a> Ready to Contribute!

### <a name="issue"></a> Create an issue

Before submitting a new issue, please search the issues to make sure there isn't a similar issue doesn't already exist.

Assuming no existing issues exist, please ensure you include the following bits of information when submitting the issue to ensure we can quickly reproduce your issue:

* Version of mu
* Platform (Linux, OS X, Windows)
* The complete `mu.yml` file used
* The complete command that was executed
* Any output from the command
* Details of the expected results and how they differed from the actual results

We may have additional questions and will communicate through the GitHub issue, so please respond back to our questions to help reproduce and resolve the issue as quickly as possible.

New issues can be created with in our [GitHub repo](https://github.com/stelligent/mu/issues/new).

### <a name="pr"></a>Pull Requests

Pull requests should target the `develop` branch. Ensure you have a successful build for your branch in [Circle CI](https://circleci.com/gh/stelligent/mu). Please also reference the issue from the description of the pull request using [special keyword syntax](https://help.github.com/articles/closing-issues-via-commit-messages/) to auto close the issue when the PR is merged. For example, include the phrase `fixes #14` in the PR description to have issue #14 auto close.

### <a name="style"></a> Styleguide

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Here are a few points to keep in mind:

* Please run `go fmt ./...` before committing to ensure code aligns with go standards.
* All dependencies must be defined in the `glide.yaml` file and pinned to a patch range. This is accomplished via a command like `glide get github.com/depuser/deprepo`
* For details on the approved style, check out [Effective Go](https://golang.org/doc/effective_go.html).

Also, consider the original design principles:

* **Polyglot** - There will be no prescribed language or framework for developing the microservices. The only requirement will be that the service will be run inside a container and exposed via an HTTP endpoint.
* **Cloud Provider** - At this point, the tool will assume AWS for the cloud provider and will not be written in a cloud agnostic manner. However, this does not preclude refactoring to add support for other providers at a later time.
* **Declarative** - All resource administration will be handled in a declarative vs. imperative manner. A file will be used to declared the desired state of the resources and the tool will simply assert the actual state matches the desired state. The tool will accomplish this by generating CloudFormation templates.
* **Stateless** - The tool will not maintain its own state. Rather, it will rely on the CloudFormation stacks to determine the state of the platform.
* **Secure** - All security will be managed by AWS IAM credentials. No additional authentication or authorization mechanisms will be introduced.

### License

By contributing your code, you agree to license your contribution under the terms of the [MIT License](LICENSE.md).

Expand Down
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,38 @@ TARGET_OS := linux windows darwin
BRANCH := $(or $(TRAVIS_BRANCH), $(shell git rev-parse --abbrev-ref HEAD))
IS_MASTER := $(filter master, $(BRANCH))
VERSION := $(shell cat VERSION)$(if $(IS_MASTER),,-$(BRANCH))
SRC_FILES = $(shell glide nv)
ARCH := $(shell go env GOARCH)
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 main.version=$(VERSION)"
TAG_VERSION = v$(VERSION)

default: build
default: all

deps:
@echo "=== preparing $(VERSION) from $(BRANCH) ==="
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 ./...
#go get -t -d -v $(SRC_FILES)
glide install
go generate $(SRC_FILES)

lint:
@echo "=== linting ==="
go vet ./...
golint -set_exit_status ./...
go vet $(SRC_FILES)
glide novendor | xargs -n1 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
go test -v -cover $(SRC_FILES) | go-junit-report > $(CIRCLE_TEST_REPORTS)/unit/report.xml
else
go test -cover ./...
go test -cover $(SRC_FILES)
endif


Expand All @@ -53,7 +55,7 @@ ifeq ($(IS_MASTER),)
git push --delete origin $(TAG_VERSION) || echo "No tag to delete"
endif

release-create: release-clean
release-create: build release-clean
@echo "=== creating pre-release $(VERSION) ==="
git tag -f $(TAG_VERSION)
git push origin $(TAG_VERSION)
Expand All @@ -78,5 +80,13 @@ endif
clean:
@echo "=== cleaning ==="
rm -rf $(BUILD_DIR)
rm -rf vendor

.PHONY: default lint test build deps clean release-clean release-create dev-release release $(UPLOAD_FILES) $(TARGET_OS)
all: clean deps test build

fmt:
@echo "=== cleaning ==="
go fmt $(SRC_FILES)


.PHONY: default all lint test build deps clean release-clean release-create dev-release release $(UPLOAD_FILES) $(TARGET_OS)
53 changes: 40 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build Status](https://circleci.com/gh/stelligent/mu.svg?style=svg)](https://circleci.com/gh/stelligent/mu)
[![Build Status](https://circleci.com/gh/stelligent/mu.svg?style=shield)](https://circleci.com/gh/stelligent/mu) [![Join the chat at https://gitter.im/stelligent/mu](https://badges.gitter.im/stelligent/mu.svg)](https://gitter.im/stelligent/mu?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)



# 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 All @@ -17,7 +19,7 @@ curl -s https://raw.githubusercontent.com/stelligent/mu/master/install.sh | sh
curl -s https://raw.githubusercontent.com/stelligent/mu/master/install.sh | INSTALL_VERSION=0.1.0 INSTALL_DIR=~/bin sh
```

## Commands
# Commands

```
# List all environments
Expand All @@ -35,29 +37,26 @@ curl -s https://raw.githubusercontent.com/stelligent/mu/master/install.sh | INST
# Show details about a specific service (Which versions in which environments, pipeline status)
> mu service show [-s <service_name>]
# Build docker image and push to ECR
> mu service push
# Deploy the service to an environment
> mu service deploy <environment_name>
# Set an environment variable(s) for a service
> mu service setenv <environment_name> [-s <service_name>] key=value[,...]
# Undeploy the service from an environment
> mu service undeploy <environment_name> [-s <service_name>]
# List the pipelines
> mu pipeline list
# Show the pipeline details for a specific service
> mu pipeline show <service_name>
# Upsert the pipeline
> mu pipeline up [-s <service_name>] [-u <repo_url>] [-t <repo_token>]
> mu pipeline up [-t <repo_token>]
# Terminate the pipeline
> mu pipeline terminate [-s <service_name>]
```

## Configuration
# Configuration
The definition of your environments, services and pipelines is done via a YAML file (default `./mu.yml`).

```
Expand Down Expand Up @@ -86,9 +85,9 @@ environments:
vpcTarget:
vpcId: vpc-xxxxx # The id of the VPC to launch ECS container instances into
publicSubnetIds: # The list of subnets to use for ECS container instances
- sg-xxxxx
- sg-xxxxy
- sg-xxxxz
- subnet-xxxxx
- subnet-xxxxy
- subnet-xxxxz
### Define the service for this repo
service:
Expand All @@ -105,4 +104,32 @@ service:
pathPatterns:
- /bananas
- /apples
# Define the behavior of the pipeline
pipeline:
source:
repo: stelligent/microservice-exemplar # The GitHub repo slug to build (default: none)
branch: mu # The branch to build from (default: master)
build:
image: aws/codebuild/java:openjdk-8 # The image to use for CodeBuild job (default: aws/codebuild/ubuntu-base:latest)
type: linuxContainer
computeType: BUILD_GENERAL1_SMALL # The type of compute instance for builds (default: BUILD_GENERAL1_SMALL)
acceptance:
environment: dev # The environment name to deploy to for testing (default: dev)
production:
environment: production # The environment name to deploy to for production (default: production)
```



# Contributing

Want to contribute to Mu? Awesome! Check out the [contributing guidelines](CONTRIBUTING.md) to get involved.

## Building from source

* Install Go tools 1.7+ - (https://golang.org/doc/install)
* Install [Glide](https://github.com/Masterminds/glide) via `curl https://glide.sh/get | sh`
* Clone this repo `git clone [email protected]:stelligent/mu.git $GOPATH/src/github.com/stelligent/mu`
* Go to src `cd $GOPATH/src/github.com/stelligent/mu`
* Build with `make`
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4
0.1.5
11 changes: 0 additions & 11 deletions buildspec.yml

This file was deleted.

21 changes: 16 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@ general:
ignore:
- /^v[0-9]/

machine:
environment:
IMPORT_PATH: "/home/ubuntu/.go_workspace/src/github.com/$CIRCLE_PROJECT_USERNAME"
APP_PATH: "$IMPORT_PATH/$CIRCLE_PROJECT_REPONAME"

## Run 'make deps' for resolving dependencies
dependencies:
pre:
- sudo add-apt-repository ppa:masterminds/glide -y
- sudo apt-get update
- sudo apt-get install glide -y
override:
- make deps
- mkdir -p "$IMPORT_PATH"
- ln -sf "$(pwd)" "$APP_PATH"
- cd "$APP_PATH" && make deps

## Run 'make' for compile
compile:
override:
- make
- cd "$APP_PATH" && make build

## Run 'make test' to test
test:
override:
- make test
- cd "$APP_PATH" && make test


## In order for deploy to work, you need an environment variable set in CircleCI named "GITHUB_TOKEN" that contains
Expand All @@ -33,10 +44,10 @@ deployment:
pre-release:
branch: develop
commands:
- make dev-release
- cd "$APP_PATH" && make dev-release

## Create 'release' from 'master' branch
release:
branch: master
commands:
- make release
- cd "$APP_PATH" && make release
Loading

0 comments on commit 37555ee

Please sign in to comment.