Sha256: 08cc47067815842a456af34f8eff0d4a64dc994bdd018b2f0b6ed8f15f4e94cc

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'byebug'

namespace :ci do
  namespace :prepare do
    namespace :workflows do
      desc 'Prepare workflow with matrix of adventures'
      task 'adventures' do |task|
        # cases = Roro::Configurators::Reflector.new.cases
        set_content(task)
        matrix = @content['jobs'][0]['test-adventures']['matrix']
        matrix['parameters']['answers'] = ci_cases
        overwrite
        notify('answers')
      end
    end

    def set_content(task)
      wf = "#{Dir.pwd}/.circleci/src/workflows/#{task.name.split(':').last}"
      @dest = "#{wf}.yml"
      @content = JSON.parse(YAML.load_file("#{wf}.yml.tt").to_json)
    end

    def overwrite
      File.open(@dest, 'w') { |f| f.write(@content.to_yaml) }
    end

    def notify(string)
      puts "Wrote #{string} to #{@dest}"
    end

    def ci_cases
      [
        '1 1 1',
        '1 1 1',
        '1 1 2',
        '1 2 1 1 1',
        '1 2 1 1 2',
        '1 2 1 2 1',
        '1 2 1 2 2',
        '1 2 2 1',
        '1 2 2 2',
        '1 3 1 1 1 1 1 1',
        '1 3 1 1 1 1 1 2',
        '1 3 1 1 1 1 2 1',
        '1 3 1 1 1 1 2 2',
        '1 3 1 1 1 2 1 1',
        '1 3 1 1 1 2 1 2',
        '1 3 1 1 1 2 2 1',
        '1 3 1 1 1 2 2 2',
        '1 3 1 1 2 1 1 1',
        '1 3 1 1 2 1 1 2',
        '1 3 1 2 1 1 1',
        '1 3 1 2 1 1 2',
        '1 3 1 2 1 2 1',
        '1 3 1 2 1 2 2',
        '1 3 2 1',
        '1 3 2 2',
        '2 1',
        '2 2',
        '3 1',
        '3 2'
      ].map { |item| item.split(' ').join('\n') }
    end

    def ci_cases
      cases = Roro::Configurators::Reflector.new.cases
      cases.map { |c| c.join('\\n') }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roro-0.3.33 rakelib/ci/prepare/workflows/adventures.rake