diff --git a/rake/rake_tasks.rb b/rake/rake_tasks.rb deleted file mode 100644 index 9c8cddc..0000000 --- a/rake/rake_tasks.rb +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################# -# Some module specific rake tasks. -############################################################################# -require 'fileutils' -require_relative 'tasks/deploy' - -desc '[CI Only] Run beaker, but only for pull requests or for release branches.' -task :acceptance do - travis_pull_request = ENV['TRAVIS_PULL_REQUEST'] - - if travis_pull_request.nil? || (travis_pull_request == 'false') - puts 'Skipping acceptance tests.' - exit(0) - else - Rake::Task['beaker'].invoke - end -end - -desc '[CI Only] Tag, build and push the module to PuppetForge.' -task :deploy do - abort('Only deploy from master.') unless ENV['CIRCLE_BRANCH'] == 'master' - - # Find out what the local version of the module is. - file = File.read('metadata.json') - data_hash = JSON.parse(file) - local_version = data_hash['version'] - abort('Unable to find local module version.') unless local_version - puts "Module version (local): #{local_version}" - - Rake::Task['deploy:tag'].invoke(local_version) - Rake::Task['deploy:forge'].invoke(local_version) -end - -desc 'Run metadata_lint, rubocop, lint, validate and spec.' -task test: %i[ - metadata_lint - rubocop - lint - validate - spec -] - -desc 'Clean up after a vagrant run.' -task :vagrant_clean do - module_root = File.expand_path(File.join(__FILE__, '..', '..')) - directory = File.expand_path(File.join(module_root, 'vagrant', 'modules')) - FileUtils.rm_r directory if File.directory?(directory) -end diff --git a/rake/tasks/deploy.rb b/rake/tasks/deploy.rb deleted file mode 100644 index ac1c7e0..0000000 --- a/rake/tasks/deploy.rb +++ /dev/null @@ -1,2 +0,0 @@ -require_relative 'deploy/forge' -require_relative 'deploy/tag' diff --git a/rake/tasks/deploy/forge.rb b/rake/tasks/deploy/forge.rb deleted file mode 100644 index e436fd3..0000000 --- a/rake/tasks/deploy/forge.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'httparty' -require 'json' -require 'yaml' - -namespace :deploy do - desc 'Deploy module to Puppet Forge if required.' - task :forge, [:version] do |_t, args| - local_version = args[:version] - - # Find out what the forge version of the module is. - response = HTTParty.get('https://forgeapi.puppetlabs.com/v3/modules/locp-cassandra') - data_hash = JSON.parse(response.body) - forge_version = data_hash['current_release']['version'] - abort('Unable to find out the forge version.') unless forge_version - puts "Module version (forge): #{forge_version}" - exit 0 unless local_version != forge_version - - # Build the module. - puts "Build and deploy version #{local_version}." - Rake::Task['module:clean'].invoke - Rake::Task['build'].invoke - - # Now see if we can push this baby to the forge. - PUPPET_FORGE_CREDENTIALS_FILE = ENV['HOME'] + '/' + '.puppetforge.yml' - username = ENV['CIRCLE_PROJECT_USERNAME'] - password = ENV['PUPPET_FORGE_PASSWORD'] - abort("Not enough data to populate #{PUPPET_FORGE_CREDENTIALS_FILE}") unless username && password - puts "Populating #{PUPPET_FORGE_CREDENTIALS_FILE}" - credentials = { 'username' => username, 'password' => password } - File.open(PUPPET_FORGE_CREDENTIALS_FILE, 'w') { |f| f.write credentials.to_yaml } - Rake::Task['module:push'].invoke - end -end diff --git a/rake/tasks/deploy/tag.rb b/rake/tasks/deploy/tag.rb deleted file mode 100644 index 7c48fcc..0000000 --- a/rake/tasks/deploy/tag.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'git' - -namespace :deploy do - desc 'Deploy tag for the module' - task :tag, [:version] do |_t, args| - tagname = args[:version] - # Find out if a tag is available for this version. - log = Logger.new(STDOUT) - log.level = Logger::WARN - git = Git.open('.', log: log) - - begin - git.tag(tagname) - rescue Git::GitTagNameDoesNotExist - puts "Creating tag: #{tagname}" - git.add_tag(tagname, 'master', message: 'tagged by RubyAutoDeployTest', f: true) - git.push('origin', "refs/tags/#{tagname}", f: true) - else - puts "Tag: #{tagname} already exists." - end - end -end