pdksync 0.2.0 → 0.6.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: 1ddb56d6bd4366f686243b4d773083709f966726caf0d2fd580aba1e9373c890
4
- data.tar.gz: 34063f7b4a545f18f89c58b260061ffb93575b7f15ad932cb8ddeb9ed50ea209
3
+ metadata.gz: fb15750eeb297a36837b502c7d29661a13d19ce65211ce5d63f8a544720b5393
4
+ data.tar.gz: 2ebd4e07bf5ac24a0d918cddc33b56e5e93041f6318aacc7a9ff642e27d5345b
5
5
  SHA512:
6
- metadata.gz: 027c7bf9b6d2482631119390863bccc0295a4c8737ef3e741a793cf163f57a726be46a99fb116d43055deeab3f69420ee88065878e8d58df637d0536e57055a1
7
- data.tar.gz: 25b0cec819fb71ee5030e3a357deacb8ce219bd81323bf33e861b3cd5b456bd9dacf2f6993e32e52fadcdcd298ea530d439eb1093aa9d21667a2a18b03abc66b
6
+ metadata.gz: 14e2f4b50f71803db6e082a92122ab6aa1daef58636be4fde4edfb7ae9a21a27171c5edd76e012000e96c053c9e4388b7f3585fc0852c218710e852e0a6f2fbc
7
+ data.tar.gz: 69bd6f2f2260078aef909b219a3b468d402889b5393c1f30cad5b836e0d85919ae62991617fe81832963f11c3e4b4fd781af5b5d8b092e78c367546f51a4fac0
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ modules/
4
4
  Gemfile.lock
5
5
  .bundle/
6
6
  modules_pdksync/
7
+ .idea/
data/.rubocop.yml CHANGED
@@ -1,28 +1,31 @@
1
1
  ---
2
2
  AllCops:
3
3
  DisplayCopNames: true
4
- TargetRubyVersion: '2.1'
5
4
  Include:
6
- - "./**/*.rb"
5
+ - "./**/*.rb"
7
6
  Exclude:
8
- - bin/*
9
- - ".vendor/**/*"
10
- - Gemfile
11
- - Rakefile
12
- - pkg/**/*
13
- - spec/fixtures/**/*
14
- - vendor/**/*
15
- - modules_pdksync/**/*
7
+ - bin/*
8
+ - ".vendor/**/*"
9
+ - Gemfile
10
+ - Rakefile
11
+ - pkg/**/*
12
+ - spec/fixtures/**/*
13
+ - vendor/**/*
14
+ - modules_pdksync/**/*
16
15
  Metrics/LineLength:
17
16
  Description: People have wide screens, use them.
18
- Max: 200
17
+ Max: 235
19
18
  Style/BlockDelimiters:
20
- Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
19
+ Description:
20
+ Prefer braces for chaining. Mostly an aesthetical choice. Better to
21
21
  be consistent then.
22
22
  EnforcedStyle: braces_for_chaining
23
23
  Style/ClassAndModuleChildren:
24
+ Enabled: false
24
25
  Description: Compact style reduces the required amount of indentation.
25
26
  EnforcedStyle: compact
27
+ Exclude:
28
+ - lib/pdksync/configuration.rb
26
29
  Style/EmptyElse:
27
30
  Description: Enforce against empty else clauses, but allow `nil` for clarity.
28
31
  EnforcedStyle: empty
@@ -30,7 +33,8 @@ Style/FormatString:
30
33
  Description: Following the main puppet project's style, prefer the % format format.
31
34
  EnforcedStyle: percent
32
35
  Style/FormatStringToken:
33
- Description: Following the main puppet project's style, prefer the simpler template
36
+ Description:
37
+ Following the main puppet project's style, prefer the simpler template
34
38
  tokens over annotated ones.
35
39
  EnforcedStyle: template
36
40
  Style/Lambda:
@@ -40,12 +44,14 @@ Style/RegexpLiteral:
40
44
  Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168
41
45
  EnforcedStyle: percent_r
42
46
  Style/TernaryParentheses:
43
- Description: Checks for use of parentheses around ternary conditions. Enforce parentheses
47
+ Description:
48
+ Checks for use of parentheses around ternary conditions. Enforce parentheses
44
49
  on complex expressions for better readability, but seriously consider breaking
45
50
  it up.
46
51
  EnforcedStyle: require_parentheses_when_complex
47
52
  Style/TrailingCommaInArguments:
48
- Description: Prefer always trailing comma on multiline argument lists. This makes
53
+ Description:
54
+ Prefer always trailing comma on multiline argument lists. This makes
49
55
  diffs, and re-ordering nicer.
50
56
  EnforcedStyleForMultiline: comma
51
57
  Style/SymbolArray:
@@ -82,3 +88,8 @@ Style/IfUnlessModifier:
82
88
  Enabled: false
83
89
  Style/SymbolProc:
84
90
  Enabled: false
91
+ Style/Documentation:
92
+ Exclude:
93
+ - lib/pdksync/utils.rb
94
+ - lib/pdksync/logger.rb
95
+ - lib/pdksync/configuration.rb
data/.travis.yml CHANGED
@@ -1,27 +1,28 @@
1
- sudo: false
2
- dist: trusty
1
+ ---
2
+ os: linux
3
+ dist: xenial
3
4
  language: ruby
4
5
  cache: bundler
5
6
  before_install:
6
- - bundle -v
7
- - rm -f Gemfile.lock
8
- - gem update --system
9
- - gem --version
10
- - bundle -v
7
+ - bundle -v
11
8
  script:
12
- - bundle exec $CHECK
13
- rvm:
14
- - 2.4.1
15
- matrix:
9
+ - SIMPLECOV=yes bundle exec $CHECK
10
+ jobs:
16
11
  fast_finish: true
17
12
  include:
18
- - env: CHECK='rubocop'
19
- - env: CHECK='rspec spec'
13
+ - env: CHECK='rubocop'
14
+ rvm: 2.5
15
+ - env: CHECK='rspec spec'
16
+ rvm: 2.4
17
+ - env: CHECK='rspec spec'
18
+ rvm: 2.5
19
+ - env: CHECK='rspec spec'
20
+ rvm: 2.7
20
21
  branches:
21
22
  only:
22
- - master
23
- - "/^v\\d/"
24
- - release
23
+ - main
24
+ - "/^v\\d/"
25
+ - release
25
26
  env:
26
27
  global:
27
28
  secure: Hk8cxtIHM6kyRBSmcWWUSXUV50E/yo3MGJf3mPphb3ORUfzqjB8FGZLSn1VCIP81y++U6pZAg8/AkvcDNME0at1wWh/ONiOwYKxAyyVfr0/5/i7a+dIj/9MX2kUT6MBKZXipbln/u5brdwBAHJccFHz7doq30Nd108KE5ucqf0ZbptJyDbpsrIturK9Hx+mde9sYd6MyNlzGJkQOhSL22Zd+ppBSf/GDpk2+yWN171oGwHDPWPE47q4nkIrWjnWy0kLCqxoM0zHIPxPES6lhudso4ofbumnRiHcr7DldReC8Rq1CUe/fhG7udGEdPN26JAREyUeD8MOwo2uQohQluHvjOMx9leF7Sbu+tk5E2bqVz5ofm0bksZUIBahUtGP+REvwVruFOH8RsvO3pQBndDKG11691UY55L9qZNaQ82cNOWbfG1nNuglH0GIpJgdhjvWuGw1he4c18u1fgQGM01xO7JEDIpYHrrjBboD3mL/iXMmvxwg35eIrlkfdgl9DTBWqKOoLi79WpkDajI+2B/ABXW4L/WKWlM041UjAs5/r3jgkbcZz1nZVbU4Wa5r/6RvIfrM/FXnaGuZcwx7VdPBmfyhV4rgM4siyJDdhqudTRsq1+Al9q3MhZcyKQLmad8ShEx+dfG9WRBoayE+piD/9xkfriqdMk5YEjH02grE=
data/CHANGELOG.md CHANGED
@@ -2,9 +2,72 @@
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.2.0](https://github.com/puppetlabs/pdksync/tree/0.1.0) (2018-11-02)
5
+ ## [0.6.0](https://github.com/puppetlabs/pdksync/tree/0.6.0) (2021-08-16)
6
6
 
7
- [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.1.0...0.1.0)
7
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.5.0...0.6.0)
8
+
9
+ ### Added
10
+
11
+ - \(FEAT\) Add tasks for updating supported platforms / requirements [\#142](https://github.com/puppetlabs/pdksync/pull/142) ([sanfrancrisko](https://github.com/sanfrancrisko))
12
+ - Add tasks to add / update entries in module's provision.yaml [\#136](https://github.com/puppetlabs/pdksync/pull/136) ([sanfrancrisko](https://github.com/sanfrancrisko))
13
+ - \(MODULES-10379\) Multi Gem testing [\#128](https://github.com/puppetlabs/pdksync/pull/128) ([sheenaajay](https://github.com/sheenaajay))
14
+ - \(maint\) Add bundler tasks and pdk requirement [\#120](https://github.com/puppetlabs/pdksync/pull/120) ([logicminds](https://github.com/logicminds))
15
+ - \(MODULES-9786\) Using pdksync to update the Gemfile [\#114](https://github.com/puppetlabs/pdksync/pull/114) ([sheenaajay](https://github.com/sheenaajay))
16
+ - Major refactor and new features [\#105](https://github.com/puppetlabs/pdksync/pull/105) ([logicminds](https://github.com/logicminds))
17
+
18
+ ### Fixed
19
+
20
+ - \(GH-148\) Fix logging for pdksync:pdk\_validate task [\#150](https://github.com/puppetlabs/pdksync/pull/150) ([sanfrancrisko](https://github.com/sanfrancrisko))
21
+ - \(MODULES-8440\) Ensure pdksync works on windows [\#133](https://github.com/puppetlabs/pdksync/pull/133) ([michaeltlombardi](https://github.com/michaeltlombardi))
22
+ - \(maint\) fix gemfury upload [\#132](https://github.com/puppetlabs/pdksync/pull/132) ([sheenaajay](https://github.com/sheenaajay))
23
+ - fix gemfury testing upload [\#131](https://github.com/puppetlabs/pdksync/pull/131) ([DavidS](https://github.com/DavidS))
24
+ - \(IAC-354\) Fix Gemfile update [\#130](https://github.com/puppetlabs/pdksync/pull/130) ([sheenaajay](https://github.com/sheenaajay))
25
+ - \(maint\) 27x performance improvement [\#123](https://github.com/puppetlabs/pdksync/pull/123) ([DavidS](https://github.com/DavidS))
26
+ - \(maint\) Add Requirements to README.md and fix travis [\#118](https://github.com/puppetlabs/pdksync/pull/118) ([mihaibuzgau](https://github.com/mihaibuzgau))
27
+
28
+ ## [0.5.0](https://github.com/puppetlabs/pdksync/tree/0.5.0) (2019-08-21)
29
+
30
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.4.0...0.5.0)
31
+
32
+ ### Added
33
+
34
+ - pdksync externalisation fixes [\#95](https://github.com/puppetlabs/pdksync/pull/95) ([DavidS](https://github.com/DavidS))
35
+ - \(MODULES-8730\) Display warning on outdated pdk version [\#92](https://github.com/puppetlabs/pdksync/pull/92) ([eimlav](https://github.com/eimlav))
36
+
37
+ ### Fixed
38
+
39
+ - \(MODULES-9011\) deal with modules that do not need updating [\#101](https://github.com/puppetlabs/pdksync/pull/101) ([DavidS](https://github.com/DavidS))
40
+
41
+ ## [0.4.0](https://github.com/puppetlabs/pdksync/tree/0.4.0) (2019-02-04)
42
+
43
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/v0.3.0...0.4.0)
44
+
45
+ ### Added
46
+
47
+ - \(MODULES-8419\) Refactor to add support for GitLab [\#85](https://github.com/puppetlabs/pdksync/pull/85) ([antaflos](https://github.com/antaflos))
48
+ - \(MODULES-7233\) - Add configurable file option [\#81](https://github.com/puppetlabs/pdksync/pull/81) ([eimlav](https://github.com/eimlav))
49
+
50
+ ### Fixed
51
+
52
+ - \(MODULES-8283\) - Fix PR title overwritten in pdksync runs [\#84](https://github.com/puppetlabs/pdksync/pull/84) ([eimlav](https://github.com/eimlav))
53
+ - \(MODULES-8382\) - Fix API rate limit false positive [\#83](https://github.com/puppetlabs/pdksync/pull/83) ([eimlav](https://github.com/eimlav))
54
+
55
+ ## [v0.3.0](https://github.com/puppetlabs/pdksync/tree/v0.3.0) (2018-11-15)
56
+
57
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.2.0...v0.3.0)
58
+
59
+ ### Added
60
+
61
+ - \(MODULES-8231\) - Add additional title info for pdksync runs [\#76](https://github.com/puppetlabs/pdksync/pull/76) ([eimlav](https://github.com/eimlav))
62
+ - \(MODULES-7695\) - Add maintenance labels for PRs [\#75](https://github.com/puppetlabs/pdksync/pull/75) ([eimlav](https://github.com/eimlav))
63
+
64
+ ### Fixed
65
+
66
+ - \(MODULES-8002\) - Fix bundle commands not running in correct dir [\#79](https://github.com/puppetlabs/pdksync/pull/79) ([eimlav](https://github.com/eimlav))
67
+
68
+ ## [0.2.0](https://github.com/puppetlabs/pdksync/tree/0.2.0) (2018-11-02)
69
+
70
+ [Full Changelog](https://github.com/puppetlabs/pdksync/compare/0.1.0...0.2.0)
8
71
 
9
72
  ### Added
10
73
 
data/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # Setting ownership to the modules team
2
+ * @puppetlabs/modules
data/Gemfile CHANGED
@@ -1,10 +1,13 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in pdksync.gemspec
6
6
  gemspec
7
7
 
8
- gem 'github_changelog_generator', git: 'https://github.com/skywinder/github-changelog-generator', ref: 'master'
8
+ gem 'github_changelog_generator', '~> 1.15'
9
9
  gem 'travis'
10
- gem 'colorize'
10
+
11
+ group :development do
12
+ gem 'rb-readline', require: true
13
+ end
data/README.md CHANGED
@@ -4,60 +4,476 @@ Table of Contents
4
4
  -----------------
5
5
 
6
6
  1. [Overview](#overview)
7
- 2. [Usage](#usage)
8
- 3. [How it works](#how-it-works)
9
- 4. [Installing](#installing)
10
- 5. [Workflow](#workflow)
11
- 6. [Migrating from modulesync to pdksync](#migrating-from-modulesync-to-pdksync)
12
- 7. [Contributing](#contributing)
7
+ 2. [Requirements](#requirements)
8
+ 3. [Usage](#usage)
9
+ 4. [How it works](#how-it-works)
10
+ 5. [Configuration](#configuration)
11
+ 6. [Workflow](#workflow)
12
+ 7. [Migrating from modulesync to pdksync](#migrating-from-modulesync-to-pdksync)
13
+ 8. [Contributing](#contributing)
13
14
 
14
15
  ### Overview
15
16
  --------
16
17
 
17
- Pdksync is an efficient way to run a `pdk update` command against the various repositories that we manage — keeping them up-to-date with the changes made to PDK. It is a solution for converted modules that no longer run with modulesync.
18
+ Pdksync is an efficient way to run a `pdk update` command against the various Puppet module repositories that you manage — keeping them up-to-date with the changes made to PDK. It is a solution for converted modules that no longer run with modulesync.
19
+
20
+ Pdksync by default expects that your Puppet module repositories live on GitHub and will behave accordingly. It also supports GitLab as an alternative Git hosting platform.
21
+
22
+ ### Requirements
23
+ --------
24
+ * Ruby >= 2.4.4
25
+ * Bundler ~> 1.15
18
26
 
19
27
  ### Usage
20
28
  ----------
21
29
 
22
- > Note: This tool creates a 'live' pull request against the master branch of the module it is running against — defined in `managed_modules.yml`. Before running this tool, ensure this file reflects the modules you wish it to run against, and that `constants.rb` is up-to-date with the correct namespace your modules reside in.
30
+ > Note: This tool creates a 'live' pull (merge) request against the main branch of the module it is running against — defined in `managed_modules.yml`. Before running this tool, ensure this file reflects the modules you wish it to run against. Additionally make sure that the Pdksync configuration file `$HOME/.pdksync.yml` sets the correct namespace, Git platform and Git base URI for your modules. See section [Configuration](#configuration) for details.
23
31
 
24
32
  1. To use pdksync, clone the GitHub repo or install it as a gem. Set up the environment by exporting a GitHub token:
25
- ```
26
- export GITHUB_TOKEN=<access_token>
27
- ```
33
+
34
+ ```shell
35
+ export GITHUB_TOKEN=<access_token>
36
+ ```
37
+
38
+ If you use GitLab instead of GitHub export your GitLab access token:
39
+
40
+ ```shell
41
+ export GITLAB_TOKEN=<access_token>
42
+ ```
28
43
  2. Before the script will run, you need to install the gems:
29
- ```
44
+ ```shell
30
45
  bundle install --path .bundle/gems/
31
46
  ```
32
47
  3. Once this is complete, call the built-in rake task to run the module:
33
- ```
48
+ ```shell
34
49
  bundle exec rake pdksync
35
50
  ```
36
51
 
37
52
  ### How it works
38
53
  ------------
39
54
 
40
- Pdksync is a gem that works to clone, update, and push module repositories. It is activated from within the pdksync module.
55
+ 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:
56
+
57
+ Rakefile:
58
+ ```ruby
59
+ require 'pdksync/rake_tasks'
60
+ ```
61
+
62
+ Gemfile:
63
+ ```ruby
64
+ # frozen_string_literal: true
65
+
66
+ source "https://rubygems.org"
67
+
68
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
69
+
70
+ gem 'pdksync', github: 'puppetlabs/pdksync', ref: 'pdksync-externalisation-fixes'
71
+ gem 'rake'
72
+ ```
73
+
74
+ managed_modules.yml:
75
+ ```yaml
76
+ ---
77
+ - repo1
78
+ - repo2
79
+ - repo3
80
+ - repo4
81
+ ```
82
+
83
+ pdksync.yml:
84
+ ```yaml
85
+ ---
86
+ namespace: 'YOUR GITHUB NAME'
87
+ git_base_uri: 'git@github.com'
88
+ ```
89
+
90
+
91
+ Run the following commands to check that everything is working as expected:
92
+
93
+ ```shell
94
+ bundle install --path .bundle/gems/
95
+ bundle exec rake git:clone_managed_modules
96
+ ```
97
+
98
+ pdksync tool is extended with the feature to update the Gemfile. Puppet provides a lot of useful gems to access and manage their functionality between modules. This functionality will help user to perform gem testing prior to release. User is given new rake tasks to update SHA/Version/Branch/line in the Gemfile. Then the changes can be committed, PR can be created which will run the acceptance tests in the PR. If all the tests are executing successfully then the user can close the PRS and release the gem. Below given are the workflows for doing module gem testing with pdksync.
99
+
100
+
101
+ In Workflow 1 we can clone modules, update the gem file, create the commit, push the changes and create the PR using separate rake tasks.
102
+ ```shell
103
+ bundle install --path .bundle/gems/
104
+ bundle exec rake git:clone_managed_modules
105
+ bundle exec rake 'pdksync:gem_file_update[]'
106
+ bundle exec rake 'git:create_commit[]'
107
+ bundle exec rake 'git:push'
108
+ bundle exec rake 'git:create_pr[]'
109
+ ```
110
+
111
+ In Workflow 2 we can clone modules, update the gem file, create the commit, push the changes and create the PR using single rake task
112
+ ```
113
+ Using single rake job
114
+ bundle install --path .bundle/gems/
115
+ bundle exec rake 'gem_testing[]'
116
+ ```
117
+
118
+ In Workflow 3 we can clone modules, update the gem file, run the tests locally for litmus modules without creating commit,pushing or creating the PR
119
+ ```
120
+ Using single rake job
121
+ bundle install --path .bundle/gems/
122
+ bundle exec rake git:clone_managed_modules
123
+ bundle exec rake 'pdksync:gem_file_update[]'
124
+ bundle exec rake 'pdksync:run_tests_locally[]'
125
+ bundle exec rake 'pdksync:fetch_test_results_locally[]'
126
+ ```
127
+
128
+ Once the verified gem is released we can use pdksync to update the the new version of gem released in the .sync.yaml file.
129
+
130
+ pdksync tool is extended with the feature to perform multi gem testing (`puppet-module-gems`). This functionality will identify the current version and bump the version by one. Then it will build and push the gems to gemfury account. Export the GEMFURY_TOKEN to use this rake task.
131
+
132
+ ```shell
133
+ export GEMFURY_TOKEN=<access_token>
134
+ ```
135
+
136
+ Run the following commands to check that everything is working as expected:
137
+
138
+ ```shell
139
+ bundle install --path .bundle/gems/
140
+ bundle exec rake -T
141
+ bundle exec rake 'git:clone_gem['gem_name']'
142
+ ```
143
+ Below given are the workflows for doing multi gem testing with pdksync.
144
+
145
+ In this workflow we can clone gems, update the version, build the gem, push the changes to gemfury and update the gem file of the required modules with the latest gem updated in the fury. Then we can create PR or run tests locally or run tests through jenkins to verify the module test results.
146
+
147
+ ```shell
148
+ bundle install --path .bundle/gems/
149
+ bundle exec rake 'git:clone_gem[]'
150
+ bundle exec rake 'pdksync:multi_gem_testing[]'
151
+ bundle exec rake 'pdksync:multigem_file_update[]'
152
+ ```
153
+
154
+ 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 origin — where the local copy was originally cloned. A pull request against main is opened, and pdksync begins to clone the next repository.
155
+
156
+ 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.
157
+
158
+ The following rake tasks are available with pdksync:
159
+ - `pdksync:show_config` Display the current configuration of pdksync
160
+ - `git:clone_managed_modules` Clone managed modules.
161
+ - `git:create_commit[:branch_name, :commit_message]` Stage commits for modules, branchname and commit message eg rake 'git:create_commit[flippity, commit messagez]'.
162
+ - `git:push` Push staged commits eg rake 'git:push'.
163
+ - `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]'.
164
+ - `git:clean[:branch_name]` Clean up origin branches, (branches must include pdksync in their name) eg rake 'git:clean[pdksync_origin_branch]'.
165
+ - `pdksync:pdk_convert` Runs PDK convert against modules.
166
+ - `pdksync:pdk_validate` Runs PDK validate against modules.
167
+ - `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.
168
+ - `rake pdksync` PR title outputs as `pdksync - pdksync_heads/main-0-gabccfb1`
169
+ - `rake 'pdksync[MODULES-8231]'` PR title outputs as `pdksync - MODULES-8231 - pdksync_heads/main-0-gabccfb1`
170
+ - `pdksync:run_a_command[:command, :option]` Run a command against modules eg rake 'pdksync:run_a_command[complex command here -f -gx, 'background']'. :option is an optional parameter which states to run command in backgroud.
171
+ - `pdksync:gem_file_update[[:gem_to_test, :gem_line, :gem_sha_finder, :gem_sha_replacer, :gem_version_finder, :gem_version_replacer, :gem_branch_finder, :gem_branch_replacer]]` Run gem_file_update against modules
172
+ - eg rake to update gem line `pdksync:gem_file_update['puppet_litmus', "gem 'puppet_litmus'\, git: 'https://github.com/test/puppet_litmus.git'\, branch: 'testbranch'"]'`
173
+ - eg rake to update sha `pdksync:gem_file_update['puppet_litmus', '', '20ee04ba1234e9e83eb2ffb5056e23d641c7a018', '20ee04ba1234e9e83eb2ffb5056e23d641c7a31']`
174
+ - eg rake to update version`pdksync:gem_file_update['puppet_litmus', '', '', '', "= 0.9.0", "<= 0.10.0", '', '']`
175
+ - eg rake to update branch `pdksync:gem_file_update['puppet_litmus', '', '', '', '', '', 'testbranch', 'testbranches']`
176
+ - `rake 'gem_testing[:additional_title, :gem_to_test, :gem_line, :gem_sha_finder, :gem_sha_replacer, :gem_version_finder, :gem_version_replacer, :gem_branch_finder, :gem_branch_replacer]'` Run complete Gem file testing (cloning, gemfileupdate, create commit, create PR)PR title outputs as `pdksync_gemtesting - MODULES-8231 - pdksync_heads/main-0-gabccfb1`
177
+ - eg rake to perform gem file testing `gem_testing['MODULES-testing', 'puppet_litmus', '', '20ee04ba1234e9e83eb2ffb5056e23d641c7a018', 'testsha']`
178
+ - `pdksync:run_tests_locally[:provision_type, :puppet_collection]` Run litmus modules locally
179
+ - eg rake 'pdksync:run_tests_locally["default"]'
180
+ - `pdksync:fetch_test_results_locally[]` Fetch litmus modules local run results
181
+ - eg rake 'pdksync:fetch_test_results_locally[]'
182
+ - `pdksync:run_tests_jenkins[:jenkins_server_url, :github_branch, :test_framework, :github_user]` Run traditional modules on jenkins. For now this rake task works just for test_framework: jenkins.
183
+ - eg rake 'pdksync:run_tests_jenkins[test_branch, '', test_user]'
184
+ - `pdksync:test_results_jenkins[]` Fetch traditional modules jenkins run results
185
+ - eg rake 'pdksync:test_results_jenkins[jenkins_server_url]'
186
+ - `git:clone_gem[:gem_name]` Clone gem.
187
+ - `pdksync:multi_gem_testing[:gem_name, :version_file, :build_gem, :gem_path, :gemfury_username]` Build and Push new gems built to the gemfury account for testing eg rake 'pdksync:multi_gem_testing[]'
188
+ - `pdksync:multigem_file_update[:gem_name, :gemfury_username]` Update Gemfile of the modules with the new gem should be pushed to Gemfury.'
189
+ - `pdksync:add_provision_list[:key, :provisioner, :images]` Add a provision list key to provision.yaml.
190
+ - `pdksync:generate_vmpooler_release_checks[:puppet_version]` Generates release checks in provision.yaml based on module compatible platforms and puppet version
191
+
192
+ ### Adding/Updating `provision.yaml`
193
+ To add/update an entry in the `provision.yaml`, run the following task:
194
+ ```ruby
195
+ bundle exec rake pdksync:add_provision_list[:key, :provisioner, :images]
196
+ ```
197
+ The `:images` parameter is a variable in length - everything from the 3rd arg onwards, separated by commas, will be treated as an image.
198
+ For example:
199
+ ```ruby
200
+ bundle exec rake "pdksync:add_provision_list[release_checks_latest_os, abs, 'redhat-8-x86_64', 'centos-8-x86_64', 'debian-10-x86_64', 'sles-15-x86_64', 'ubuntu-2004-x86_64', 'win-2019-core-x86_64', 'win-10-pro-x86_64']"
201
+ ```
202
+ This will create a new entry (or update an existing entry, if it already exists) in the `provision.yaml`:
203
+ ```yaml
204
+ release_checks_latest_os:
205
+ provisioner: abs
206
+ images:
207
+ - redhat-8-x86_64
208
+ - centos-8-x86_64
209
+ - debian-10-x86_64
210
+ - sles-15-x86_64
211
+ - ubuntu-2004-x86_64
212
+ - win-2019-core-x86_64
213
+ - win-10-pro-x86_64
214
+ ```
215
+
216
+ ### Generating Release Checks Config in `provision.yaml` for Given Puppet Version
217
+ To generate a release checks configuration that will use VMPooler (via the ABS provisioner) in the `provision.yaml` that satisfies both:
218
+ - The supported platforms of the given Puppet version
219
+ - The supported platforms of the module
220
+
221
+ ...you can run:
222
+ ```ruby
223
+ pdksync:generate_vmpooler_release_checks[:puppet_version]
224
+ ```
225
+
226
+ #### Step 1: Create Puppet version supported platform config entry
227
+ Ensure that the there is an entry in the `lib/pdksync/conf/puppet_abs_support_platforms.yaml` config for the Puppet version you wish to add an entry for:
228
+ ```yaml
229
+ 7:
230
+ centos: ['7', '8']
231
+ debian: ['9', '10']
232
+ oracle: ['7']
233
+ redhat: ['7', '8']
234
+ sles: ['12', '15']
235
+ scientific: ['7']
236
+ ubuntu: ['18.04', '20.04']
237
+ win: ['2012r2', '2016-core', '2019-core', '10']
238
+ ```
239
+ **NOTE: Please be aware of the requirements regarding the platform naming and version syntax. Instructions and an explanation are within the `puppet_support_platforms.yaml`**
240
+
241
+ The platforms specified above do not necessarily have to reflect ALL the platforms that Puppet version supports - this is the configuration we wish to test against.
242
+ If you do not wish to test against `solaris` then simply omit it from the above config.
243
+
244
+ #### Step 2: Add the config entries to `provision.yaml`
245
+ Say you want to add a configuration key for Puppet 7 (_and you have ensured the `puppet_support_platforms.yaml` is correct as defined in the step above_), you would run:
246
+ ```ruby
247
+ bundle exec rake 'pdksync:generate_vmpooler_release_checks[7]'
248
+ ```
249
+ This will create a `release_checks_7` entry in the `provision.yaml` of the managed modules cloned down that contains a list of appropriate number of platforms to satisfy the conditions outlined above.
250
+
251
+ ### Adding a new platform to `metadata.json`
252
+
253
+ To add a new OS or OS version to the `operatingsystem_support` key in the `metadata.json`:
254
+
255
+ ```ruby
256
+ bundle exec rake 'pdksync:add_platform_to_metadata[:os, :version]'
257
+ ```
258
+
259
+ For example, to add a new OS called 'FooBar OS' and versions `1`, `2` and `3`:
260
+
261
+ ```ruby
262
+ bundle exec rake 'pdksync:add_platform_to_metadata[FooBar,1]'
263
+ bundle exec rake 'pdksync:add_platform_to_metadata[FooBar,2]'
264
+ bundle exec rake 'pdksync:add_platform_to_metadata[FooBar,3]'
265
+ ```
266
+
267
+ To add a new version (e.g. `22.04`) to an existing entry (e.g. `Ubuntu`):
268
+
269
+ ```ruby
270
+ bundle exec rake 'pdksync:add_platform_to_metadata[Ubuntu,22.04]'
271
+ ```
272
+
273
+ **PLEASE NOTE: All OS names are normalised to the conventions defined in the `normalize_os` method - see below for more details.**
274
+
275
+ ### Removing a platform from `metadata.json`
276
+
277
+ To remove a platform version from `metadata.json`:
278
+
279
+ ```ruby
280
+ bundle exec rake 'pdksync:remove_platform_from_metadata[:os, :version]'
281
+ ```
282
+
283
+ **PLEASE NOTE: There is currently a limitation on removing an entire OS if no versions are specified - feel free to enhance with a PR :)**
284
+
285
+ For example, to remove version `14.04` from `Ubuntu`:
286
+
287
+ ```ruby
288
+ bundle exec rake 'pdksync:remove_platform_from_metadata[Ubuntu,14.04]'
289
+ ```
290
+
291
+ ### Update requirements
292
+
293
+ To add / modify a requirement from the `requirements` key of the `metadata.json`:
294
+
295
+ ```ruby
296
+ bundle exec rake 'pdksync:update_requirements[:name, :key, :value]'
297
+ ```
298
+
299
+ **PLEASE NOTE: There is currently a limitation on removing an entire requirement entry - feel free to enhance with a PR :)**
300
+
301
+ To update the `puppet` `version_requirement` requirement to `>= 6.0.0 < 8.0.0`:
302
+
303
+ ```ruby
304
+ bundle exec rake 'pdksync:update_requirements[puppet,version_requirement,>= 6.0.0 < 8.0.0]'
305
+ ```
306
+
307
+ To add a new requirement called `foobar` with a parameter called `baz` which has a value of `123`:
308
+
309
+ ```ruby
310
+ bundle exec rake 'pdksync:update_requirements[foobar,baz,123]'
311
+ ```
312
+
313
+ ### Normalize Supported Platforms
314
+
315
+ To normalize the platforms and versions (Windows only) defined in the `operatingsystem_support` key of the `metadata.json` based on [these rules](https://github.com/puppetlabs/pdksync/blob/ebb84d81d2c15115f896995043eac6d666a114a0/lib/pdksync/utils.rb#L1043-L1098):
316
+
317
+ ```ruby
318
+ bundle exec rake 'pdksync:normalize_metadata_supported_platforms'
319
+ ```
320
+
321
+ ### Configuration
322
+
323
+ 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:
324
+ ```yaml
325
+ ---
326
+ namespace: 'puppetlabs'
327
+ pdksync_dir: 'modules_pdksync'
328
+ pdksync_gem_dir: 'gems_pdksync',
329
+ push_file_destination: 'origin'
330
+ create_pr_against: 'main'
331
+ managed_modules: 'managed_modules.yml'
332
+ pdksync_label: 'maintenance'
333
+ git_platform: :github
334
+ git_base_uri: 'https://github.com'
335
+ # Only used when git_platform is set to :gitlab
336
+ gitlab_api_endpoint: 'https://gitlab.com/api/v4'
337
+ ```
338
+
339
+ You may override any property. Those that are not specified in your config file will use their corresponding default value from `lib/pdksync/constants.rb`.
41
340
 
42
- 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.
341
+ #### Git platform support
342
+
343
+ By default pdksync assumes you are hosting your Puppet modules on GitHub, and GitHub is the only platform officially supported by Puppetlabs in pdksync.
344
+
345
+ Pdksync also supports the GitLab platform, but without official support by Puppetlabs.
346
+
347
+ ##### GitHub
348
+ Github.com and Github enterprise both work with octokit which is used in pdksync. There are some settings
349
+ you will need to adjust if using the on premise github enterprise edition.
350
+
351
+ 1. `api_endpoint: https://mygithub.mycompany.com/api/v3`
352
+ 2. `git_base_uri: git@mygithub.mycompany.com`
353
+ 3. `export GITHUB_TOKEN=k3939isdiasdf93i_` (your token goes here)
354
+
355
+ To use GitHub.com you only need to export your GitHub access token as the
356
+ environment variable `GITHUB_TOKEN` and configure the namespace in which your
357
+ modules are hosted in `$HOME/.pdksync.yml` as described above.
358
+
359
+ ##### GitLab
360
+
361
+ To use GitLab at `https://gitlab.com` you need to set `git_platform: :gitlab`
362
+ and configure the namespace of your modules in `$HOME/.pdksync.yml`. You also
363
+ need to export your GitLab access token as the environment variable
364
+ `GITLAB_TOKEN`.
365
+
366
+ Your `$HOME/.pdksync.yml` then looks like this:
367
+
368
+ ```yaml
369
+ # ~/pdksync.yml
370
+ ---
371
+ namespace: 'acme'
372
+ git_platform: :gitlab
373
+ ```
374
+
375
+ Export your GitLab access token:
376
+
377
+ ```shell
378
+ export GITLAB_TOKEN=<your GitLab access token here>
379
+ ```
380
+
381
+ If you are running your own GitLab instance on premise or use a GitLab instance
382
+ other than the official one at `https://gitlab.com` you also need to configure
383
+ `git_base_uri` and `api_endpoint` in `$HOME/.pdksync.yml` so that
384
+ pdksync knows from where to clone your modules and where to access to GitLab
385
+ API to create the live merge requests:
386
+
387
+ ```yaml
388
+ # ~/pdksync.yml
389
+ ---
390
+ namespace: 'puppetmodules'
391
+ git_platform: :gitlab
392
+ git_base_uri: 'https://gitlab.example.com'
393
+ # alternatively use SSH:
394
+ #git_base_uri: 'ssh://git@gitlab.example.com:2222'
395
+ api_endpoint: 'https://gitlab.example.com/api/v4'
396
+ ```
397
+
398
+ ### Setting who has the authoritive
399
+ It may be desirable to allow modules to dictate which version of the pdk-templates they should sync with.
400
+ There are a few settings you can tune to allow for this kind of flexability. These settings are in the pdksync.yml file. All of these settings are optional and have sane defaults. See `rake pdksync:show_config` for the settings that will be used.
401
+
402
+ - pdk_templates_prefix: 'nwops-' (example only, keep as empty string)
403
+ - pdk_templates_ref: 1.12.0
404
+ - pdk_templates_url: https://github.com/puppetlabs/pdk-templates.git
405
+ - module_is_authoritive: true
406
+
407
+ The first setting is `module_is_authoritive`. When this is set to true the templates and ref specified in the metadata become the authoritive source for these settings. Even if you have pdk_templates_ref and pdk_templates_url specified in pdksync.yml the metadata settings will alwasys be used.
408
+
409
+ ```json
410
+ # module/metadata.json
411
+ {
412
+ "pdk-version": "1.11.1",
413
+ "template-url": "https://github.com/puppetlabs/pdk-templates#main",
414
+ "template-ref": "heads/main-0-gb096033"
415
+ }
416
+
417
+ ```
418
+
419
+ When `module_is_authoritive` is set to false the pdk_templates_ref and pdk_templates_url will override what is found in the modules's metadata.json file. This is very useful when you have to control pdk-template upgrades on modules.
420
+
421
+ The other settings dictiate where the templates are located and which branch, tag or reference you want to use.
422
+ `pdk_templates_ref: 'main'` and `pdk_templates_url: https://github.com/puppetlabs/pdk-templates.git`. These settings will only be utilized if module_is_authoritive is set to false. However, if you are performing a conversion via pdksync these settings will also be used since the metadata in the module being converted doesn't have pdk settings yet.
423
+
424
+ The last setting `pdk_templates_prefix` is a special use case that allows folks with internal forks of pdk-templates to keep branches of the pdk-template tags with additional custom changes. Setting this to an empty string disables this. You will most likely need to resolve conflicts with this workflow, so it is not for everyone. If you know of a better way please submmit a pull request.
425
+
426
+ This strategy works in conjunction with the pdk-template git tags and the workflow looks like:
427
+ 1. git fetch upstream (github.com/puppetlabs/pdk-templates)
428
+ 2. git checkout main && git rebase upstream/main
429
+ 3. git checkout -b nwops-1.0.13 nwops-1.0.12
430
+ 4. git rebase 1.0.13
431
+ 5. git push origin nwops-1.0.13
432
+
433
+
434
+ ### Supporting multiple namespaces
435
+ If you have multiple namespaces that you need to support you will need to create a pdksync.yml config
436
+ file for each namespace. This will allow you to create a folder structure and keep a separate
437
+ managed_modules.yml for that namespace too.
438
+
439
+ You can set a PDKSYNC_CONFIG_PATH environment variable that points to the specific pdksync.yml config file for use in a CI or on the CLI. This allows you to set custom names for pdksync.yml file.
440
+
441
+ example: `PDKSYNC_CONFIG_PATH=pdksync_ops.yml`
442
+
443
+ Or you can set a different HOME environment variable that tells pdksync where to find the pdksync.yml file. Pdksync will locate the pdksync.yml file in the HOME folder you specify. The config file name is not changable in this case.
444
+
445
+ example: `HOME=ops`
446
+
447
+ ### Logging output
448
+ Pdksync uses a logger class to log all output. You can control how the logger works via a few environment variables.
449
+
450
+ To control the level set the `LOG_LEVEL` to one of
451
+ 1. info
452
+ 2. debug
453
+ 3. fatal
454
+ 4. error
455
+ 5. warn
456
+
457
+ To control where the logs are sent (defaults to stdout) set the `PDKSYNC_LOG_FILENAME` to a file path.
43
458
 
44
459
  ### Workflow
45
460
  --------
46
461
 
47
- It currently runs without additional arguments. To alter how it runs, make alterations to either the `constants.rb` or `managed_modules.yml`.
462
+ It currently runs without additional arguments. To alter how it runs, make alterations to either `HOME/.pdksync.yml` or `managed_modules.yml`.
48
463
 
49
464
  ### Managed modules
50
465
  ----------
51
466
 
52
467
  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:
53
468
 
54
- ```
469
+ ```yaml
55
470
  ---
56
471
  - puppetlabs-motd
57
472
  - puppetlabs-stdlib
58
473
  - puppetlabs-mysql
59
474
  ```
60
- To add a module, add it to the list. To remove a module, remove it from the list.
475
+
476
+ To add a module, add it to the list. To remove a module, remove it from the list. If you wish to specify a custom managed modules file, use the `managed_modules` property in your configuration file to specify the path to the file.
61
477
 
62
478
  ### Migrating from modulesync to pdksync
63
479
  --------
@@ -90,7 +506,7 @@ When you're confident everything is in good shape, you can start converting your
90
506
  Useful commands via the .sync.yml:
91
507
 
92
508
  - Add additional gem dependencies:
93
- ```
509
+ ```yaml
94
510
  Gemfile:
95
511
  required:
96
512
  ':system_tests':
@@ -98,18 +514,18 @@ Gemfile:
98
514
  platforms: ruby
99
515
  ```
100
516
  - Make changes to your travis configuration:
101
- ```
517
+ ```yaml
102
518
  .travis.yml:
103
519
  branches:
104
520
  - release
105
521
  ```
106
522
  - Delete files that you don't want to exist in the repo:
107
- ```
523
+ ```yaml
108
524
  .gitlab-ci.yml:
109
525
  delete: true
110
526
  ```
111
527
  - Unmanage files that you don't want to be managed:
112
- ```
528
+ ```yaml
113
529
  .gitlab-ci.yml:
114
530
  unmanaged: true
115
531
  ```
@@ -141,15 +557,15 @@ This tool has been developed and tested on OSX and Linux. **It currently does no
141
557
 
142
558
  1. Fork the repo
143
559
  2. Create your feature branch:
144
- ```
560
+ ```shell
145
561
  git checkout -b my-new-feature
146
562
  ```
147
563
  3. Commit your changes:
148
- ```
564
+ ```shell
149
565
  git commit -am 'Add some feature'
150
566
  ```
151
567
  4. Push to the branch:
152
- ```
568
+ ```shell
153
569
  git push origin my-new-feature
154
570
  ```
155
571
  5. Create a new pull request