pdksync 0.4.0 → 0.5.0

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: ab2ac9994044ffbddbbe2a6a18933d764477c2cdff17578abc2b203272c0bca0
4
- data.tar.gz: da3644827bdad46868369dd0297ebae4dedfd15225ccf41def3aecdb5c0bfd73
3
+ metadata.gz: db56fccacb1a8fd65ffe4179aaad15fecbcd041b199748f08984dbce2a8d5064
4
+ data.tar.gz: 25586423e467cf87fa7986237dd954d1be333bbe343eed24f50653627e90385e
5
5
  SHA512:
6
- metadata.gz: 9d35e566ef6c5f29fdff5536721343d9c21aeedca3c3465afc4813183cc6b3ff6919687e43c63167649a6024fb711f420fbd9d604f402880eb99d32d0c1483f1
7
- data.tar.gz: e5a4b656cc8a940d106a652b6a3818e3fc7106020b3581d192eb2d5706183a069edf59e1d6196c4aaf06c495f876bfe6c2591079abbb3e9b585196a863bf91ba
6
+ metadata.gz: bc7e96689dcba3b6c19c5b3f04be7ce8a89f5ec08de728336d20e688d34dd0676a9e26b3a877e373c7b5f89cec352921e58c13e8b017a91b34cdb4f38129a79e
7
+ data.tar.gz: b2866e5751b9528062b907b2d1292c17037aa437d4f2e1bab3d2a63c21a6d459a6f35bb8a1517ad98a8c2022ab09a3434f7c13518130cdec1a4363469af13215
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [0.5.0](https://github.com/puppetlabs/pdksync/tree/0.5.0) (2019-08-21)
6
+
7
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.4.0...0.5.0)
8
+
9
+ ### Added
10
+
11
+ - pdksync externalisation fixes [\#95](https://github.com/puppetlabs/pdksync/pull/95) ([DavidS](https://github.com/DavidS))
12
+ - \(MODULES-8730\) Display warning on outdated pdk version [\#92](https://github.com/puppetlabs/pdksync/pull/92) ([eimlav](https://github.com/eimlav))
13
+
14
+ ### Fixed
15
+
16
+ - \(MODULES-9011\) deal with modules that do not need updating [\#101](https://github.com/puppetlabs/pdksync/pull/101) ([DavidS](https://github.com/DavidS))
17
+
5
18
  ## [0.4.0](https://github.com/puppetlabs/pdksync/tree/0.4.0) (2019-02-04)
6
19
 
7
20
  [Full Changelog](https://github.com/puppetlabs/pdksync/compare/v0.3.0...0.4.0)
data/Gemfile CHANGED
@@ -7,4 +7,3 @@ gemspec
7
7
 
8
8
  gem 'github_changelog_generator', git: 'https://github.com/skywinder/github-changelog-generator', ref: 'master'
9
9
  gem 'travis'
10
- gem 'colorize'
data/README.md CHANGED
@@ -25,50 +25,93 @@ Pdksync by default expects that your Puppet module repositories live on GitHub a
25
25
 
26
26
  1. To use pdksync, clone the GitHub repo or install it as a gem. Set up the environment by exporting a GitHub token:
27
27
 
28
- ```
28
+ ```shell
29
29
  export GITHUB_TOKEN=<access_token>
30
30
  ```
31
31
 
32
32
  If you use GitLab instead of GitHub export your GitLab access token:
33
33
 
34
- ```
34
+ ```shell
35
35
  export GITLAB_TOKEN=<access_token>
36
36
  ```
37
37
  2. Before the script will run, you need to install the gems:
38
- ```
38
+ ```shell
39
39
  bundle install --path .bundle/gems/
40
40
  ```
41
41
  3. Once this is complete, call the built-in rake task to run the module:
42
- ```
42
+ ```shell
43
43
  bundle exec rake pdksync
44
44
  ```
45
45
 
46
46
  ### How it works
47
47
  ------------
48
48
 
49
- Pdksync is a gem that works to clone, update, and push module repositories. It is activated from within the pdksync module.
49
+ Pdksync is a gem that works to clone, update, and push module repositories. Create a new git repository to store your working config. You need the following files in there:
50
+
51
+ Rakefile:
52
+ ```ruby
53
+ require 'pdksync/rake_tasks'
54
+ ```
55
+
56
+ Gemfile:
57
+ ```ruby
58
+ # frozen_string_literal: true
59
+
60
+ source "https://rubygems.org"
61
+
62
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
63
+
64
+ gem 'pdksync', github: 'puppetlabs/pdksync', ref: 'pdksync-externalisation-fixes'
65
+ gem 'rake'
66
+ ```
67
+
68
+ managed_modules.yml:
69
+ ```yaml
70
+ ---
71
+ - repo1
72
+ - repo2
73
+ - repo3
74
+ - repo4
75
+ ```
76
+
77
+ pdksync.yml:
78
+ ```yaml
79
+ ---
80
+ namespace: 'YOUR GITHUB NAME'
81
+ git_base_uri: 'git@github.com:'
82
+ ```
50
83
 
51
- The gem takes in a file, `managed_modules.yml`, stored within the gem that lists all the repositories that need to be updated. It then clones them, one after another, so that a local copy exists. The update command is ran against this local copy, with the subsequent changes being added into a commit on a unique branch. It is then pushed back to the remote master — where the local copy was originally cloned. The commit is merged to the master via a pull request, causing the gem to begin to clone the next repository.
52
84
 
53
- By default, pdksync will supply a label to a PR (default is 'maintenance'). This can be changed by creating `$HOME/.pdksync.yml` and setting the `pdksync_label` key. You must ensure that the label selected exists on the modules that you are applying pdksync to. Should you wish to disable this feature, simply change `pdksync_label` to an empty string i.e. `''`. Similarly, when supplying a label using the `git:push_and_create_pr` rake task, the label must exist on each of the managed modules to run successfully.
85
+ Run the following commands to check that everything is working as expected:
86
+
87
+ ```shell
88
+ bundle install --path .bundle/gems/
89
+ bundle exec rake -T
90
+ bundle exec rake git:clone_managed_modules
91
+ ```
92
+
93
+ The rake tasks take in a file, `managed_modules.yml`, stored within the local directory that lists all the repositories that need to be updated. It then clones them, one after another, so that a local copy exists. The `pdk update` command is ran against this local copy, with the subsequent changes being added into a commit on a unique branch. It is then pushed back to the remote master — where the local copy was originally cloned. A pull request against master is opened, and pdksync begins to clone the next repository.
94
+
95
+ By default, pdksync will supply a label to a PR (default is 'maintenance'). This can be changed by creating `pdksync.yml` in the local directory and setting the `pdksync_label` key. You must ensure that the label selected exists on the modules that you are applying pdksync to. Should you wish to disable this feature, set `pdksync_label` to an empty string i.e. `''`. Similarly, when supplying a label using the `git:create_pr` rake task, the label must exist on each of the managed modules to run successfully.
54
96
 
55
97
  The following rake tasks are available with pdksync:
56
- - `show_config` Display the current configuration of pdksync
98
+ - `pdksync:show_config` Display the current configuration of pdksync
57
99
  - `git:clone_managed_modules` Clone managed modules.
58
100
  - `git:create_commit[:branch_name, :commit_message]` Stage commits for modules, branchname and commit message eg rake 'git:create_commit[flippity, commit messagez]'.
59
- - `git:push_and_create_pr[:pr_title, :label]` Push commit, and create PR for modules. Label is optional eg rake 'git:push_and_create_pr[pr title goes here, optional label right here]'.
101
+ - `git:push` Push staged commits eg rake 'git:push'.
102
+ - `git:create_pr[:pr_title, :label]` Create PR for modules. Label is optional eg rake 'git:create_pr[pr title goes here, optional label right here]'.
60
103
  - `git:clean[:branch_name]` Clean up origin branches, (branches must include pdksync in their name) eg rake 'git:clean[pdksync_origin_branch]'.
61
- - `pdk:pdk_convert` Runs PDK convert against modules.
62
- - `pdk:pdk_validate` Runs PDK validate against modules.
104
+ - `pdksync:pdk_convert` Runs PDK convert against modules.
105
+ - `pdksync:pdk_validate` Runs PDK validate against modules.
63
106
  - `pdksync[:additional_title]` Run full pdksync process, clone repository, pdk update, create pr. Additional information can be added to the title, which will be appended before the reference section.
64
107
  - `rake pdksync` PR title outputs as `pdksync - pdksync_heads/master-0-gabccfb1`
65
108
  - `rake 'pdksync[MODULES-8231]'` PR title outputs as `pdksync - MODULES-8231 - pdksync_heads/master-0-gabccfb1`
66
- - `run_a_command[:command]` Run a command against modules eg rake 'run_a_command[complex command here -f -gx]'
109
+ - `pdksync:run_a_command[:command]` Run a command against modules eg rake 'pdksync:run_a_command[complex command here -f -gx]'
67
110
 
68
111
  ### Configuration
69
112
 
70
- By default pdksync will use hardcoded values for configuring itself. However, if you wish to override these values, simply create `$HOME/.pdksync.yml` and use the following format:
71
- ```
113
+ By default pdksync will use hardcoded values for configuring itself. However, if you wish to override these values, create a `pdksync.yml` in your working directory and use the following format:
114
+ ```yaml
72
115
  ---
73
116
  namespace: 'puppetlabs'
74
117
  pdksync_dir: 'modules_pdksync'
@@ -105,7 +148,7 @@ need to export your GitLab access token as the environment variable
105
148
 
106
149
  Your `$HOME/.pdksync.yml` then looks like this:
107
150
 
108
- ```
151
+ ```yaml
109
152
  # ~/pdksync.yml
110
153
  ---
111
154
  namespace: 'acme'
@@ -114,8 +157,8 @@ git_platform: :gitlab
114
157
 
115
158
  Export your GitLab access token:
116
159
 
117
- ```
118
- $ export GITLAB_TOKEN=<your GitLab access token here>
160
+ ```shell
161
+ export GITLAB_TOKEN=<your GitLab access token here>
119
162
  ```
120
163
 
121
164
  If you are running your own GitLab instance on premise or use a GitLab instance
@@ -124,7 +167,7 @@ other than the official one at `https://gitlab.com` you also need to configure
124
167
  pdksync knows from where to clone your modules and where to access to GitLab
125
168
  API to create the live merge requests:
126
169
 
127
- ```
170
+ ```yaml
128
171
  # ~/pdksync.yml
129
172
  ---
130
173
  namespace: 'puppetmodules'
@@ -145,7 +188,7 @@ It currently runs without additional arguments. To alter how it runs, make alter
145
188
 
146
189
  This module runs through a pre-set array of modules, with this array set within the `managed_modules.yml` file. This file makes use of a simple `yaml` style format to set out the different module names, for example:
147
190
 
148
- ```
191
+ ```yaml
149
192
  ---
150
193
  - puppetlabs-motd
151
194
  - puppetlabs-stdlib
@@ -185,7 +228,7 @@ When you're confident everything is in good shape, you can start converting your
185
228
  Useful commands via the .sync.yml:
186
229
 
187
230
  - Add additional gem dependencies:
188
- ```
231
+ ```yaml
189
232
  Gemfile:
190
233
  required:
191
234
  ':system_tests':
@@ -193,18 +236,18 @@ Gemfile:
193
236
  platforms: ruby
194
237
  ```
195
238
  - Make changes to your travis configuration:
196
- ```
239
+ ```yaml
197
240
  .travis.yml:
198
241
  branches:
199
242
  - release
200
243
  ```
201
244
  - Delete files that you don't want to exist in the repo:
202
- ```
245
+ ```yaml
203
246
  .gitlab-ci.yml:
204
247
  delete: true
205
248
  ```
206
249
  - Unmanage files that you don't want to be managed:
207
- ```
250
+ ```yaml
208
251
  .gitlab-ci.yml:
209
252
  unmanaged: true
210
253
  ```
@@ -236,15 +279,15 @@ This tool has been developed and tested on OSX and Linux. **It currently does no
236
279
 
237
280
  1. Fork the repo
238
281
  2. Create your feature branch:
239
- ```
282
+ ```shell
240
283
  git checkout -b my-new-feature
241
284
  ```
242
285
  3. Commit your changes:
243
- ```
286
+ ```shell
244
287
  git commit -am 'Add some feature'
245
288
  ```
246
289
  4. Push to the branch:
247
- ```
290
+ ```shell
248
291
  git push origin my-new-feature
249
292
  ```
250
293
  5. Create a new pull request
data/Rakefile CHANGED
@@ -1,77 +1,16 @@
1
- require_relative 'lib/pdksync'
2
- require 'colorize'
1
+ require 'pdksync/rake_tasks'
3
2
  require 'github_changelog_generator/task'
3
+ require 'rubocop/rake_task'
4
4
 
5
- desc 'Display the current configuration of pdksync'
6
- task :show_config do
7
- include PdkSync::Constants
8
- puts 'PDKSync Configuration'.bold.yellow
9
- puts '- Git hosting platform: '.bold + "#{PdkSync::Constants::GIT_PLATFORM}".cyan
10
- puts '- Git base URI: '.bold + "#{PdkSync::Constants::GIT_BASE_URI}".cyan
11
- if PdkSync::Constants::GIT_PLATFORM == :gitlab
12
- puts '- Gitlab API endpoint: '.bold + "#{PdkSync::Constants::GITLAB_API_ENDPOINT}".cyan
13
- end
14
- puts '- Namespace: '.bold + "#{PdkSync::Constants::NAMESPACE}".cyan
15
- puts '- PDKSync Dir: '.bold + "#{PdkSync::Constants::PDKSYNC_DIR}".cyan
16
- puts '- Push File Destination: '.bold + "#{PdkSync::Constants::PUSH_FILE_DESTINATION}".cyan
17
- puts '- Create PR Against: '.bold + "#{PdkSync::Constants::CREATE_PR_AGAINST}".cyan
18
- puts '- Managed Modules: '.bold + "#{PdkSync::Constants::MANAGED_MODULES}".cyan
19
- puts '- Default PDKSync Label: '.bold + "#{PdkSync::Constants::PDKSYNC_LABEL}".cyan
20
- end
21
-
22
- desc 'Run full pdksync process, clone repository, pdk update, create pr. Additional title information can be added to the title, which will be appended before the reference section.'
23
- task :pdksync, [:additional_title] do |task, args|
24
- args = {:branch_name => "pdksync_{ref}",
25
- :commit_message => "pdksync_{ref}",
26
- :pr_title => "pdksync_{ref}",
27
- :additional_title => args[:additional_title]}
28
- PdkSync::main(steps: [:use_pdk_ref, :clone, :pdk_update, :create_commit, :push_and_create_pr], args: args)
29
- end
30
-
31
- namespace :pdk do
32
- desc 'Runs PDK convert against modules'
33
- task :pdk_convert do
34
- PdkSync::main(steps: [:pdk_convert])
35
- end
36
-
37
- desc 'Runs PDK validate against modules'
38
- task :pdk_validate do
39
- PdkSync::main(steps: [:pdk_validate])
40
- end
41
- end
42
-
43
- namespace :git do
44
- desc 'Clone managed modules'
45
- task :clone_managed_modules do
46
- PdkSync::main(steps: [:clone])
47
- end
48
-
49
- desc "Stage commits for modules, branchname and commit message eg rake 'git:create_commit[flippity, commit messagez]'"
50
- task :create_commit, [:branch_name, :commit_message] do |task, args|
51
- PdkSync::main(steps: [:create_commit], args: args)
52
- end
53
-
54
- desc "Push commit, and create PR for modules eg rake 'git:push_and_create_pr[pr title goes here, optional label right here]'"
55
- task :push_and_create_pr, [:pr_title, :label] do |task, args|
56
- PdkSync::main(steps: [:push_and_create_pr], args: args)
57
- end
58
-
59
- desc "Clean up origin branches, (branches must include pdksync in their name) eg rake 'git:clean[pdksync_origin_branch]'"
60
- task :clean_branches, [:branch_name] do |task, args|
61
- PdkSync::main(steps: [:clean_branches], args: args)
62
- end
63
- end
64
-
65
- desc "Run a command against modules eg rake 'run_a_command[complex command here -f -gx]'"
66
- task :run_a_command, [:command] do |task, args|
67
- PdkSync::main(steps: [:run_a_command], args: args[:command])
5
+ RuboCop::RakeTask.new(:rubocop) do |t|
6
+ t.options = ['--display-cop-names']
68
7
  end
69
8
 
70
9
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
71
10
  config.user = 'puppetlabs'
72
11
  config.project = 'pdksync'
73
12
  # config.since_tag = '1.1.1'
74
- config.future_release = '0.4.0'
13
+ config.future_release = '0.5.0'
75
14
  config.exclude_labels = ['maintenance']
76
15
  config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
77
16
  config.add_pr_wo_labels = true
@@ -10,6 +10,7 @@ require 'json'
10
10
  require 'yaml'
11
11
  require 'colorize'
12
12
  require 'bundler'
13
+ require 'octokit'
13
14
 
14
15
  # @summary
15
16
  # This module set's out and controls the pdksync process
@@ -49,6 +50,7 @@ module PdkSync
49
50
  }
50
51
 
51
52
  def self.main(steps: [:clone], args: nil)
53
+ check_pdk_version
52
54
  create_filespace
53
55
  client = setup_client
54
56
  module_names = return_modules
@@ -69,8 +71,8 @@ module PdkSync
69
71
  raise 'Needs a branch_name and commit_message' if args.nil? || args[:commit_message].nil? || args[:branch_name].nil?
70
72
  puts "Commit branch_name=#{args[:branch_name]} commit_message=#{args[:commit_message]}"
71
73
  end
72
- # validation push_and_create_pr
73
- if steps.include?(:push_and_create_pr)
74
+ # validation create_pr
75
+ if steps.include?(:create_pr)
74
76
  raise 'Needs a pr_title' if args.nil? || args[:pr_title].nil?
75
77
  puts "PR title =#{args[:additional_title]} #{args[:pr_title]}"
76
78
  end
@@ -134,35 +136,47 @@ module PdkSync
134
136
  create_commit(git_instance, module_args[:branch_name], module_args[:commit_message])
135
137
  print 'commit created, '
136
138
  end
137
- if steps.include?(:push_and_create_pr)
139
+ if steps.include?(:push)
138
140
  Dir.chdir(main_path) unless Dir.pwd == main_path
139
141
  git_instance = Git.open(output_path)
140
- push_staged_files(git_instance, git_instance.current_branch, repo_name)
141
- print 'push, '
142
- pdk_version = return_pdk_version("#{output_path}/metadata.json")
143
-
144
- # If a label is supplied, verify that it is available in the repo
145
- label = module_args[:pdksync_label] ? module_args[:pdksync_label] : module_args[:label]
146
- label_valid = (label.is_a?(String) && !label.to_str.empty?) ? check_for_label(client, repo_name, label) : nil
147
-
148
- # Exit current iteration if an error occured retrieving a label
149
- if label_valid == false
150
- raise 'Ensure label is valid'
142
+ if git_instance.diff(git_instance.current_branch, "#{@push_file_destination}/#{@create_pr_against}").size != 0 # Git::Diff doesn't have empty? # rubocop:disable Style/ZeroLengthPredicate
143
+ push_staged_files(git_instance, git_instance.current_branch, repo_name)
144
+ print 'push, '
145
+ else
146
+ print 'skipped push, '
151
147
  end
152
-
153
- # Create the PR and add link to pr list
154
- pr = create_pr(client, repo_name, git_instance.current_branch, pdk_version, module_args[:pr_title])
155
- if pr.nil?
156
- break
157
- end
158
-
159
- pr_list.push(pr.html_url)
160
- print 'created pr, '
161
-
162
- # If a valid label is supplied, add this to the PR
163
- if label_valid == true
164
- add_label(client, repo_name, pr.number, label)
165
- print "added label '#{label}' "
148
+ end
149
+ if steps.include?(:create_pr)
150
+ Dir.chdir(main_path) unless Dir.pwd == main_path
151
+ git_instance = Git.open(output_path)
152
+ if git_instance.diff(git_instance.current_branch, "#{@push_file_destination}/#{@create_pr_against}").size != 0 # Git::Diff doesn't have empty? # rubocop:disable Style/ZeroLengthPredicate
153
+ pdk_version = return_pdk_version("#{output_path}/metadata.json")
154
+
155
+ # If a label is supplied, verify that it is available in the repo
156
+ label = module_args[:pdksync_label] ? module_args[:pdksync_label] : module_args[:label]
157
+ label_valid = (label.is_a?(String) && !label.to_str.empty?) ? check_for_label(client, repo_name, label) : nil
158
+
159
+ # Exit current iteration if an error occured retrieving a label
160
+ if label_valid == false
161
+ raise 'Ensure label is valid'
162
+ end
163
+
164
+ # Create the PR and add link to pr list
165
+ pr = create_pr(client, repo_name, git_instance.current_branch, pdk_version, module_args[:pr_title])
166
+ if pr.nil?
167
+ break
168
+ end
169
+
170
+ pr_list.push(pr.html_url)
171
+ print 'created pr, '
172
+
173
+ # If a valid label is supplied, add this to the PR
174
+ if label_valid == true
175
+ add_label(client, repo_name, pr.number, label)
176
+ print "added label '#{label}' "
177
+ end
178
+ else
179
+ print 'skipped pr, '
166
180
  end
167
181
  end
168
182
  if steps.include?(:clean_branches)
@@ -179,6 +193,22 @@ module PdkSync
179
193
  end
180
194
  end
181
195
 
196
+ # @summary
197
+ # Check the local pdk version against the most recent tagged release on GitHub
198
+ def self.check_pdk_version
199
+ stdout, _stderr, status = Open3.capture3("#{return_pdk_path} --version")
200
+ raise "(FAILURE) Unable to find pdk at '#{return_pdk_path}'.".red unless status.exitstatus
201
+
202
+ local_version = stdout.strip
203
+ remote_version = Octokit.tags('puppetlabs/pdk').first[:name][1..-1]
204
+
205
+ unless Gem::Version.new(remote_version) <= Gem::Version.new(local_version)
206
+ puts "(WARNING) The current version of pdk is #{remote_version} however you are using #{local_version}".red
207
+ end
208
+ rescue StandardError => error
209
+ puts "(WARNING) Unable to check latest pdk version. #{error}".red
210
+ end
211
+
182
212
  # @summary
183
213
  # This method when called will create a directory identified by the set global variable '@pdksync_dir', on the condition that it does not already exist.
184
214
  def self.create_filespace
@@ -243,8 +273,9 @@ module PdkSync
243
273
 
244
274
  def self.create_commit(git_repo, branch_name, commit_message)
245
275
  checkout_branch(git_repo, branch_name)
246
- add_staged_files(git_repo)
247
- commit_staged_files(git_repo, branch_name, commit_message)
276
+ if add_staged_files(git_repo) # ignore rubocop for clarity on side effect ordering # rubocop:disable Style/GuardClause
277
+ commit_staged_files(git_repo, branch_name, commit_message)
278
+ end
248
279
  end
249
280
 
250
281
  # @summary
@@ -357,8 +388,10 @@ module PdkSync
357
388
  if git_repo.status.changed != {}
358
389
  git_repo.add(all: true)
359
390
  puts 'All files have been staged.'
391
+ true
360
392
  else
361
393
  puts 'Nothing to commit.'
394
+ false
362
395
  end
363
396
  end
364
397
 
@@ -24,7 +24,7 @@ module PdkSync # rubocop:disable Style/ClassAndModuleChildren
24
24
 
25
25
  config = {}
26
26
 
27
- config_path = "#{ENV['HOME']}/.pdksync.yml"
27
+ config_path = File.exist?('pdksync.yml') ? 'pdksync.yml' : "#{ENV['HOME']}/.pdksync.yml"
28
28
 
29
29
  # pdksync config file must exist, not be empty and not be an empty YAML file
30
30
  if File.exist?(config_path) && YAML.load_file(config_path) && !YAML.load_file(config_path).nil?
@@ -0,0 +1,73 @@
1
+ require 'pdksync'
2
+ require 'colorize'
3
+
4
+ desc 'Run full pdksync process, clone repository, pdk update, create pr. Additional title information can be added to the title, which will be appended before the reference section.'
5
+ task :pdksync, [:additional_title] do |_task, args|
6
+ args = { branch_name: 'pdksync_{ref}',
7
+ commit_message: 'pdksync_{ref}',
8
+ pr_title: 'pdksync_{ref}',
9
+ additional_title: args[:additional_title] }
10
+ PdkSync.main(steps: [:use_pdk_ref, :clone, :pdk_update, :create_commit, :push, :create_pr], args: args)
11
+ end
12
+
13
+ namespace :pdksync do
14
+ desc 'Runs PDK convert against modules'
15
+ task :pdk_convert do
16
+ PdkSync.main(steps: [:pdk_convert])
17
+ end
18
+
19
+ desc 'Runs PDK validate against modules'
20
+ task :pdk_validate do
21
+ PdkSync.main(steps: [:pdk_validate])
22
+ end
23
+
24
+ desc "Run a command against modules eg rake 'run_a_command[complex command here -f -gx]'"
25
+ task :run_a_command, [:command] do |_task, args|
26
+ PdkSync.main(steps: [:run_a_command], args: args[:command])
27
+ end
28
+
29
+ desc 'Display the current configuration of pdksync'
30
+ task :show_config do
31
+ include PdkSync::Constants
32
+ puts 'Please note that you can override any of the configuration by using an additional file at `$HOME/.pdksync.yml`.'.bold.red
33
+ puts 'PDKSync Configuration'.bold.yellow
34
+ puts '- Git hosting platform: '.bold + PdkSync::Constants::GIT_PLATFORM.to_s.cyan
35
+ puts '- Git base URI: '.bold + PdkSync::Constants::GIT_BASE_URI.to_s.cyan
36
+ if PdkSync::Constants::GIT_PLATFORM == :gitlab
37
+ puts '- Gitlab API endpoint: '.bold + PdkSync::Constants::GITLAB_API_ENDPOINT.to_s.cyan
38
+ end
39
+ puts '- Namespace: '.bold + PdkSync::Constants::NAMESPACE.to_s.cyan
40
+ puts '- PDKSync Dir: '.bold + PdkSync::Constants::PDKSYNC_DIR.to_s.cyan
41
+ puts '- Push File Destination: '.bold + PdkSync::Constants::PUSH_FILE_DESTINATION.to_s.cyan
42
+ puts '- Create PR Against: '.bold + PdkSync::Constants::CREATE_PR_AGAINST.to_s.cyan
43
+ puts '- Managed Modules: '.bold + PdkSync::Constants::MANAGED_MODULES.to_s.cyan
44
+ puts '- Default PDKSync Label: '.bold + PdkSync::Constants::PDKSYNC_LABEL.to_s.cyan
45
+ end
46
+ end
47
+
48
+ namespace :git do
49
+ desc 'Clone managed modules'
50
+ task :clone_managed_modules do
51
+ PdkSync.main(steps: [:clone])
52
+ end
53
+
54
+ desc "Stage commits for modules, branchname and commit message eg rake 'git:create_commit[flippity, commit messagez]'"
55
+ task :create_commit, [:branch_name, :commit_message] do |_task, args|
56
+ PdkSync.main(steps: [:create_commit], args: args)
57
+ end
58
+
59
+ desc "Push commits for the module eg rake 'git:push'"
60
+ task :push do |_task|
61
+ PdkSync.main(steps: [:push], args: nil)
62
+ end
63
+
64
+ desc "Create PR for modules eg rake 'git:create_pr[pr title goes here, optional label right here]'"
65
+ task :create_pr, [:pr_title, :label] do |_task, args|
66
+ PdkSync.main(steps: [:create_pr], args: args)
67
+ end
68
+
69
+ desc "Clean up origin branches, (branches must include pdksync in their name) eg rake 'git:clean[pdksync_origin_branch]'"
70
+ task :clean_branches, [:branch_name] do |_task, args|
71
+ PdkSync.main(steps: [:clean_branches], args: args)
72
+ end
73
+ end
@@ -41,15 +41,16 @@
41
41
  #- puppetlabs-translate
42
42
  #- puppetlabs-vcsrepo
43
43
  #- puppetlabs-websphere_application_server
44
- # networking team
44
+ ## networking team
45
45
  #- cisco_ios
46
46
  #- device_manager
47
47
  #- puppetlabs-panos
48
48
  #- puppetlabs-resource_api
49
49
  ## testing only
50
- # - puppetlabs-testing
51
- # - puppetlabs-testing1
52
- # - puppetlabs-testing2
50
+ #- puppetlabs-testing
51
+ #- puppetlabs-testing1
52
+ #- puppetlabs-testing2
53
53
  ## cloud and containers team
54
- # - puppetlabs-kubernetes
55
- # - puppetlabs-rook
54
+ #- puppetlabs-kubernetes
55
+ #- puppetlabs-helm
56
+ #- puppetlabs-rook
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'pdksync'
6
- spec.version = '0.4.0'
6
+ spec.version = '0.5.0'
7
7
  spec.authors = ['Puppet']
8
8
  spec.email = ['']
9
9
  spec.summary = 'Puppet Module PDK Synchronizer'
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_development_dependency 'bundler', '~> 1.15'
21
- spec.add_development_dependency 'rake'
22
21
  spec.add_development_dependency 'rspec'
23
22
  spec.add_development_dependency 'rubocop', '~> 0.50.0'
24
- spec.add_development_dependency 'octokit'
25
- spec.add_development_dependency 'gitlab'
26
23
  spec.add_development_dependency 'pry'
27
24
 
28
25
  spec.add_runtime_dependency 'git', '~>1.3'
29
26
  spec.add_runtime_dependency 'pdk', '>= 1.4.1'
27
+ spec.add_runtime_dependency 'rake'
28
+ spec.add_runtime_dependency 'gitlab'
29
+ spec.add_runtime_dependency 'octokit'
30
+ spec.add_runtime_dependency 'colorize'
30
31
  end
@@ -45,11 +45,11 @@ describe PdkSync do
45
45
  git_repo = Git.open(@output_path)
46
46
  expect(git_repo.show).to include('kittens in mittens')
47
47
  end
48
- it 'raise when push_and_create_pr with no arguments' do
49
- expect { PdkSync.main(steps: [:push_and_create_pr]) }.to raise_error(RuntimeError, %r{Needs a pr_title})
48
+ it 'raise when create_pr with no arguments' do
49
+ expect { PdkSync.main(steps: [:create_pr]) }.to raise_error(RuntimeError, %r{Needs a pr_title})
50
50
  end
51
- it 'raise when push_and_create_pr with invalid label' do
52
- expect { PdkSync.main(steps: [:push_and_create_pr], args: { pr_title: 'My amazing PR', label: 'doot doot' }) }.to raise_error(RuntimeError, %r{Ensure label is valid})
51
+ it 'raise when create_pr with invalid label' do
52
+ expect { PdkSync.main(steps: [:create_pr], args: { pr_title: 'My amazing PR', label: 'doot doot' }) }.to raise_error(RuntimeError, %r{Ensure label is valid})
53
53
  end
54
54
  it 'raise when clean_branches with no arguments' do
55
55
  expect { PdkSync.main(steps: [:clean_branches]) }.to raise_error(RuntimeError, %r{Needs a branch_name, and the branch name contains the string pdksync})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdksync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-04 00:00:00.000000000 Z
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.50.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.50.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,41 +67,41 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rubocop
70
+ name: git
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 0.50.0
62
- type: :development
75
+ version: '1.3'
76
+ type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 0.50.0
82
+ version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
- name: octokit
84
+ name: pdk
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
89
+ version: 1.4.1
90
+ type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
96
+ version: 1.4.1
83
97
  - !ruby/object:Gem::Dependency
84
- name: gitlab
98
+ name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
- type: :development
104
+ type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
@@ -95,13 +109,13 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: pry
112
+ name: gitlab
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
- type: :development
118
+ type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
@@ -109,33 +123,33 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: git
126
+ name: octokit
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - "~>"
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
- version: '1.3'
131
+ version: '0'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - "~>"
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
- version: '1.3'
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: pdk
140
+ name: colorize
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
130
144
  - !ruby/object:Gem::Version
131
- version: 1.4.1
145
+ version: '0'
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
- version: 1.4.1
152
+ version: '0'
139
153
  description: Utility to synchronize common files across puppet modules using PDK Update.
140
154
  email:
141
155
  - ''
@@ -159,6 +173,7 @@ files:
159
173
  - lib/pdksync/gitlabclient.rb
160
174
  - lib/pdksync/gitplatformclient.rb
161
175
  - lib/pdksync/pullrequest.rb
176
+ - lib/pdksync/rake_tasks.rb
162
177
  - managed_modules.yml
163
178
  - pdksync.gemspec
164
179
  - spec/lib/pdksync_spec.rb
@@ -181,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
196
  - !ruby/object:Gem::Version
182
197
  version: '0'
183
198
  requirements: []
184
- rubyforge_project:
185
- rubygems_version: 2.7.7
199
+ rubygems_version: 3.0.4
186
200
  signing_key:
187
201
  specification_version: 4
188
202
  summary: Puppet Module PDK Synchronizer