Skip to content

Commit

Permalink
Moonshot 1.0.0 - multiple features. (#139)
Browse files Browse the repository at this point in the history
Moonshot 1.0.0 - multiple features.
  • Loading branch information
askreet authored Oct 10, 2016
1 parent 96a05e7 commit d5640b2
Show file tree
Hide file tree
Showing 57 changed files with 720 additions and 579 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ Style/ClassAndModuleChildren:
Enabled: false
Metrics/ClassLength:
Max: 130
Style/Documentation:
Enabled: false
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ should aspire to meet them with each iteration.

## Installation

Add this line to your application's Gemfile:
Install the Moonshot gem:

gem 'moonshot'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install moonshot
```shell
$ gem install moonshot
```

After installation, there is still some work required. Follow the [example documentation](docs/example.md) as described below to dig in!

## Getting started

The Moonshot tool has been designed to be an extensible library for your specific use-case. Interested in how it can be used? See our [example documentation](http://moonshot.readthedocs.org/en/latest/example). The example doc uses the files shown in the [sample directory](https://github.com/acquia/moonshot/tree/master/sample) so you can figure out how to modify this for your own deployment strategy.
The Moonshot tool has been designed to be an extensible library for your
specific use-case. Interested in how it can be used? See our [example
documentation](http://moonshot.readthedocs.org/en/latest/example). The example
doc uses the files shown in the [sample
directory](https://github.com/acquia/moonshot/tree/master/sample) so you can
figure out how to modify this for your own deployment strategy.

We also want to [help you contribute and answer all your questions](http://moonshot.readthedocs.org/en/latest/about/contribute) on how Moonshot is maintained.

Expand Down
10 changes: 10 additions & 0 deletions bin/moonshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
require 'moonshot'

# This is the main entry point for the `moonshot` command-line tool.
begin
Moonshot::CommandLine.run!
rescue => e
warn "#{e} (at #{e.backtrace.first})"
exit 1
end
36 changes: 28 additions & 8 deletions docs/about/contribute.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Contributing to Moonshot
An introduction to contributing to the Moonshot project.

The Moonshot project welcomes, and depends, on contributions from developers and users in the open source community. Contributions can be made in a number of ways, a few examples are:
The Moonshot project welcomes, and depends, on contributions from
developers and users in the open source community. Contributions can
be made in a number of ways, a few examples are:

- Code patches via pull requests
- Documentation improvements
Expand All @@ -10,15 +12,33 @@ The Moonshot project welcomes, and depends, on contributions from developers and

## How to Contribute

So, you want to help? Awesome! In order to guide this the best way we can and to make sure we can help you in either getting a bug fixed or improve our documentation. we are asking you to please include as much detail as you can. Let us know your platform and Moonshot version. If the problem is visual please add a screenshot and if you get an error please include the full error and traceback.
So, you want to help? Awesome! In order to guide this the best way we
can and to make sure we can help you in either getting a bug fixed or
improve our documentation. we are asking you to please include as much
detail as you can. Let us know your platform and Moonshot version. If
the problem is visual please add a screenshot and if you get an error
please include the full error and traceback.

## Submitting Pull Requests

Once you are happy with your changes or you are ready for some feedback, push it to your fork and send a pull request. For a change to be accepted it will most likely need to have tests and documentation if it is a new feature.
Once you are happy with your changes or you are ready for some
feedback, push it to your fork and send a pull request. For a change
to be accepted it will most likely need to have tests and
documentation if it is a new feature.

## Expectations
Even though this is an Open project, it does not mean that we have 24/7 support for it. The best way to make sure that we accept your bugfix or add in a feature you want is still to make a pull request and link it in the issue. Include some reasons how to reproduce or even better, make sure the bug is tested and passes highy increases your chances for the change to get committed.

So, you've done all that? It very likely that it could get committed really quickly but since some of the contributers to this project could be on a holiday or we are in no way responsible in actually merging it in soon. But have no fear! Since you filed a pull request from your fork, you are able to use a version of moonshot yourselves. And we promise you, we will do our utter best.

And again, thanks! We're looking forward working with you.
Even though this is an Open project, it does not mean that we have
24/7 support for it. The best way to make sure that we accept your
bugfix or add in a feature you want is still to make a pull request
and link it in the issue. Include some reasons how to reproduce or
even better, make sure the bug is tested and passes highy increases
your chances for the change to get committed.

So, you've done all that? It very likely that it could get committed
really quickly but since some of the contributers to this project
could be on a holiday or we are in no way responsible in actually
merging it in soon. But have no fear! Since you filed a pull request
from your fork, you are able to use a version of moonshot
yourselves. And we promise you, we will do our utter best.

And again, thanks! We're looking forward working with you.
39 changes: 20 additions & 19 deletions docs/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ After setup, you will be able to repeatedly deploy a PHP app to one or more
isolated environments on AWS by running the following command:

```shell
bundle exec bin/environment deploy-code
$ moonshot push
```

You will also be able to update the OS and supporting software by pulling the
latest changes in this repository and updating the stack with following command:

```shell
bundle exec bin/environment update
$ moonshot update
```

Lastly, you get a disposable, light-weight application that can be used to learn
Expand All @@ -30,7 +30,7 @@ matter.
Create a role called CodeDeployRole with the AWSCodeDeployRole policy

```bash
aws iam create-role --role-name CodeDeployRole --assume-role-policy-document '{
$ aws iam create-role --role-name CodeDeployRole --assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
Expand All @@ -45,7 +45,7 @@ aws iam create-role --role-name CodeDeployRole --assume-role-policy-document '{
}
]
}'
aws iam attach-role-policy --role-name CodeDeployRole --policy-arn arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole
$ aws iam attach-role-policy --role-name CodeDeployRole --policy-arn arn:aws:iam::aws:policy/service-role/AWSCodeDeployRole
```

If you wish to do this manually, follow the
Expand All @@ -55,10 +55,10 @@ what Moonshot expects.

### Install Moonshot and it's dependencies.

This step assumes that you have [Bundler](http://bundler.io/) and a modern version of Ruby installed on your system. See Moonshot's [requirements](index.md#requirements)
Moonshot is released as a Ruby gem, and required Ruby 2.1+.

```shell
bundle install
$ gem install moonshot
```

### Create an S3 bucket and update the sample tools.
Expand All @@ -68,7 +68,7 @@ First, create your own bucket to put your artifacts in:
$ aws s3api create-bucket --bucket moonshot-sample-your-name
```

Then update `bin/environment` to refer to that bucket in the `S3Bucket` configuration.
Then update `Moonfile.rb` to refer to that bucket in the `S3Bucket` configuration.

### Create a configuration for your stack.

Expand All @@ -83,61 +83,62 @@ $ cp cloud_formation/parameters/moonshot-sample-app.yml cloud_formation/paramete
## Usage of the CLI

Run the following commands to create your environment and deploy code to it.
Note that you will have to set the `AWS_REGION` environment variable prior to running these commands. If it's not set, it will use the default AWS region which at the time of this writing is us-east-1.
Note that you will have to set the `AWS_REGION` environment variable prior to
running these commands. If it's not set, it will use the default AWS region
which at the time of this writing is us-east-1.

A detailed explanation of [all the CLI commands can be found in the User Guide](user-guide/cli.md)

You can now deploy your software to a new stack with:

```shell
$ ./bin/environment create
$ moonshot create
```

By default, you'll get a development environment named `moonshot-sample-app`. If you want to provision test or production
named environment, use:

```shell
$ ./bin/environment create -n my-service-staging
$ ./bin/environment create -n my-service-production
$ moonshot create -n my-service-staging
$ moonshot create -n my-service-production
```

By default, create launches the stack and deploys code. If you want to only
create the stack and not deploy code, use:

```shell
$ ./bin/environment create --no-deploy
$ moonshot create --no-deploy
```

If you make changes to your application and want to release a development build
to your stack, run:

```shell
$ ./bin/environment deploy-code
$ moonshot push
```

To build a "named build" for releasing through test and production environments,
use:

```shell
$ ./bin/environment build-version v0.1.0
$ ./bin/environment deploy-version v0.1.0 -n <environment-name>
$ moonshot build v0.1.0
$ moonshot deploy v0.1.0 -n <environment-name>
```

To see the outputs of the stack you just spun up:

```shell
$ ./bin/environment build-version v0.1.0
$ ./bin/environment deploy-version v0.1.0 -n <environment-name>
$ moonshot status
```

Tear down your stack by running the following command:

```shell
bundle exec bin/environment delete
$ moonshot delete
```

SSH into the first instance in your stack by running the following command:

```shell
bundle exec bin/environment ssh
$ moonshot ssh
```
27 changes: 19 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,36 @@ should aspire to meet them with each iteration.

## Installation

Add this line to your application's Gemfile:
You can install Moonshot for your local user with:

$ gem install moonshot

If you would prefer to manage your projects dependencies with Bundler,
add the following to your Gemfile:

gem 'moonshot'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install moonshot

After installation, there is still some work required. Follow the [example documentation](example.md) as described below to dig in!
After installation, there is still some work required. Follow
the [example documentation](example.md) as described below to dig in!

## Getting started

The Moonshot tool has been designed to be an extensible library for your specific use-case. Interested in how it can be used? See our [example documentation](example.md). The example doc uses the files shown in the [sample directory](https://github.com/acquia/moonshot/tree/master/sample) so you can figure out how to modify this for your own deployment strategy.
The Moonshot tool has been designed to be an extensible library for
your specific use-case. Interested in how it can be used? See
our [example documentation](example.md). The example doc uses the
files shown in the
[sample directory](https://github.com/acquia/moonshot/tree/master/sample) so
you can figure out how to modify this for your own deployment
strategy.

We also want to [help you contribute and answer all your questions][1]
on how Moonshot is maintained.

We also want to [help you contribute and answer all your questions](http://moonshot.readthedocs.org/en/latest/about/contribute) on how Moonshot is maintained.
[1]: http://moonshot.readthedocs.org/en/latest/about/contribute

## Requirements

Expand Down
18 changes: 10 additions & 8 deletions docs/mechanisms/artifact-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
## S3Bucket

The store action will upload the file using the S3 PutObject API call.
The local environment must be configured with appropriate credentials.
The local environment must be configured with appropriate
credentials. Running `doctor` will verify those credentials for you.

To create a new S3Bucket ArtifactRepository:
```ruby
class MyApplication < Moonshot::CLI
self.artifact_repository = S3Bucket.new('my-bucket-name')
Moonshot.config do |c|
c.artifact_repository = S3Bucket.new('my-bucket-name')
end
```

## S3BucketViaGithubReleases

S3 Bucket repository backed by GitHub releases.
If a SemVer package isn't found in S3, it is downloaded from GitHub releases to avoid not being able to release in case there is trouble with AWS S3.
S3 Bucket repository backed by GitHub releases. If a SemVer package
isn't found in S3, it is downloaded from GitHub releases to avoid not
being able to release in case there is trouble with AWS S3.

To create a new S3BucketViaGithubReleases ArtifactRepository:
```ruby
class MyApplication < Moonshot::CLI
self.artifact_repository = S3BucketViaGithubReleases.new('my-bucket-name')
Moonshot.config do |c|
c.artifact_repository = S3BucketViaGithubReleases.new('my-bucket-name')
end
```
```
43 changes: 17 additions & 26 deletions docs/mechanisms/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,45 @@ expectations. The script will run with some environment variables:
- `VERSION`: The named version string passed to `build-version`.
- `OUTPUT_FILE`: The file that the script is expected to produce.

If the file is not created by the build script, deployment will fail. Otherwise,
the output file will be uploaded using the ArtifactRepository.
If the file is not created by the build script, deployment will
fail. Otherwise, the output file will be uploaded using the
ArtifactRepository.

Sample Usage
```ruby
#!/usr/bin/env ruby

require 'moonshot'

# Set up Moonshot tooling for our environment.
class MoonshotSampleApp < Moonshot::CLI
self.build_mechanism = Script.new('bin/build.sh')
Moonshot.config do |c|
c.build_mechanism = Script.new('bin/build.sh')
...
```

## GithubRelease

A build mechanism that creates a tag and GitHub release. Could be used to delegate other building steps after GitHub release is created.
A build mechanism that creates a tag and GitHub release. Could be used
to delegate other building steps after GitHub release is created.

Sample Usage

```ruby
#!/usr/bin/env ruby

require 'moonshot'

# Set up Moonshot tooling for our environment.
class MoonshotSampleApp < Moonshot::CLI
wait_for_travis_mechanism = TravisDeploy.new("acquia/moonshot", true)
self.build_mechanism = GithubRelease.new(wait_for_travis_mechanism)
Moonshot.config do |c|
wait_for_travis_mechanism = TravisDeploy.new("acquia/moonshot", true)
c.build_mechanism = GithubRelease.new(wait_for_travis_mechanism)
...
```

## TravisDeploy

The Travis Build Mechanism waits for Travis-CI to finish building a job matching the VERSION (see above) and the output of the travis job has to be 'BUILD=1'. Can be used to make sure that the travis job for the repository for that version actually finished before the deployment step can be executed.
The Travis Build Mechanism waits for Travis-CI to finish building a
job matching the VERSION (see above) and the output of the travis job
has to be 'BUILD=1'. Can be used to make sure that the travis job for
the repository for that version actually finished before the
deployment step can be executed.

Sample Usage
```ruby
#!/usr/bin/env ruby

require 'moonshot'

# Set up Moonshot tooling for our environment.
class MoonshotSampleApp < Moonshot::CLI
Moonshot.config do |c|
# First argument is the repository as known by travis.
# Second argument is wether or not you are using travis pro.
self.build_mechanism = TravisDeploy.new("acquia/moonshot", pro: true)
c.build_mechanism = TravisDeploy.new("acquia/moonshot", pro: true)
...
```

Expand Down
Loading

0 comments on commit d5640b2

Please sign in to comment.