ninny 0.1.6 → 0.1.12

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: c1b394ae3cffee19b4c978dcdcc46a442ac6cd6bb2b49915fa9838c83455b16c
4
- data.tar.gz: 36e1b4e1fd52d3049b5f097f85f183c767f6d3b7bddae24680d56838305bf2de
3
+ metadata.gz: df20c749d0ff68d76160dd8c49af839c0d5bca44b2bc843c6869c54847d6cd2a
4
+ data.tar.gz: fd04479d94849368b53d539ad1f3084e024c90d4a89d879787213dc5fd5de9a9
5
5
  SHA512:
6
- metadata.gz: b715894da4e3af69cbc8aea35e3075625320eb8f62df5925bbdc49f41a1c6bef986e431210843afc6057c2912fe9c50aa6d7f185a6ccb43e8dcb1421fb4d41d6
7
- data.tar.gz: 6b5bc90feba98311f0147441a0b6e9c0181ac3420561009d8a01e04286a3c618d37f7c10a1edb7c63b0430ba419aa0a3860d1fc47ed2423f38e272379f1666b1
6
+ metadata.gz: 7882708a164cfc52316f496f26c7203458d39c996d155a67b5fc8afedb58a9b9d60a9b44badc97ba4860815c497017ac1e47cc7dcbdd4fd89b24e4d9e3e7162c
7
+ data.tar.gz: 954e986c09b28bc6ce678fb7a88ff04f872f212ce71c8637699342eb683229b28286ba50dc32b9523ca43dbee59cece29e9ad06546fe27f600712b479a70fd3b
@@ -0,0 +1,47 @@
1
+ <!--
2
+ Your audience for this merge request description is **code reviewers**. Help them understand the technical implications involved in this change. The JIRA ticket should outline the user-facing details.
3
+
4
+ Remember that Product and QA teams may have other test cases, verifications, and requirements associated with this change. Your Verification and QA plan should be directed towards Code Reviewers.
5
+ -->
6
+
7
+ ## What and Why
8
+
9
+ <!--
10
+ What are you changing? Describe impact and scope. Why is this being changed? Provide some context that may help future developers understand the reasoning behind these changes. Quote and/or link to requirements, keeping in mind that JIRA links may not be available in the future.
11
+ -->
12
+
13
+ ## Deploy Plan
14
+
15
+ <!--
16
+ Is there anything special about this deploy? Are migrations present? Are there other merge requests that need to be shipped before this one? Are there any manual steps required, such as data migrations, search reindexes, etc?
17
+ -->
18
+
19
+ ## Rollback Plan
20
+
21
+ <!--
22
+ Is there anything special about this rollback plan? Does this merge request anything that may need to be cleaned up manually (data migrations, search reindexes, etc)? Are there other associated merge requests that would also need to be reverted?
23
+ -->
24
+
25
+ To roll back this change, revert the merge with: `git revert -m 1 MERGE_SHA` and perform another deploy.
26
+
27
+ ## Related URLs
28
+
29
+ <!--
30
+ Links to bug tickets, user stories, or other merge requests.
31
+ -->
32
+
33
+ ## Verification and QA Plan
34
+
35
+ <!--
36
+ Fill in scenarios below in checklist format and complete them before merging. Evaluate the risk level and label this merge request or indicate risk in this description. Ensure the Verification and QA Plan matches the risk level appropriately.
37
+
38
+ Consider these topics:
39
+ * regressions (did we break something else related to this change?)
40
+ * edge cases (weird scenarios we don't immediately think of, but could occur)
41
+ * happy path (testing the new feature directly)
42
+ * data model changes
43
+ * data elements to add or remove from indexes
44
+ * changes in data models requiring migrations to be performed
45
+ -->
46
+
47
+ - [ ] Example scenario
@@ -0,0 +1,34 @@
1
+ name: Main
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ pull_request:
6
+ branches: [ main ]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby: [2.6.3, 2.6.6, 2.7.0, 2.7.2]
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ with:
18
+ fetch-depth: 0
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler: 1.17.3
23
+ bundler-cache: true
24
+ - run: bundle exec rake
25
+ pronto:
26
+ if: github.EVENT_NAME == 'pull_request'
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ with:
31
+ fetch-depth: 0
32
+ - uses: HeRoMo/pronto-action@v1.13.0
33
+ with:
34
+ github_token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore CHANGED
@@ -13,3 +13,6 @@
13
13
 
14
14
  # ninny configs
15
15
  .ninny.yml*
16
+
17
+ Gemfile.lock
18
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,27 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 2.7
5
+ Exclude:
6
+ - vendor/**/*
7
+
8
+ Gemspec/RequiredRubyVersion:
9
+ Enabled: false
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Lint/EmptyClass:
15
+ Enabled: false
16
+
17
+ Lint/EmptyBlock:
18
+ Enabled: false
19
+
20
+ Lint/MissingSuper:
21
+ Enabled: false
22
+
23
+ Metrics/MethodLength:
24
+ Max: 15
25
+
26
+ Style/OptionalBooleanParameter:
27
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.7.2
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in ninny.gemspec
6
8
  gem 'tty'
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
4
+ watch(%r{^spec/.+_spec\.rb$})
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
+ watch('spec/spec_helper.rb') { 'spec' }
7
+ end
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Carl Allen
3
+ Copyright (c) 2019 Dispatch
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Ninny
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ninny`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Ninny is a command line workflow for git with GitLab. It is maintained by the engineers of Dispatch.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ We use Ninny to help us automate our development pipelines. We create weekly staging branches straight from `main`, merge feature branches into the current staging branch, and deploy to our staging environment directly from the current staging branch. We date all of our staging branches with `YYYY.MM.DD` appended to the end so that if we need to recreate a new staging branch mid-week (typically if the staging branch gets very out of date from `main`), then we know exactly which branch is the latest.
6
+
7
+ Ninny is based off of [SportsEngine's Octopolo](https://github.com/sportngin/octopolo) command-line tool.
6
8
 
7
9
  ## Installation
8
10
 
9
- Add this line to your application's Gemfile:
11
+ To use this gem with an application on GitLab, add this line to your project's Gemfile:
10
12
 
11
13
  ```ruby
12
14
  gem 'ninny'
@@ -14,30 +16,94 @@ gem 'ninny'
14
16
 
15
17
  And then execute:
16
18
 
17
- $ bundle
19
+ ```bash
20
+ $ bundle install
21
+ ```
18
22
 
19
- Or install it yourself as:
23
+ Then, you'll need to install the gem on your local computer:
20
24
 
21
- $ gem install ninny
25
+ ```bash
26
+ $ gem install ninny
27
+ ```
22
28
 
23
29
  ## Usage
24
30
 
25
- TODO: Write usage instructions here
31
+ To use this gem with a GitLab project, you'll need to add the following information in a `.ninny.yml` file in the root directory of the project:
32
+
33
+ ```yml
34
+ repo_type: gitlab
35
+ gitlab_project_id: GITLAB_PROJECT_ID
36
+ deploy_branch: DEPLOY_BRANCH
37
+ ```
38
+
39
+ The `GITLAB_PROJECT_ID` can be found in the general settings of the entire project. The `DEPLOY_BRANCH` is most likely your project's default branch.
40
+
41
+ Then, each developer on the project should set up a file at `~/.ninny.yml` on their computer. To help with this, they can run the following and follow the prompts:
42
+
43
+ ```bash
44
+ $ ninny setup
45
+ Do you have a new GitLab private token? (Y/n) y # enter 'y'
46
+ Enter private token: abc123def456ghi789jk # enter your private token
47
+ User config updated
48
+ ```
49
+
50
+ The private token should be a personal access token for that person's GitLab account (generated [here](https://gitlab.com/-/profile/personal_access_tokens)).
51
+
52
+ If that command doesn't work, then you can manually create/update that file like this:
53
+
54
+ ```yml
55
+ gitlab_private_token: abc123def456ghi789jk # private token goes here
56
+ ```
57
+
58
+ After the config files are set up, these commands are available:
59
+
60
+ ```bash
61
+ # To create a new staging branch of this format: staging.YYYY.MM.DD
62
+ $ ninny new_staging
63
+
64
+ # To list the current/latest staging branch
65
+ $ ninny staging_branch
66
+
67
+ # To merge the current branch into the current/latest staging branch
68
+ $ ninny stage_up
69
+
70
+ ```
71
+
72
+ At any point, `ninny help` will show the help screen.
26
73
 
27
74
  ## Development
28
75
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
76
+ ### Making Changes
77
+
78
+ 1. Clone or fork the repository
79
+ 2. Create a feature branch for your changes
80
+ 3. Run `bundle install`
81
+ 4. Make your changes
82
+ 5. Run `bundle exec rake` to run the tests
83
+ * Run `bundle exec guard` to run tests continuously as you develop
84
+ 6. Test the gem locally
85
+ * Run `gem build *.gemspec` to build the gem locally
86
+ * Run `gem install --local ninny-X.X.X.gem` to install the gem locally
87
+ 7. Make a pull request back to this repository
88
+
89
+ ### Releasing
90
+
91
+ 1. Make sure the `lib/ninny/version.rb` file is updated with a new version
92
+ 2. Run `git tag vX.X.X && git push --tag`
93
+ 3. Run `gem build *.gemspec`
94
+ 4. Run `gem push *.gem` to push the new version to RubyGems
95
+ 5. Run `rm *.gem` to clean up your local repository
30
96
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
97
+ To set up your local machine to push to RubyGems via the API, see the [RubyGems documentation](https://guides.rubygems.org/publishing/#publishing-to-rubygemsorg).
32
98
 
33
99
  ## Contributing
34
100
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ninny. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
101
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dispatchinc/ninny. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
102
 
37
103
  ## Code of Conduct
38
104
 
39
- Everyone interacting in the Ninny project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ninny/blob/master/CODE_OF_CONDUCT.md).
105
+ Everyone interacting in the Ninny project’s codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
106
 
41
107
  ## Copyright
42
108
 
43
- Copyright (c) 2019 Carl Allen. See [MIT License](LICENSE.txt) for further details.
109
+ Copyright (c) 2019 Dispatch. See [MIT License](LICENSE.txt) for further details.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "ninny"
4
+ require 'bundler/setup'
5
+ require 'ninny'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "ninny"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/exe/ninny CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  lib_path = File.expand_path('../lib', __dir__)
4
- $:.unshift(lib_path) if !$:.include?(lib_path)
5
+ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
5
6
  require 'ninny'
6
7
  require 'ninny/cli'
7
8
 
@@ -12,7 +13,7 @@ end
12
13
 
13
14
  begin
14
15
  Ninny::CLI.start
15
- rescue Ninny::CLI::Error => err
16
- puts "ERROR: #{err.message}"
16
+ rescue Ninny::CLI::Error => e
17
+ puts "ERROR: #{e.message}"
17
18
  exit 1
18
19
  end
data/lib/ninny.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
  require 'ninny/git'
3
5
  require 'ninny/command'
@@ -13,15 +15,15 @@ require 'ninny/repository/pull_request'
13
15
  require 'ninny/project_config'
14
16
  require 'ninny/user_config'
15
17
 
16
-
17
18
  require 'git'
18
19
  require 'gitlab'
19
20
  require 'tty-config'
20
21
 
21
22
  module Ninny
22
23
  class Error < StandardError; end
24
+
23
25
  def self.project_config
24
- @config ||= ProjectConfig.config
26
+ @project_config ||= ProjectConfig.config
25
27
  end
26
28
 
27
29
  def self.user_config
data/lib/ninny/cli.rb CHANGED
@@ -16,11 +16,10 @@ module Ninny
16
16
  require_relative 'version'
17
17
  puts "v#{Ninny::VERSION}"
18
18
  end
19
- map %w(--version -v) => :version
19
+ map %w[--version -v] => :version
20
20
 
21
21
  desc 'staging_branch', 'Returns the current staging branch'
22
- method_option :help, aliases: '-h', type: :boolean,
23
- desc: 'Display usage information'
22
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
24
23
  def staging_branch(*)
25
24
  if options[:help]
26
25
  invoke :help, ['staging_branch']
@@ -31,8 +30,7 @@ module Ninny
31
30
  end
32
31
 
33
32
  desc 'stage_up [PULL_REQUEST_ID]', 'Merges PR/MR into the staging branch'
34
- method_option :help, aliases: '-h', type: :boolean,
35
- desc: 'Display usage information'
33
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
36
34
  def stage_up(pull_request_id = nil)
37
35
  if options[:help]
38
36
  invoke :help, ['stage_up']
@@ -43,11 +41,8 @@ module Ninny
43
41
  end
44
42
 
45
43
  desc 'new_staging', 'Create a new staging branch'
46
- method_option :help, aliases: '-h', type: :boolean,
47
- desc: 'Display usage information'
48
- method_option :delete_old_branches, aliases: ['-d'], type: :boolean,
49
- desc: "Should old staging branches be deleted?"
50
-
44
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
45
+ method_option :delete_old_branches, aliases: ['-d'], type: :boolean, desc: 'Should old staging branches be deleted?'
51
46
  def new_staging(*)
52
47
  if options[:help]
53
48
  invoke :help, ['new_staging']
@@ -58,8 +53,7 @@ module Ninny
58
53
  end
59
54
 
60
55
  desc 'setup', 'Interactively setup configuration'
61
- method_option :help, aliases: '-h', type: :boolean,
62
- desc: 'Display usage information'
56
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
63
57
  def setup(*)
64
58
  if options[:help]
65
59
  invoke :help, ['setup']
@@ -4,12 +4,13 @@ module Ninny
4
4
  module Commands
5
5
  class CreateDatedBranch < Ninny::Command
6
6
  attr_reader :branch_type, :should_delete_old_branches
7
+
7
8
  def initialize(options)
8
9
  @branch_type = options[:branch_type] || Git::STAGING_PREFIX
9
10
  @should_delete_old_branches = options[:delete_old_branches]
10
11
  end
11
12
 
12
- def execute(input: $stdin, output: $stdout)
13
+ def execute(output: $stdout)
13
14
  create_branch
14
15
  delete_old_branches
15
16
  output.puts "#{branch_name} created"
@@ -22,7 +23,7 @@ module Ninny
22
23
 
23
24
  # Public: The date suffix to append to the branch name
24
25
  def date_suffix
25
- Date.today.strftime("%Y.%m.%d")
26
+ Date.today.strftime('%Y.%m.%d')
26
27
  end
27
28
 
28
29
  # Public: The name of the branch to create
@@ -35,12 +36,15 @@ module Ninny
35
36
  # Public: If necessary, and if user opts to, delete old branches of its type
36
37
  def delete_old_branches
37
38
  return unless extra_branches.any?
38
- should_delete = should_delete_old_branches || prompt.yes?("Do you want to delete the old #{branch_type} branch(es)? (#{extra_branches.join(", ")})")
39
39
 
40
- if should_delete
41
- extra_branches.each do |extra|
42
- Ninny.git.delete_branch(extra)
43
- end
40
+ should_delete = should_delete_old_branches || prompt.yes?(
41
+ "Do you want to delete the old #{branch_type} branch(es)? (#{extra_branches.join(', ')})"
42
+ )
43
+
44
+ return unless should_delete
45
+
46
+ extra_branches.each do |extra|
47
+ Ninny.git.delete_branch(extra)
44
48
  end
45
49
  end
46
50
 
@@ -49,11 +53,11 @@ module Ninny
49
53
  # Returns an Array of Strings of the branch names
50
54
  def extra_branches
51
55
  with_branch_type do
52
- Ninny.git.branches_for(branch_type).select{ |branch| branch.name != branch_name }
56
+ Ninny.git.branches_for(branch_type).reject { |branch| branch.name == branch_name }
53
57
  end
54
58
  end
55
59
 
56
- def with_branch_type(&block)
60
+ def with_branch_type
57
61
  case branch_type
58
62
  when Git::DEPLOYABLE_PREFIX, Git::STAGING_PREFIX, Git::QAREADY_PREFIX
59
63
  yield