<commit_before>$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'serverspec'
require 'cfer'
require 'cfer/provisioning'

set :backend, :ssh

ssh_options = {:user => 'ubuntu'}
ssh_options.merge! keys: [ ENV['CI_SSH_KEY'] ] if ENV['CI_SSH_KEY']
set :ssh_options, ssh_options

VPC_STACK_NAME = 'cfer-provisioning-vpc'

KEEP_STACK = ENV['KEEP_STACK']

def with_stack(caller_self, stack_name, file_name, parameters = {})
  stack_name =
    if KEEP_STACK
      "cfer-provisioning-#{stack_name}"
    else
      "cfer-provisioning-#{stack_name}-#{SecureRandom.uuid}"
    end

  caller_self.before(:all) do
    puts "Converging #{stack_name}"
    Cfer.converge! stack_name, template: file_name,
      follow: true, number: 0, backoff: 2, backoff_max_wait: 60,
      parameter_file: ENV['CI_PARAMETERS_YAML'] || 'parameters.yaml',
      parameters: parameters
    set :host, Cfer::Cfn::Client.new(stack_name: stack_name).fetch_outputs[:IpAddress]
  end

  caller_self.after(:all) do
    unless KEEP_STACK
      puts "Deleting #{stack_name}"
      Cfer.delete! stack_name
    end
  end
end

RSpec.configure do |config|
  config.before(:suite) do
    puts "Converging VPC"
    Cfer.converge! VPC_STACK_NAME,
      template: 'spec/stacks/vpc.rb',
      follow: true, number: 0, backoff: 2, backoff_max_wait: 60,
      parameter_file: ENV['CI_PARAMETERS_YAML'] || 'parameters.yaml'
  end

  config.after(:suite) do
    Cfer.delete! VPC_STACK_NAME, follow: true, number: 0 unless KEEP_STACK
  end
end
<commit_msg>Always keep the VPC stack<commit_after>$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'serverspec'
require 'cfer'
require 'cfer/provisioning'

set :backend, :ssh

ssh_options = {:user => 'ubuntu'}
ssh_options.merge! keys: [ ENV['CI_SSH_KEY'] ] if ENV['CI_SSH_KEY']
set :ssh_options, ssh_options

VPC_STACK_NAME = 'cfer-provisioning-vpc'

KEEP_STACK = ENV['KEEP_STACK']

def with_stack(caller_self, stack_name, file_name, parameters = {})
  stack_name =
    if KEEP_STACK
      "cfer-provisioning-#{stack_name}"
    else
      "cfer-provisioning-#{stack_name}-#{SecureRandom.uuid}"
    end

  caller_self.before(:all) do
    puts "Converging #{stack_name}"
    Cfer.converge! stack_name, template: file_name,
      follow: true, number: 0, backoff: 2, backoff_max_wait: 60,
      parameter_file: ENV['CI_PARAMETERS_YAML'] || 'parameters.yaml',
      parameters: parameters
    set :host, Cfer::Cfn::Client.new(stack_name: stack_name).fetch_outputs[:IpAddress]
  end

  caller_self.after(:all) do
    unless KEEP_STACK
      puts "Deleting #{stack_name}"
      Cfer.delete! stack_name
    end
  end
end

RSpec.configure do |config|
  config.before(:suite) do
    puts "Converging VPC"
    Cfer.converge! VPC_STACK_NAME,
      template: 'spec/stacks/vpc.rb',
      follow: true, number: 0, backoff: 2, backoff_max_wait: 60,
      parameter_file: ENV['CI_PARAMETERS_YAML'] || 'parameters.yaml'
  end
end

{'fraction_non_alphanumeric': 0.1287465940054496, 'fraction_numerical': 0.0057901907356948225, 'mean_word_length': 4.216696269982238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3175727', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1107, 'n_words': 221}