codebuild 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95697bfe6c4ae37bb84258a9b2067494efcc83e259f9a03bd9e4a2088d579f52
4
- data.tar.gz: b472131c142171e67aa7fa5f0d4e7f12e35efe18572408d3f002ead4cb230687
3
+ metadata.gz: a61acb91b1f2eb181094bd20117879da0219931178fec03054f930f06cf3fd4a
4
+ data.tar.gz: 9c462974ca5f372d437f490a44a88763373f852aca75c727bfcf58e9f853f599
5
5
  SHA512:
6
- metadata.gz: ee5f2784e0986fbd38ed79df15089ed8eb031a8da983dbb7c690fbf1084ab0a21b2e4327ec8d4ac99cf29aecb2431f217b3ca745a22c6797f986f0eaf39ac5e0
7
- data.tar.gz: f4334660cfc0c108b03fecc451d1cbf7742ec5c223b4964bd8969006d8a9aaea6e7a9ddb54dfe8ce7fdaa1ab633d7ccbd2e39130e33b958f7b015ce59973430f
6
+ metadata.gz: 30a6738433fb64cd50b2237f6f7a8d78c3dcd9bc281b836eed6f869bb295d462f0778499e17c79adb06031af8908d2c89581fef74d49cb59d08026e50b18adc4
7
+ data.tar.gz: dd6342bfdfb19de9a91c16736b3a2edf939b7bd05e72675797f22777d0c6c44171cf960c225b4f0c97ac35294f177291c9a1b45fb872f70a08ce68c940fe0bc7
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.6.1]
7
+ - cb init: no variables by default
8
+ - fix handle rollback
9
+
6
10
  ## [0.6.0]
7
11
  - named stack with -cb at the very end
8
12
  - add docs
@@ -85,6 +85,8 @@ managed_iam_policy("AmazonS3ReadOnlyAccess") # optional but common to need read
85
85
 
86
86
  From a security perspective, using CodeBuild gives us a stronger security posture. The **only** permission the user calling [cb start]({% link _docs/start.md %}) really needs is CodeBuild access. The permissions to create the ECS service and other deployment resources are delegated to the CodeBuild project itself. We know that the CodeBuild project will not run any arbitrary commands unless we update `buildspec.yml` and explicitly give permission to it's IAM role.
87
87
 
88
+ {% include examples-steps.md %}
89
+
88
90
  ## CodePipeline ECS Deploy Action
89
91
 
90
92
  If you are using CodePipeline also, you may be wondering why not just use the provided Amazon ECS deployment action instead. It comes down to control. With a CodeBuild project, we have full control of how we want to build and deploy the Docker image to ECS.
@@ -13,13 +13,15 @@ Here's the project DSL.
13
13
 
14
14
 
15
15
  ```ruby
16
- github_url("https://github.com/tongueroo/jets-hello-examples")
17
- linux_image("aws/codebuild/ruby:2.5.3-1.7.0") # currently must used ruby 2.5
16
+ github_url("https://github.com/tongueroo/jets-codebuild")
17
+ linux_image("timbru31/ruby-node:2.5") # currently must used ruby 2.5 for Lambda
18
18
  environment_variables(
19
19
  JETS_ENV: Codebuild.env,
20
20
  )
21
21
  ```
22
22
 
23
+ The [.codebuild/project.rb](.codebuild/project.rb) uses a Docker image that has ruby, node, and yarn already installed. If you prefer to use another image, update the `linux_image` setting, and update your `buildspec.yml` accordingly. IE: Install the necessary packages.
24
+
23
25
  Here's the buildspec:
24
26
 
25
27
  .codebuild/buildspec.yml
@@ -30,20 +32,20 @@ version: 0.2
30
32
  phases:
31
33
  install:
32
34
  commands:
33
- - apt-get update -y && apt-get install -y rsync # prequisite for jets
35
+ - apt-get update -y
36
+ - apt-get install -y rsync zip
34
37
  build:
35
38
  commands:
36
39
  - echo Build started on `date`
37
40
  - sed -i '/BUNDLED WITH/Q' Gemfile.lock # hack to fix bundler issue: allow different versions of bundler to work
38
- - gem install bundler:1.16.6
39
- - export JETS_ENV=test
40
41
  - bundle
41
- - bundle exec rspec
42
+ - JETS_ENV=test bundle exec rspec
42
43
  post_build:
43
44
  commands:
44
45
  - bash -c 'if [ "$CODEBUILD_BUILD_SUCCEEDING" == "0" ]; then exit 1; fi'
45
46
  - export JETS_AGREE=yes
46
47
  - bundle exec jets deploy $JETS_ENV
48
+
47
49
  ```
48
50
 
49
51
  And here are the IAM permissions required as described in [Jets Minimal IAM Deploy Policy](https://rubyonjets.com/docs/extras/minimal-deploy-iam/).
@@ -65,4 +67,13 @@ iam_policy(
65
67
  )
66
68
  ```
67
69
 
70
+ Here's also Github repo with CodeBuild examples with Jets: [tongueroo/jets-codebuild](https://github.com/tongueroo/jets-codebuild). The example on the master branch is a similar simple approach with 1 CodeBuild project.
71
+
72
+ You may be interested in the [separate-unit-and-deploy branch](https://github.com/tongueroo/jets-codebuild/tree/separate-unit-and-deploy). The example shows how to set up 2 separate CodeBuild projects. Some advantages:
73
+
74
+ * The projects are decoupled and you can run them separately.
75
+ * Only the deploy project requires IAM access to create the AWS resources.
76
+
77
+ {% include examples-steps.md %}
78
+
68
79
  {% include prev_next.md %}
@@ -5,7 +5,7 @@ categories: example
5
5
  nav_order: 18
6
6
  ---
7
7
 
8
- This examples show to run ruby unit tests.
8
+ This examples show to run Ruby unit tests.
9
9
 
10
10
  Here's the project DSL.
11
11
 
@@ -30,15 +30,15 @@ version: 0.2
30
30
  phases:
31
31
  install:
32
32
  commands:
33
- - apt-get update -y && apt-get install -y rsync # prequisite for jets
33
+ - apt-get update -y apt-get install -y rsync
34
34
  build:
35
35
  commands:
36
36
  - echo Build started on `date`
37
37
  - sed -i '/BUNDLED WITH/Q' Gemfile.lock # hack to fix bundler issue: allow different versions of bundler to work
38
- - gem install bundler:1.16.6
39
- - export JETS_ENV=test
40
38
  - bundle
41
- - bundle exec rspec
39
+ - JETS_ENV=test bundle exec rspec
42
40
  ```
43
41
 
44
- {% include prev_next.md %}
42
+ {% include examples-steps.md %}
43
+
44
+ {% include prev_next.md %}
@@ -39,10 +39,9 @@ cb delete
39
39
  <div class="commands">
40
40
  {% highlight sh %}
41
41
  cb deploy # infers the CloudFormation name from the parent folder
42
- cb deploy stack-name # explicitly specify stack name
42
+ cb deploy project-name # explicitly specify project name
43
43
 
44
44
  cb start # infers the name from the parent folder
45
- cb start stack-name # looks up project via CloudFormation stack
46
45
  cb start demo-project # looks up project via CodeBuild project name
47
46
  {% endhighlight %}
48
47
  </div>
@@ -0,0 +1,17 @@
1
+ ## Create CodeBuild Project
2
+
3
+ To create the CodeBuild project via CloudFormation run:
4
+
5
+ cb deploy demo
6
+
7
+ This creates the CodeBuild project as well as the necessary IAM role.
8
+
9
+ ## Start Build
10
+
11
+ To start a build:
12
+
13
+ cb start
14
+
15
+ You can also start a build with a specific branch. Remember to `git push` your branch.
16
+
17
+ cb start -b mybranch
@@ -1,11 +1,39 @@
1
1
  module Codebuild
2
2
  class Deploy < Stack
3
3
  def run
4
+ handle_rollback_completed!
4
5
  if stack_exists?(@stack_name)
5
6
  Update.new(@options).run
6
7
  else
7
8
  Create.new(@options).run
8
9
  end
9
10
  end
11
+
12
+ def handle_rollback_completed!
13
+ @stack = find_stack(@stack_name)
14
+ if @stack && rollback_complete?(@stack)
15
+ puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
16
+ cfn.delete_stack(stack_name: @stack_name)
17
+ status.wait
18
+ status.reset
19
+ @stack = nil # at this point stack has been deleted
20
+ end
21
+ end
22
+
23
+ def rollback_complete?(stack)
24
+ stack.stack_status == 'ROLLBACK_COMPLETE'
25
+ end
26
+
27
+ def find_stack(stack_name)
28
+ resp = cfn.describe_stacks(stack_name: stack_name)
29
+ resp.stacks.first
30
+ rescue Aws::CloudFormation::Errors::ValidationError => e
31
+ # example: Stack with id demo-web does not exist
32
+ if e.message =~ /Stack with/ && e.message =~ /does not exist/
33
+ nil
34
+ else
35
+ raise
36
+ end
37
+ end
10
38
  end
11
39
  end
@@ -8,7 +8,7 @@ module Codebuild
8
8
  [:template, desc: "Custom template to use"],
9
9
  [:template_mode, desc: "Template mode: replace or additive"],
10
10
  [:type, desc: "Type option creates a subfolder under .codebuild"],
11
- [:variables, type: :boolean, default: true, desc: "Create variables starter files"],
11
+ [:variables, type: :boolean, default: false, desc: "Create variables starter files"],
12
12
  ]
13
13
  end
14
14
  cli_options.each { |o| class_option(*o) }
@@ -45,15 +45,6 @@ module Codebuild
45
45
  return if @options[:noop]
46
46
  puts "Deploying stack #{@stack_name.color(:green)} with CodeBuild project #{@full_project_name.color(:green)}"
47
47
 
48
- @stack = find_stack(@stack_name)
49
- if @stack && rollback_complete?(@stack)
50
- puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
51
- cfn.delete_stack(stack_name: @stack_name)
52
- status.wait
53
- status.reset
54
- @stack = nil # at this point stack has been deleted
55
- end
56
-
57
48
  begin
58
49
  perform
59
50
  url_info
@@ -64,7 +55,7 @@ module Codebuild
64
55
  if e.message.include?("No updates") # No updates are to be performed.
65
56
  puts "WARN: #{e.message}".color(:yellow)
66
57
  else
67
- puts "ERROR: #{e.message}".color(:red)
58
+ puts "ERROR ValidationError: #{e.message}".color(:red)
68
59
  exit 1
69
60
  end
70
61
  end
@@ -1,3 +1,3 @@
1
1
  module Codebuild
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2019-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -256,6 +256,7 @@ files:
256
256
  - docs/_includes/commands.html
257
257
  - docs/_includes/content.html
258
258
  - docs/_includes/edit-on-github.html
259
+ - docs/_includes/examples-steps.md
259
260
  - docs/_includes/footer.html
260
261
  - docs/_includes/google_analytics.html
261
262
  - docs/_includes/head.html
@@ -290,7 +291,6 @@ files:
290
291
  - docs/_sass/_variables.scss
291
292
  - docs/bin/web
292
293
  - docs/docs.md
293
- - docs/favicon.ico
294
294
  - docs/img/docs/codebuild-output.png
295
295
  - docs/img/logos/boltops-logo-full.png
296
296
  - docs/img/logos/boltops-logo.png
data/docs/favicon.ico DELETED
Binary file