-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
118 lines (100 loc) · 2.7 KB
/
Rakefile
File metadata and controls
118 lines (100 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# frozen_string_literal: true
require 'rake/testtask'
require 'getclonedata'
task :default do
puts `rake -T`
end
Rake::TestTask.new(:spec) do |t|
t.pattern = 'spec/*_spec.rb'
t.warning = false
end
namespace :run do
task :dev do
sh 'rerun "rackup -p 9292"'
end
task :test do
loop do
puts 'Setting up test environment'
ENV['RACK_ENV'] = 'test'
Rake::Task['db:_setup'].execute
Rake::Task['db:reset'].execute
puts 'Populating test database'
LoadDeveloper.call(username: 'rjollet', channel_id: 'Loaddevtest'.hash)
sh 'rerun "rackup -p 3000"'
end
end
end
namespace :db do
task :_setup do
require 'sequel'
require_relative 'init'
Sequel.extension :migration
end
desc 'Run database migrations'
task migrate: [:_setup] do
puts "Migrating to latest for: #{ENV['RACK_ENV'] || 'development'}"
Sequel::Migrator.run(DB, 'db/migrations')
end
desc 'Reset migrations (full rollback and migration)'
task reset: [:_setup] do
Sequel::Migrator.run(DB, 'db/migrations', target: 0)
Sequel::Migrator.run(DB, 'db/migrations')
end
desc 'Print out final schema to file'
task schema: [:_setup] do
DB.extension :schema_dumper
File.open('db/schema.rb', 'w') do |file|
header = <<~END
# This schema file is automativally generated by `rake db:schema.
# It will be overwritten peridodically so do not make changes.
END
puts 'Writing schema to db/schema.rb'
file.write(header)
file.write(DB.dump_schema_migration)
end
end
end
desc 'delete files or folders in casset or cloned repositories'
namespace :wipe do
desc 'wipe cassettes'
task :cassettes do
sh 'rm spec/fixtures/cassettes/*.yml' do |ok, _|
puts(ok ? 'Cassettes deleted' : 'No casseettes found')
end
end
desc "wipe clones repositories"
task :repos do
GetCloneData::ClonedRepo.wipe
end
end
namespace :quality do
CODE = 'app.rb'
desc 'run all quality checks'
task all: [:spec, :rubocop, :flog, :flay]
task :flog do
sh 'flog ./'
end
task :flay do
sh 'flay'
end
task :rubocop do
sh 'rubocop'
end
end
namespace :queue do
require 'aws-sdk'
require_relative 'init'
desc 'Create SQS queue for Shoryuken'
task :create do
config = DevRankAPI.config
sqs = Aws::SQS::Client.new(access_key_id: config.AWS_ACCESS_KEY_ID,
secret_access_key: config.AWS_SECRET_ACCESS_KEY,
region: config.AWS_REGION)
begin
queue = sqs.create_queue(queue_name: config.QUALITY_QUEUE)
puts "Queue #{config.QUALITY_QUEUE} created on #{config.AWS_REGION}"
rescue => e
puts "Error creating queue: #{e}"
end
end
end