ninny 0.1.5 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +47 -0
- data/.github/workflows/main.yml +34 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +27 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -2
- data/Guardfile +7 -0
- data/LICENSE.txt +1 -1
- data/README.md +78 -12
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/exe/ninny +4 -3
- data/lib/ninny.rb +4 -2
- data/lib/ninny/cli.rb +6 -12
- data/lib/ninny/commands/create_dated_branch.rb +13 -9
- data/lib/ninny/commands/output_dated_branch.rb +2 -1
- data/lib/ninny/commands/pull_request_merge.rb +10 -5
- data/lib/ninny/commands/setup.rb +32 -14
- data/lib/ninny/git.rb +27 -22
- data/lib/ninny/project_config.rb +4 -2
- data/lib/ninny/repository/gitlab.rb +24 -14
- data/lib/ninny/repository/pull_request.rb +5 -2
- data/lib/ninny/user_config.rb +4 -4
- data/lib/ninny/version.rb +1 -1
- data/ninny.gemspec +35 -57
- metadata +121 -38
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile.lock +0 -159
- data/lib/ninny/commands/.gitkeep +0 -1
- data/lib/ninny/templates/.gitkeep +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbd94550d42dd1d2280ae1838482dc22f67ec5abaea0abacdf57feccc6fedc23
|
4
|
+
data.tar.gz: 5801551978e1805825178d2544f3bd94554bf944f1e095b35f8448a7ed9e1ad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53df5cd87f9193a26bb0976bf4bf0efbcb10a1e2c4e6c6cc25a1381ae11ad69f8279f60fcc05848f0127e19982d08a7505f2c7e49b9b62a785af957a6a717b11
|
7
|
+
data.tar.gz: a9534c205c2f24cab166a80795e11038040afa0bac73592da8af8d4762a1bd820224d39b1a85fb7930b5c1e637d6f24ce9d3c0e6032ca7d78c7aba3a6c014a38
|
@@ -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
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.
|
1
|
+
2.7.2
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# Ninny
|
2
2
|
|
3
|
-
|
3
|
+
Ninny is a command line workflow for git with GitLab. It is maintained by the engineers of Dispatch.
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
19
|
+
```bash
|
20
|
+
$ bundle install
|
21
|
+
```
|
18
22
|
|
19
|
-
|
23
|
+
Then, you'll need to install the gem on your local computer:
|
20
24
|
|
21
|
-
|
25
|
+
```bash
|
26
|
+
$ gem install ninny
|
27
|
+
```
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
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
|
-
|
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
|
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/
|
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 [
|
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
|
109
|
+
Copyright (c) 2019 Dispatch. See [MIT License](LICENSE.txt) for further details.
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
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
|
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
|
-
|
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 =>
|
16
|
-
puts "ERROR: #{
|
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
|
-
@
|
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
|
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
|
-
|
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(
|
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(
|
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
|
-
|
41
|
-
extra_branches.
|
42
|
-
|
43
|
-
|
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).
|
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
|
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
|