pdksync 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +15 -0
- data/.github/workflows/ci.yml +23 -0
- data/.github/workflows/labeller.yml +22 -0
- data/.github/workflows/mend.yml +15 -0
- data/.github/workflows/nightly.yml +22 -0
- data/.github/workflows/release.yml +16 -0
- data/.github/workflows/release_prep.yml +20 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +35 -46
- data/CHANGELOG.md +69 -44
- data/CODEOWNERS +2 -0
- data/Gemfile +10 -3
- data/README.md +330 -18
- data/Rakefile +8 -29
- data/lib/pdksync/conf/puppet_abs_supported_platforms.yaml +41 -0
- data/lib/pdksync/configuration.rb +155 -0
- data/lib/pdksync/githubclient.rb +3 -1
- data/lib/pdksync/gitplatformclient.rb +2 -2
- data/lib/pdksync/jenkinsclient.rb +50 -0
- data/lib/pdksync/logger.rb +120 -0
- data/lib/pdksync/rake_tasks.rb +100 -16
- data/lib/pdksync/utils.rb +1296 -0
- data/lib/pdksync/version.rb +3 -0
- data/lib/pdksync.rb +310 -450
- data/managed_modules.yml +16 -33
- data/pdksync.gemspec +20 -17
- data/spec/configuration_spec.rb +56 -0
- data/spec/fixtures/fake_managed_modules.yaml +2 -0
- data/spec/fixtures/pdksync.yml +2 -0
- data/spec/logger_spec.rb +44 -0
- data/spec/pdksync_spec.rb +185 -0
- data/spec/spec_helper.rb +74 -0
- data/spec/utils_spec.rb +134 -0
- metadata +88 -22
- data/.travis.yml +0 -27
- data/lib/pdksync/constants.rb +0 -78
- data/spec/lib/pdksync_spec.rb +0 -58
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,57 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pdksync
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Puppet
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2023-07-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - " | 
| 17 | 
            +
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '0'
         | 
| 20 20 | 
             
              type: :development
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - " | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: codecov
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 25 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: ' | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: pry
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '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'
         | 
| 27 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 56 | 
             
              name: rspec
         | 
| 29 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -53,7 +81,7 @@ dependencies: | |
| 53 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 82 | 
             
                    version: 0.50.0
         | 
| 55 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            -
              name:  | 
| 84 | 
            +
              name: simplecov
         | 
| 57 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 86 | 
             
                requirements:
         | 
| 59 87 | 
             
                - - ">="
         | 
| @@ -67,33 +95,47 @@ dependencies: | |
| 67 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 96 | 
             
                    version: '0'
         | 
| 69 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            -
              name:  | 
| 98 | 
            +
              name: simplecov-console
         | 
| 71 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 100 | 
             
                requirements:
         | 
| 73 | 
            -
                - - " | 
| 101 | 
            +
                - - ">="
         | 
| 74 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            -
                    version: ' | 
| 76 | 
            -
              type: : | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :development
         | 
| 77 105 | 
             
              prerelease: false
         | 
| 78 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 107 | 
             
                requirements:
         | 
| 80 | 
            -
                - - " | 
| 108 | 
            +
                - - ">="
         | 
| 81 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            -
                    version: ' | 
| 110 | 
            +
                    version: '0'
         | 
| 83 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 112 | 
             
              name: pdk
         | 
| 85 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 114 | 
             
                requirements:
         | 
| 87 115 | 
             
                - - ">="
         | 
| 88 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            -
                    version: 1. | 
| 117 | 
            +
                    version: 1.14.1
         | 
| 90 118 | 
             
              type: :runtime
         | 
| 91 119 | 
             
              prerelease: false
         | 
| 92 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 121 | 
             
                requirements:
         | 
| 94 122 | 
             
                - - ">="
         | 
| 95 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            -
                    version: 1. | 
| 124 | 
            +
                    version: 1.14.1
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: git
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "~>"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '1.3'
         | 
| 132 | 
            +
              type: :runtime
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '1.3'
         | 
| 97 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 140 | 
             
              name: rake
         | 
| 99 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -137,7 +179,7 @@ dependencies: | |
| 137 179 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 180 | 
             
                    version: '0'
         | 
| 139 181 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            -
              name:  | 
| 182 | 
            +
              name: jenkins_api_client
         | 
| 141 183 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 184 | 
             
                requirements:
         | 
| 143 185 | 
             
                - - ">="
         | 
| @@ -157,26 +199,44 @@ executables: [] | |
| 157 199 | 
             
            extensions: []
         | 
| 158 200 | 
             
            extra_rdoc_files: []
         | 
| 159 201 | 
             
            files:
         | 
| 202 | 
            +
            - ".github/pull_request_template.md"
         | 
| 203 | 
            +
            - ".github/workflows/ci.yml"
         | 
| 204 | 
            +
            - ".github/workflows/labeller.yml"
         | 
| 205 | 
            +
            - ".github/workflows/mend.yml"
         | 
| 206 | 
            +
            - ".github/workflows/nightly.yml"
         | 
| 207 | 
            +
            - ".github/workflows/release.yml"
         | 
| 208 | 
            +
            - ".github/workflows/release_prep.yml"
         | 
| 160 209 | 
             
            - ".gitignore"
         | 
| 161 210 | 
             
            - ".rspec"
         | 
| 162 211 | 
             
            - ".rubocop.yml"
         | 
| 163 212 | 
             
            - ".rubocop_todo.yml"
         | 
| 164 | 
            -
            - ".travis.yml"
         | 
| 165 213 | 
             
            - CHANGELOG.md
         | 
| 214 | 
            +
            - CODEOWNERS
         | 
| 166 215 | 
             
            - Gemfile
         | 
| 167 216 | 
             
            - LICENSE
         | 
| 168 217 | 
             
            - README.md
         | 
| 169 218 | 
             
            - Rakefile
         | 
| 170 219 | 
             
            - lib/pdksync.rb
         | 
| 171 | 
            -
            - lib/pdksync/ | 
| 220 | 
            +
            - lib/pdksync/conf/puppet_abs_supported_platforms.yaml
         | 
| 221 | 
            +
            - lib/pdksync/configuration.rb
         | 
| 172 222 | 
             
            - lib/pdksync/githubclient.rb
         | 
| 173 223 | 
             
            - lib/pdksync/gitlabclient.rb
         | 
| 174 224 | 
             
            - lib/pdksync/gitplatformclient.rb
         | 
| 225 | 
            +
            - lib/pdksync/jenkinsclient.rb
         | 
| 226 | 
            +
            - lib/pdksync/logger.rb
         | 
| 175 227 | 
             
            - lib/pdksync/pullrequest.rb
         | 
| 176 228 | 
             
            - lib/pdksync/rake_tasks.rb
         | 
| 229 | 
            +
            - lib/pdksync/utils.rb
         | 
| 230 | 
            +
            - lib/pdksync/version.rb
         | 
| 177 231 | 
             
            - managed_modules.yml
         | 
| 178 232 | 
             
            - pdksync.gemspec
         | 
| 179 | 
            -
            - spec/ | 
| 233 | 
            +
            - spec/configuration_spec.rb
         | 
| 234 | 
            +
            - spec/fixtures/fake_managed_modules.yaml
         | 
| 235 | 
            +
            - spec/fixtures/pdksync.yml
         | 
| 236 | 
            +
            - spec/logger_spec.rb
         | 
| 237 | 
            +
            - spec/pdksync_spec.rb
         | 
| 238 | 
            +
            - spec/spec_helper.rb
         | 
| 239 | 
            +
            - spec/utils_spec.rb
         | 
| 180 240 | 
             
            homepage: http://github.com/puppetlabs/pdksync
         | 
| 181 241 | 
             
            licenses:
         | 
| 182 242 | 
             
            - Apache-2.0
         | 
| @@ -189,16 +249,22 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 189 249 | 
             
              requirements:
         | 
| 190 250 | 
             
              - - ">="
         | 
| 191 251 | 
             
                - !ruby/object:Gem::Version
         | 
| 192 | 
            -
                  version: 2. | 
| 252 | 
            +
                  version: '2.7'
         | 
| 193 253 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 194 254 | 
             
              requirements:
         | 
| 195 255 | 
             
              - - ">="
         | 
| 196 256 | 
             
                - !ruby/object:Gem::Version
         | 
| 197 257 | 
             
                  version: '0'
         | 
| 198 258 | 
             
            requirements: []
         | 
| 199 | 
            -
            rubygems_version: 3. | 
| 259 | 
            +
            rubygems_version: 3.1.6
         | 
| 200 260 | 
             
            signing_key: 
         | 
| 201 261 | 
             
            specification_version: 4
         | 
| 202 262 | 
             
            summary: Puppet Module PDK Synchronizer
         | 
| 203 263 | 
             
            test_files:
         | 
| 204 | 
            -
            - spec/ | 
| 264 | 
            +
            - spec/configuration_spec.rb
         | 
| 265 | 
            +
            - spec/fixtures/fake_managed_modules.yaml
         | 
| 266 | 
            +
            - spec/fixtures/pdksync.yml
         | 
| 267 | 
            +
            - spec/logger_spec.rb
         | 
| 268 | 
            +
            - spec/pdksync_spec.rb
         | 
| 269 | 
            +
            - spec/spec_helper.rb
         | 
| 270 | 
            +
            - spec/utils_spec.rb
         | 
    
        data/.travis.yml
    DELETED
    
    | @@ -1,27 +0,0 @@ | |
| 1 | 
            -
            sudo: false
         | 
| 2 | 
            -
            dist: trusty
         | 
| 3 | 
            -
            language: ruby
         | 
| 4 | 
            -
            cache: bundler
         | 
| 5 | 
            -
            before_install:
         | 
| 6 | 
            -
            - bundle -v
         | 
| 7 | 
            -
            - rm -f Gemfile.lock
         | 
| 8 | 
            -
            - gem update --system
         | 
| 9 | 
            -
            - gem --version
         | 
| 10 | 
            -
            - bundle -v
         | 
| 11 | 
            -
            script:
         | 
| 12 | 
            -
            - bundle exec $CHECK
         | 
| 13 | 
            -
            rvm:
         | 
| 14 | 
            -
            - 2.4.1
         | 
| 15 | 
            -
            matrix:
         | 
| 16 | 
            -
              fast_finish: true
         | 
| 17 | 
            -
              include:
         | 
| 18 | 
            -
              - env: CHECK='rubocop'
         | 
| 19 | 
            -
              - env: CHECK='rspec spec'
         | 
| 20 | 
            -
            branches:
         | 
| 21 | 
            -
              only:
         | 
| 22 | 
            -
              - master
         | 
| 23 | 
            -
              - "/^v\\d/"
         | 
| 24 | 
            -
              - release
         | 
| 25 | 
            -
            env:
         | 
| 26 | 
            -
              global:
         | 
| 27 | 
            -
                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/lib/pdksync/constants.rb
    DELETED
    
    | @@ -1,78 +0,0 @@ | |
| 1 | 
            -
            require 'yaml'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            # @summary
         | 
| 4 | 
            -
            #   A module used to contain a set of variables that are expected to remain constant across all iterations of the main pdksync module.
         | 
| 5 | 
            -
            # @note
         | 
| 6 | 
            -
            #   Configuration is loaded from `$HOME/.pdksync.yml`. If $HOME is not set, the config_path will use the current directory.
         | 
| 7 | 
            -
            #   Set PDKSYNC_LABEL to '' to disable adding a label during pdksync runs.
         | 
| 8 | 
            -
            module PdkSync # rubocop:disable Style/ClassAndModuleChildren
         | 
| 9 | 
            -
              # Constants contains the configuration for pdksync to use
         | 
| 10 | 
            -
              module Constants
         | 
| 11 | 
            -
                default_config = {
         | 
| 12 | 
            -
                  namespace: 'puppetlabs',
         | 
| 13 | 
            -
                  pdksync_dir: 'modules_pdksync',
         | 
| 14 | 
            -
                  push_file_destination: 'origin',
         | 
| 15 | 
            -
                  create_pr_against: 'master',
         | 
| 16 | 
            -
                  managed_modules: 'managed_modules.yml',
         | 
| 17 | 
            -
                  pdksync_label: 'maintenance',
         | 
| 18 | 
            -
                  git_platform: :github,
         | 
| 19 | 
            -
                  git_base_uri: 'https://github.com',
         | 
| 20 | 
            -
                  gitlab_api_endpoint: 'https://gitlab.com/api/v4'
         | 
| 21 | 
            -
                }
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                supported_git_platforms = [:github, :gitlab]
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                config = {}
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                config_path = File.exist?('pdksync.yml') ? 'pdksync.yml' : "#{ENV['HOME']}/.pdksync.yml"
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                # pdksync config file must exist, not be empty and not be an empty YAML file
         | 
| 30 | 
            -
                if File.exist?(config_path) && YAML.load_file(config_path) && !YAML.load_file(config_path).nil?
         | 
| 31 | 
            -
                  custom_config = YAML.load_file(config_path)
         | 
| 32 | 
            -
                  config[:namespace] = custom_config['namespace'] ||= default_config[:namespace]
         | 
| 33 | 
            -
                  config[:pdksync_dir] = custom_config['pdksync_dir'] ||= default_config[:pdksync_dir]
         | 
| 34 | 
            -
                  config[:push_file_destination] = custom_config['push_file_destination'] ||= default_config[:push_file_destination]
         | 
| 35 | 
            -
                  config[:create_pr_against] = custom_config['create_pr_against'] ||= default_config[:create_pr_against]
         | 
| 36 | 
            -
                  config[:managed_modules] = custom_config['managed_modules'] ||= default_config[:managed_modules]
         | 
| 37 | 
            -
                  config[:pdksync_label] = custom_config['pdksync_label'] ||= default_config[:pdksync_label]
         | 
| 38 | 
            -
                  config[:git_platform] = custom_config['git_platform'] ||= default_config[:git_platform]
         | 
| 39 | 
            -
                  config[:git_base_uri] = custom_config['git_base_uri'] ||= case config[:git_platform]
         | 
| 40 | 
            -
                                                                            when :gitlab
         | 
| 41 | 
            -
                                                                              'https://gitlab.com'
         | 
| 42 | 
            -
                                                                            else
         | 
| 43 | 
            -
                                                                              default_config[:git_base_uri]
         | 
| 44 | 
            -
                                                                            end
         | 
| 45 | 
            -
                  config[:gitlab_api_endpoint] = custom_config['gitlab_api_endpoint'] ||= default_config[:gitlab_api_endpoint]
         | 
| 46 | 
            -
                else
         | 
| 47 | 
            -
                  config = default_config
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                NAMESPACE = config[:namespace].freeze
         | 
| 51 | 
            -
                PDKSYNC_DIR = config[:pdksync_dir].freeze
         | 
| 52 | 
            -
                PUSH_FILE_DESTINATION = config[:push_file_destination].freeze
         | 
| 53 | 
            -
                CREATE_PR_AGAINST = config[:create_pr_against].freeze
         | 
| 54 | 
            -
                MANAGED_MODULES = config[:managed_modules].freeze
         | 
| 55 | 
            -
                PDKSYNC_LABEL = config[:pdksync_label].freeze
         | 
| 56 | 
            -
                GIT_PLATFORM = config[:git_platform].downcase.to_sym.freeze
         | 
| 57 | 
            -
                GIT_BASE_URI = config[:git_base_uri].freeze
         | 
| 58 | 
            -
                GITLAB_API_ENDPOINT = config[:gitlab_api_endpoint].freeze
         | 
| 59 | 
            -
                ACCESS_TOKEN = case GIT_PLATFORM
         | 
| 60 | 
            -
                               when :github
         | 
| 61 | 
            -
                                 ENV['GITHUB_TOKEN'].freeze
         | 
| 62 | 
            -
                               when :gitlab
         | 
| 63 | 
            -
                                 ENV['GITLAB_TOKEN'].freeze
         | 
| 64 | 
            -
                               end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                # Sanity checks
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                unless supported_git_platforms.include?(GIT_PLATFORM)
         | 
| 69 | 
            -
                  raise "Unsupported Git hosting platform '#{GIT_PLATFORM}'."\
         | 
| 70 | 
            -
                    " Supported platforms are: #{supported_git_platforms.join(', ')}"
         | 
| 71 | 
            -
                end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                if ACCESS_TOKEN.nil?
         | 
| 74 | 
            -
                  raise "Git platform access token for #{GIT_PLATFORM.capitalize} not set"\
         | 
| 75 | 
            -
                    " - use 'export #{GIT_PLATFORM.upcase}_TOKEN=\"<your token>\"' to set"
         | 
| 76 | 
            -
                end
         | 
| 77 | 
            -
              end
         | 
| 78 | 
            -
            end
         | 
    
        data/spec/lib/pdksync_spec.rb
    DELETED
    
    | @@ -1,58 +0,0 @@ | |
| 1 | 
            -
            require_relative '../../lib/pdksync'
         | 
| 2 | 
            -
            require 'git'
         | 
| 3 | 
            -
            require 'fileutils'
         | 
| 4 | 
            -
            require 'octokit'
         | 
| 5 | 
            -
             | 
| 6 | 
            -
            describe PdkSync do
         | 
| 7 | 
            -
              before(:all) do
         | 
| 8 | 
            -
                @pdksync_dir = './modules_pdksync'
         | 
| 9 | 
            -
                module_name = 'puppetlabs-testing'
         | 
| 10 | 
            -
                @module_names = ['puppetlabs-testing']
         | 
| 11 | 
            -
                @output_path = "#{@pdksync_dir}/#{module_name}"
         | 
| 12 | 
            -
                @folder = Dir.pwd
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              before(:each) do
         | 
| 16 | 
            -
                allow(PdkSync).to receive(:return_modules).and_return(@module_names)
         | 
| 17 | 
            -
                allow(PdkSync).to receive(:validate_modules_exist).and_return(@module_names)
         | 
| 18 | 
            -
                Dir.chdir(@folder)
         | 
| 19 | 
            -
              end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
              context 'main method' do
         | 
| 22 | 
            -
                it 'runs clone sucessfully' do
         | 
| 23 | 
            -
                  FileUtils.rm_rf(@pdksync_dir)
         | 
| 24 | 
            -
                  PdkSync.create_filespace
         | 
| 25 | 
            -
                  PdkSync.main(steps: [:clone])
         | 
| 26 | 
            -
                  expect(Dir.exist?(@pdksync_dir)).to be(true)
         | 
| 27 | 
            -
                  expect(Dir.exist?(@output_path)).to be(true)
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
                it 'runs pdk convert, and files have changed' do
         | 
| 30 | 
            -
                  PdkSync.main(steps: [:pdk_convert])
         | 
| 31 | 
            -
                  File.exist?("#{@output_path}/convert_report.txt")
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
                it 'raise when running a command with no argument' do
         | 
| 34 | 
            -
                  expect { PdkSync.main(steps: [:run_a_command]) }.to raise_error(RuntimeError, %r{"run_a_command" requires an argument to run.})
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
                it 'runs a command "touch cat.meow"' do
         | 
| 37 | 
            -
                  PdkSync.main(steps: [:run_a_command], args: 'touch cat.meow')
         | 
| 38 | 
            -
                  expect File.exist?("#{@output_path}/cat.meow")
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
                it 'raise when create_commit with no arguments' do
         | 
| 41 | 
            -
                  expect { PdkSync.main(steps: [:create_commit]) }.to raise_error(RuntimeError, %r{Needs a branch_name and commit_message})
         | 
| 42 | 
            -
                end
         | 
| 43 | 
            -
                it 'create_commit runs, and contains the "kittens in mittens"' do
         | 
| 44 | 
            -
                  PdkSync.main(steps: [:create_commit], args: { branch_name: 'temp_branch', commit_message: 'kittens in mittens' })
         | 
| 45 | 
            -
                  git_repo = Git.open(@output_path)
         | 
| 46 | 
            -
                  expect(git_repo.show).to include('kittens in mittens')
         | 
| 47 | 
            -
                end
         | 
| 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 | 
            -
                end
         | 
| 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 | 
            -
                end
         | 
| 54 | 
            -
                it 'raise when clean_branches with no arguments' do
         | 
| 55 | 
            -
                  expect { PdkSync.main(steps: [:clean_branches]) }.to raise_error(RuntimeError, %r{Needs a branch_name, and the branch name contains the string pdksync})
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
            end
         |