renuo-cli 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/renuo/cli.rb +11 -0
- data/lib/renuo/cli/app/configure_semaphore.rb +53 -0
- data/lib/renuo/cli/app/templates/semaphore-deploy.yml.erb +25 -0
- data/lib/renuo/cli/app/templates/semaphore.yml.erb +52 -0
- data/lib/renuo/cli/version.rb +1 -1
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: df319b290efddcc2508f9a66d6fd91be5ed699ddba6445022e38e9778e53ee87
         | 
| 4 | 
            +
              data.tar.gz: 36109dd81622f8e1fcf40fd0b38ace7f79eee1e5399d1157b2032a5a38ed2b87
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2a2dc996e454224ec4f00bd9615dce746cbe4f399f61e4dba8fc94dc14b422895404b1732c176dc4e6247c3116a903a292239707b86924b25c593deb5502b428
         | 
| 7 | 
            +
              data.tar.gz: d71a3793f8f3f9abb31e0893731e2eba33b5aa2ddc254c9b9a920836ff1a64f87307bcd87eb2ad10dd2321a6689746a9fa3723e5cb8de803d7f30fedc30b5fde
         | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/lib/renuo/cli.rb
    CHANGED
    
    | @@ -16,6 +16,7 @@ require 'renuo/cli/app/fetch_emails.rb' | |
| 16 16 | 
             
            require 'renuo/cli/app/heroku_users.rb'
         | 
| 17 17 | 
             
            require 'renuo/cli/app/setup_uptimerobot'
         | 
| 18 18 | 
             
            require 'renuo/cli/app/release_xing'
         | 
| 19 | 
            +
            require 'renuo/cli/app/configure_semaphore'
         | 
| 19 20 |  | 
| 20 21 | 
             
            module Renuo
         | 
| 21 22 | 
             
              class CLI
         | 
| @@ -203,6 +204,16 @@ module Renuo | |
| 203 204 | 
             
                      ReleaseXing.new.run
         | 
| 204 205 | 
             
                    end
         | 
| 205 206 | 
             
                  end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                  command 'configure-semaphore' do |c|
         | 
| 209 | 
            +
                    c.syntax = 'renuo configure-semaphore'
         | 
| 210 | 
            +
                    c.summary = 'Adds standard semaphore configuration files to a project and creates the notifications'
         | 
| 211 | 
            +
                    c.description = 'Run this command with a project, to add the semaphore configuration files '\
         | 
| 212 | 
            +
                                    'and create notifications.'
         | 
| 213 | 
            +
                    c.action do |args|
         | 
| 214 | 
            +
                      ConfigureSemaphore.new.call
         | 
| 215 | 
            +
                    end
         | 
| 216 | 
            +
                  end
         | 
| 206 217 | 
             
                end
         | 
| 207 218 | 
             
              end
         | 
| 208 219 | 
             
            end
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            require 'commander'
         | 
| 2 | 
            +
            require_relative './environments'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class ConfigureSemaphore
         | 
| 5 | 
            +
              attr_accessor :project_name, :environment
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def initialize
         | 
| 8 | 
            +
                @project_name = File.basename(Dir.getwd)
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def call
         | 
| 12 | 
            +
                return unless semaphore_cli_installed?
         | 
| 13 | 
            +
                FileUtils.mkdir_p('.semaphore')
         | 
| 14 | 
            +
                write_or_warn('.semaphore/semaphore.yml', render('templates/semaphore.yml.erb'))
         | 
| 15 | 
            +
                %w[master develop testing].each do |environment|
         | 
| 16 | 
            +
                  @environment = environment
         | 
| 17 | 
            +
                  write_or_warn(".semaphore/#{environment}-deploy.yml", render('templates/semaphore-deploy.yml.erb'))
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                create_semaphore_notification
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              private
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              def semaphore_cli_installed?
         | 
| 25 | 
            +
                semaphore_cli_installed = `sem context`.strip == '* renuo_semaphoreci_com'
         | 
| 26 | 
            +
                warn('You need to install and configure Semaphore CLI to run this command.') unless semaphore_cli_installed
         | 
| 27 | 
            +
                semaphore_cli_installed
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def create_semaphore_notification
         | 
| 31 | 
            +
                system("sem create notifications #{project_name} "\
         | 
| 32 | 
            +
                       "--projects #{project_name} "\
         | 
| 33 | 
            +
                       '--branches "master,develop,testing" '\
         | 
| 34 | 
            +
                       "--slack-channels \"#project-#{project_name}\" "\
         | 
| 35 | 
            +
                       '--slack-endpoint "https://hooks.slack.com/services/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"')
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              def render(template_file)
         | 
| 39 | 
            +
                file_path = File.join(File.dirname(__FILE__), template_file)
         | 
| 40 | 
            +
                semaphore_template = File.read(file_path)
         | 
| 41 | 
            +
                renderer = ERB.new(semaphore_template)
         | 
| 42 | 
            +
                renderer.result(binding)
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def write_or_warn(file_path, content)
         | 
| 46 | 
            +
                if File.exist?(file_path)
         | 
| 47 | 
            +
                  warn("#{file_path} exists already. I will not overwrite it.")
         | 
| 48 | 
            +
                else
         | 
| 49 | 
            +
                  File.write(file_path, content)
         | 
| 50 | 
            +
                  say("#{file_path} added.")
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            version: v1.0
         | 
| 2 | 
            +
            name: <%= environment %>-deploy
         | 
| 3 | 
            +
            agent:
         | 
| 4 | 
            +
              machine:
         | 
| 5 | 
            +
                type: e1-standard-2
         | 
| 6 | 
            +
                os_image: ubuntu1804
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            blocks:
         | 
| 9 | 
            +
              - name: <%= environment %>-deploy
         | 
| 10 | 
            +
                task:
         | 
| 11 | 
            +
                  secrets:
         | 
| 12 | 
            +
                    - name: heroku-deploy
         | 
| 13 | 
            +
                  env_vars:
         | 
| 14 | 
            +
                    - name: HEROKU_REMOTE
         | 
| 15 | 
            +
                      value: https://git.heroku.com/<%= project_name %>-<%= environment %>.git
         | 
| 16 | 
            +
                  jobs:
         | 
| 17 | 
            +
                    - name: <%= environment %>-deploy
         | 
| 18 | 
            +
                      commands:
         | 
| 19 | 
            +
                        - checkout --use-cache
         | 
| 20 | 
            +
                        - ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts
         | 
| 21 | 
            +
                        - chmod 600 ~/.ssh/id_rsa_semaphore_heroku
         | 
| 22 | 
            +
                        - ssh-add ~/.ssh/id_rsa_semaphore_heroku
         | 
| 23 | 
            +
                        - git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/
         | 
| 24 | 
            +
                        - git remote add heroku $HEROKU_REMOTE
         | 
| 25 | 
            +
                        - git push heroku -f $SEMAPHORE_GIT_BRANCH:master
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            version: "v1.0"
         | 
| 2 | 
            +
            name: <%= project_name %>
         | 
| 3 | 
            +
            agent:
         | 
| 4 | 
            +
              machine:
         | 
| 5 | 
            +
                type: e1-standard-2
         | 
| 6 | 
            +
                os_image: ubuntu1804
         | 
| 7 | 
            +
            auto_cancel:
         | 
| 8 | 
            +
              running:
         | 
| 9 | 
            +
                when: "true"
         | 
| 10 | 
            +
            blocks:
         | 
| 11 | 
            +
              - name: cache
         | 
| 12 | 
            +
                dependencies: []
         | 
| 13 | 
            +
                task:
         | 
| 14 | 
            +
                  secrets:
         | 
| 15 | 
            +
                    - name: <%= project_name %>
         | 
| 16 | 
            +
                  jobs:
         | 
| 17 | 
            +
                    - name: cache
         | 
| 18 | 
            +
                      commands:
         | 
| 19 | 
            +
                        - checkout
         | 
| 20 | 
            +
                        - cache restore
         | 
| 21 | 
            +
                        - bundle install --deployment -j 4 --path vendor/bundle
         | 
| 22 | 
            +
                        - nvm install
         | 
| 23 | 
            +
                        - bin/yarn install --cache-folder ~/.cache/yarn
         | 
| 24 | 
            +
                        - cache store
         | 
| 25 | 
            +
              - name: tests
         | 
| 26 | 
            +
                dependencies: ['cache']
         | 
| 27 | 
            +
                task:
         | 
| 28 | 
            +
                  secrets:
         | 
| 29 | 
            +
                    - name: <%= project_name %>
         | 
| 30 | 
            +
                  env_vars:
         | 
| 31 | 
            +
                    - name: DATABASE_URL
         | 
| 32 | 
            +
                      value: postgresql://postgres@localhost/test?encoding=utf8
         | 
| 33 | 
            +
                    - name: RAILS_ENV
         | 
| 34 | 
            +
                      value: test
         | 
| 35 | 
            +
                  prologue:
         | 
| 36 | 
            +
                    commands:
         | 
| 37 | 
            +
                      - checkout
         | 
| 38 | 
            +
                      - cache restore
         | 
| 39 | 
            +
                      - bundle install --deployment --path vendor/bundle
         | 
| 40 | 
            +
            promotions:
         | 
| 41 | 
            +
              - name: develop
         | 
| 42 | 
            +
                pipeline_file: develop-deploy.yml
         | 
| 43 | 
            +
                auto_promote:
         | 
| 44 | 
            +
                  when: "result = 'passed' and branch = 'develop'"
         | 
| 45 | 
            +
              - name: master
         | 
| 46 | 
            +
                pipeline_file: master-deploy.yml
         | 
| 47 | 
            +
                auto_promote:
         | 
| 48 | 
            +
                  when: "result = 'passed' and branch = 'master'"
         | 
| 49 | 
            +
              - name: testing
         | 
| 50 | 
            +
                pipeline_file: testing-deploy.yml
         | 
| 51 | 
            +
                auto_promote:
         | 
| 52 | 
            +
                  when: "result = 'passed' and branch = 'testing'"
         | 
    
        data/lib/renuo/cli/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: renuo-cli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.6.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Renuo AG
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-10- | 
| 11 | 
            +
            date: 2019-10-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: colorize
         | 
| @@ -276,6 +276,7 @@ files: | |
| 276 276 | 
             
            - bin/run
         | 
| 277 277 | 
             
            - bin/setup
         | 
| 278 278 | 
             
            - lib/renuo/cli.rb
         | 
| 279 | 
            +
            - lib/renuo/cli/app/configure_semaphore.rb
         | 
| 279 280 | 
             
            - lib/renuo/cli/app/configure_sentry.rb
         | 
| 280 281 | 
             
            - lib/renuo/cli/app/create_aws_project.rb
         | 
| 281 282 | 
             
            - lib/renuo/cli/app/create_heroku_app.rb
         | 
| @@ -293,6 +294,8 @@ files: | |
| 293 294 | 
             
            - lib/renuo/cli/app/services/cloudfront_config_service.rb
         | 
| 294 295 | 
             
            - lib/renuo/cli/app/services/markdown_parser_service.rb
         | 
| 295 296 | 
             
            - lib/renuo/cli/app/setup_uptimerobot.rb
         | 
| 297 | 
            +
            - lib/renuo/cli/app/templates/semaphore-deploy.yml.erb
         | 
| 298 | 
            +
            - lib/renuo/cli/app/templates/semaphore.yml.erb
         | 
| 296 299 | 
             
            - lib/renuo/cli/app/upgrade_laptop.rb
         | 
| 297 300 | 
             
            - lib/renuo/cli/app/upgrade_laptop/run_command.rb
         | 
| 298 301 | 
             
            - lib/renuo/cli/app/upgrade_laptop/upgrade_laptop_execution.rb
         |