firespring_dev_commands 2.1.33.pre.alpha.1 → 2.5.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/firespring_dev_commands/audit/report.rb +2 -9
- data/lib/firespring_dev_commands/aws/cloudformation.rb +3 -10
- data/lib/firespring_dev_commands/common.rb +2 -22
- data/lib/firespring_dev_commands/docker/status.rb +0 -20
- data/lib/firespring_dev_commands/docker.rb +16 -86
- data/lib/firespring_dev_commands/eol.rb +2 -12
- data/lib/firespring_dev_commands/git.rb +22 -17
- data/lib/firespring_dev_commands/jira/issue.rb +1 -3
- data/lib/firespring_dev_commands/node.rb +1 -1
- data/lib/firespring_dev_commands/php.rb +12 -28
- data/lib/firespring_dev_commands/platform.rb +31 -38
- data/lib/firespring_dev_commands/ruby.rb +3 -6
- data/lib/firespring_dev_commands/target_process/query.rb +4 -30
- data/lib/firespring_dev_commands/target_process.rb +1 -3
- data/lib/firespring_dev_commands/templates/aws.rb +6 -14
- data/lib/firespring_dev_commands/templates/docker/application.rb +2 -2
- data/lib/firespring_dev_commands/templates/docker/node/application.rb +5 -28
- data/lib/firespring_dev_commands/templates/docker/php/application.rb +16 -31
- data/lib/firespring_dev_commands/templates/docker/ruby/application.rb +5 -27
- data/lib/firespring_dev_commands/templates/eol.rb +2 -3
- data/lib/firespring_dev_commands/templates/git.rb +0 -17
- data/lib/firespring_dev_commands/version.rb +1 -1
- data/lib/firespring_dev_commands.rb +1 -1
- metadata +35 -48
- data/lib/firespring_dev_commands/bloom_growth/rock.rb +0 -34
- data/lib/firespring_dev_commands/bloom_growth/seat.rb +0 -16
- data/lib/firespring_dev_commands/bloom_growth/user.rb +0 -43
- data/lib/firespring_dev_commands/bloom_growth.rb +0 -132
- data/lib/firespring_dev_commands/certificate.rb +0 -59
- data/lib/firespring_dev_commands/coverage/base.rb +0 -16
- data/lib/firespring_dev_commands/coverage/cobertura.rb +0 -86
- data/lib/firespring_dev_commands/coverage/none.rb +0 -21
- data/lib/firespring_dev_commands/docker/desktop.rb +0 -59
- data/lib/firespring_dev_commands/jira/parent.rb +0 -19
- data/lib/firespring_dev_commands/os.rb +0 -35
- data/lib/firespring_dev_commands/port.rb +0 -24
- data/lib/firespring_dev_commands/templates/certificate.rb +0 -41
@@ -1,86 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
# Module containing different classes for interfacing with coverage files
|
3
|
-
module Coverage
|
4
|
-
# Class for checking code coverage using cobertura
|
5
|
-
class Cobertura < Base
|
6
|
-
attr_reader :local_filename, :container_filename, :filename, :threshold, :exclude
|
7
|
-
|
8
|
-
def initialize(filename: File.join('coverage', 'cobertura.xml'), threshold: nil, container_path: nil, local_path: nil, exclude: nil)
|
9
|
-
super()
|
10
|
-
|
11
|
-
@filename = filename
|
12
|
-
@local_filename = File.join(local_path || '.', @filename)
|
13
|
-
@container_filename = File.join(container_path || '.', @filename)
|
14
|
-
@threshold = threshold
|
15
|
-
@exclude = (exclude || []).map do |it|
|
16
|
-
next it if it.is_a?(Regex)
|
17
|
-
|
18
|
-
Regex.new(it)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Remove any previous versions of the local file that will be output
|
23
|
-
# return the phpunit options needed to regenerate the cobertura xml file
|
24
|
-
def php_options
|
25
|
-
# Remove any previous coverage info
|
26
|
-
FileUtils.rm_f(local_filename, verbose: true)
|
27
|
-
|
28
|
-
# Return the needed php commands to generate the cobertura report
|
29
|
-
%W(--coverage-cobertura #{container_filename})
|
30
|
-
end
|
31
|
-
|
32
|
-
# Parse the cobertura file and check the lines missed against the desired threshold
|
33
|
-
def check(application: nil)
|
34
|
-
# If an application has been specified and the file does not exist locally, attempt to copy it back from the docker container
|
35
|
-
if application && !File.exist?(local_filename)
|
36
|
-
container = Dev::Docker::Compose.new.container_by_name(application)
|
37
|
-
Dev::Docker.new.copy_from_container(container, container_filename, local_filename, required: true)
|
38
|
-
end
|
39
|
-
|
40
|
-
report = Ox.load(File.read(local_filename))
|
41
|
-
total_missed = report.coverage.locate('packages/package').sum { |package| parse_package_missed(package) }
|
42
|
-
puts "Lines missing coverage was #{total_missed}"
|
43
|
-
puts "Configured threshold was #{threshold}" if threshold
|
44
|
-
raise 'Code coverage not met' if threshold && total_missed > threshold
|
45
|
-
end
|
46
|
-
|
47
|
-
# Go through the package and add up all of the lines that were missed
|
48
|
-
# Ignore if the file was in the exlude list
|
49
|
-
private def parse_package_missed(package)
|
50
|
-
filename = package.attributes[:name]
|
51
|
-
return if exclude.any? { |it| it.match(filename) }
|
52
|
-
|
53
|
-
missed = 0
|
54
|
-
lines_processed = Set.new
|
55
|
-
package.locate('classes/class/lines/line').each do |line|
|
56
|
-
# Don't count lines multiple times
|
57
|
-
line_number = line.attributes[:number]
|
58
|
-
next if lines_processed.include?(line_number)
|
59
|
-
|
60
|
-
lines_processed << line_number
|
61
|
-
missed += 1 unless line.attributes[:hits].to_i.positive?
|
62
|
-
end
|
63
|
-
total = lines_processed.length
|
64
|
-
|
65
|
-
sanity_check_coverage_against_cobertura_values(package, missed, total)
|
66
|
-
missed
|
67
|
-
end
|
68
|
-
|
69
|
-
# Calculate the coverage percent based off the numbers we got and compare to the
|
70
|
-
# value cobertura reported. This is meant as a sanity check that we are reading the data correctly
|
71
|
-
# TODO: This should be removed after the above logic has been vetted
|
72
|
-
private def sanity_check_coverage_against_cobertura_values(package, missed, total)
|
73
|
-
line_rate = package.attributes[:'line-rate']
|
74
|
-
cobertura_reported_coverage = line_rate.to_f
|
75
|
-
cobertura_reported_precision = line_rate.split('.').last.length
|
76
|
-
|
77
|
-
file_coverage = 0.0
|
78
|
-
file_coverage = ((total - missed).to_f / total).round(cobertura_reported_precision) if total.positive?
|
79
|
-
return if file_coverage == cobertura_reported_coverage
|
80
|
-
|
81
|
-
filename = package.attributes[:name]
|
82
|
-
puts "WARNINNG: #{filename} coverage (#{file_coverage}) differed from what cobertura reported (#{cobertura_reported_coverage})"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
# Module with a variety of coverage methods for different languages
|
3
|
-
module Coverage
|
4
|
-
# Class which provides methods to effectvely skip coverage
|
5
|
-
class None < Base
|
6
|
-
def initialize(*)
|
7
|
-
super()
|
8
|
-
end
|
9
|
-
|
10
|
-
# Returns the php options for generating code coverage file
|
11
|
-
def php_options
|
12
|
-
[]
|
13
|
-
end
|
14
|
-
|
15
|
-
# Checks the code coverage against the defined threshold
|
16
|
-
def check(*)
|
17
|
-
puts 'Coverage not configured'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
class Docker
|
3
|
-
# Class for configuring docker desktop
|
4
|
-
# This is mostly around configuring the docker URL correctly
|
5
|
-
class Desktop
|
6
|
-
# A snippet of a docker compose file which forwards a socket to a local port so that we can read it in the docker library
|
7
|
-
WIN_TCP_COMPOSE_CONTENT = "
|
8
|
-
---
|
9
|
-
version: '3.8'
|
10
|
-
services:
|
11
|
-
windows_tcp:
|
12
|
-
image: alpine/socat
|
13
|
-
network_mode: bridge
|
14
|
-
ports:
|
15
|
-
- 127.0.0.1:23750:2375
|
16
|
-
volumes:
|
17
|
-
- /var/run/docker.sock:/var/run/docker.sock
|
18
|
-
command: tcp-listen:2375,reuseaddr,fork unix-connect:/var/run/docker.sock
|
19
|
-
restart: always".freeze
|
20
|
-
|
21
|
-
# Set up the local ports/sockets correctly based off of the os type
|
22
|
-
def configure
|
23
|
-
if Dev::Os.new.windows?
|
24
|
-
# Start up a small proxy container if running Docker Desktop on windows
|
25
|
-
# This is needed because the docker api library cannot connect to the windows socket
|
26
|
-
unless Dev::Port.new('127.0.0.1', 23_750).open?
|
27
|
-
LOG.info('Starting local proxy port for docker')
|
28
|
-
|
29
|
-
# Write the compose data to a tmp file
|
30
|
-
tmp_compose_file = Tempfile.new('windows_tcp')
|
31
|
-
tmp_compose_file.write(WIN_TCP_COMPOSE_CONTENT)
|
32
|
-
tmp_compose_file.close
|
33
|
-
|
34
|
-
# Start up the container
|
35
|
-
Dev::Docker::Compose.new(
|
36
|
-
compose_files: tmp_compose_file.path,
|
37
|
-
options: ['--detach'],
|
38
|
-
project_name: 'proxy'
|
39
|
-
).up
|
40
|
-
|
41
|
-
# Wait 1 second before we continue
|
42
|
-
sleep 1
|
43
|
-
end
|
44
|
-
|
45
|
-
# Configure the docker url to use 23750 on windows
|
46
|
-
::Docker.url = 'tcp://127.0.0.1:23750'
|
47
|
-
|
48
|
-
else
|
49
|
-
# If a user based socket has been defined, default to that
|
50
|
-
::Docker.url = if File.exist?("/#{Dir.home}/.docker/run/docker.sock")
|
51
|
-
"unix://#{Dir.home}/.docker/run/docker.sock"
|
52
|
-
elsif File.exist?("/#{Dir.home}/.docker/desktop/docker.sock")
|
53
|
-
"unix://#{Dir.home}/.docker/desktop/docker.sock"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
class Jira
|
3
|
-
# Contains information on the Jira parent issue
|
4
|
-
class Parent
|
5
|
-
attr_accessor :data, :id, :title
|
6
|
-
|
7
|
-
def initialize(data)
|
8
|
-
@data = data.parent
|
9
|
-
@id = data.parent['key']
|
10
|
-
@title = data.parent['fields']['summary']
|
11
|
-
end
|
12
|
-
|
13
|
-
# Converts the jira parent object to a string representation
|
14
|
-
def to_s
|
15
|
-
"[#{id}] #{title}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
# Class containing methods for determining operating system information
|
3
|
-
class Os
|
4
|
-
attr_accessor :os
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@os = ::RbConfig::CONFIG['host_os']
|
8
|
-
end
|
9
|
-
|
10
|
-
# Returns true if the host_os contains windowsy text
|
11
|
-
def windows?
|
12
|
-
os.match?(/(mingw|mswin|windows)/i)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns true if the host_os contains darwinsy text
|
16
|
-
def darwin?
|
17
|
-
os.match?(/(darwin|mac os)/i)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns true if the host_os contains macsy text
|
21
|
-
def mac?
|
22
|
-
darwin?
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns true if the host_os contains nixy text
|
26
|
-
def nix?
|
27
|
-
os.match?(/(linux|bsd|aix|solaris)/i)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Returns true if the host_os contains cygwiny text
|
31
|
-
def cygwin?
|
32
|
-
os.match?(/(cygwin)/i)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
# Class containing methods for actions to be taken on ports
|
3
|
-
class Port
|
4
|
-
attr_accessor :ip_address, :port
|
5
|
-
|
6
|
-
def initialize(ip_address, port)
|
7
|
-
@ip_address = ip_address
|
8
|
-
@port = port
|
9
|
-
end
|
10
|
-
|
11
|
-
# Returns true if the port is open
|
12
|
-
# Returns false otherwise
|
13
|
-
def open?(timeout = 1)
|
14
|
-
Timeout.timeout(timeout) do
|
15
|
-
TCPSocket.new(ip_address, port).close
|
16
|
-
return true
|
17
|
-
end
|
18
|
-
|
19
|
-
false
|
20
|
-
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
21
|
-
false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require_relative 'base_interface'
|
2
|
-
|
3
|
-
module Dev
|
4
|
-
module Template
|
5
|
-
# Class contains rake templates for managing configured certificates
|
6
|
-
class Certificate < Dev::Template::BaseInterface
|
7
|
-
attr_reader :domains, :email, :paths
|
8
|
-
|
9
|
-
def initialize(domains, email:, paths:, exclude: [])
|
10
|
-
@domains = domains
|
11
|
-
@email = email
|
12
|
-
@paths = Array(paths)
|
13
|
-
|
14
|
-
super(exclude:)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Create the rake task for the generate method
|
18
|
-
def create_generate_task!
|
19
|
-
# Have to set a local variable to be accessible inside of the instance_eval block
|
20
|
-
domains = @domains
|
21
|
-
email = @email
|
22
|
-
paths = @paths
|
23
|
-
exclude = @exclude
|
24
|
-
|
25
|
-
DEV_COMMANDS_TOP_LEVEL.instance_eval do
|
26
|
-
return if exclude.include?(:generate)
|
27
|
-
|
28
|
-
namespace :certificate do
|
29
|
-
desc 'Requests a new certificate for the configured domain using the route53 validation and deposits it in the configured paths'
|
30
|
-
task generate: %w(init_docker ensure_aws_credentials) do
|
31
|
-
Dev::Docker.new.pull_image('certbot/dns-route53', 'latest')
|
32
|
-
c = Dev::Certificate.new(domains, email)
|
33
|
-
c.request
|
34
|
-
paths.each { |path| c.save(path) }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|