firespring_dev_commands 2.1.24.pre.alpha.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb2cf1870dd2e6e30d0dbd360bee8827c3bf8f748051a1692411e1a3d3324e71
4
- data.tar.gz: d71152d34719d590445f2265d955faecfc502cb4864411a54fa4c26d2038b666
3
+ metadata.gz: e146e8c9d9c3422dfd7641c6a09ca8c2cdfad6ed430d73aec5808de28ed5d880
4
+ data.tar.gz: 273923aae5ccce231fc77174ed89cbe0e4f5ad59b52219b04303f983e9966e1d
5
5
  SHA512:
6
- metadata.gz: 5040fae63fb2071356d149f22128aedd0fc4bed611431e1254d0eeff1f3b59b4d7656a1be78d502c5bd0a329c095cff050878f42722aac15d1d376b005313096
7
- data.tar.gz: ed7695707e6d7fd6dfb7e8962a7001500fd2e62dc8844761ec2cc267e5fedcc023a20d61805fbf650dbd9bdeaed10578d5eb8b43f7a7c04d46c0086430d31b9d
6
+ metadata.gz: 67223e6ba12a10f798d7fee6b1cab844da41cd3dc65a449330e8c8bd0ef86180cc297889b7365b7b68f5ca8054919e9881693707ecfde02e539d0a7e22c6af51
7
+ data.tar.gz: ada0e13a3f2d8022687a2542503bad6bc847bf32fc17604116d17e06ed46ee7efa18aea35635c31a26c07f5ccdd6a3c5083235edaafd77684528bc487c17f3c7
@@ -3,12 +3,11 @@ module Dev
3
3
  class Audit
4
4
  # The class containing standardized information about an audit report
5
5
  class Report
6
- attr_accessor :items, :min_severity, :error_on_unknown, :ignorelist, :filtered_items
6
+ attr_accessor :items, :min_severity, :ignorelist, :filtered_items
7
7
 
8
8
  def initialize(
9
9
  items,
10
10
  min_severity: ENV.fetch('MIN_SEVERITY', nil),
11
- error_on_unknown: ENV.fetch('ERROR_ON_UNKNOWN', nil),
12
11
  ignorelist: ENV['IGNORELIST'].to_s.split(/\s*,\s*/)
13
12
  )
14
13
  # Items should be an array of Item objects
@@ -16,18 +15,12 @@ module Dev
16
15
  raise 'items must all be report items' unless @items.all?(Dev::Audit::Report::Item)
17
16
 
18
17
  @min_severity = min_severity || Level::HIGH
19
- @error_on_unknown = error_on_unknown
20
18
  @ignorelist = Array(ignorelist).compact
21
19
  end
22
20
 
23
21
  # Get all severities greater than or equal to the minimum severity
24
22
  def desired_severities
25
- max_severity = if error_on_unknown.to_s.strip == 'true'
26
- -1
27
- else
28
- -2
29
- end
30
- LEVELS.slice(LEVELS.find_index(min_severity)..max_severity)
23
+ LEVELS.slice(LEVELS.find_index(min_severity)..-1)
31
24
  end
32
25
 
33
26
  # Run the filters against the report items and filter out any which should be excluded
@@ -138,14 +138,8 @@ module Dev
138
138
  Docker::Compose.new.mapped_public_port(name, private_port)
139
139
  end
140
140
 
141
- # Gets the default working dir of the container
142
- def working_dir(container)
143
- container.json['Config']['WorkingDir']
144
- end
145
-
146
141
  # Copies the source path on your local machine to the destination path on the container
147
142
  def copy_to_container(container, source_path, dest_path)
148
- dest_path = File.join(working_dir(container), dest_path) unless dest_path.start_with?(File::SEPARATOR)
149
143
  LOG.info "Copying #{source_path} to #{dest_path}... "
150
144
 
151
145
  container.archive_in(source_path, dest_path, overwrite: true)
@@ -160,7 +154,6 @@ module Dev
160
154
  # Copies the source path on the container to the destination path on your local machine
161
155
  # If required is set to true, the command will fail if the source path does not exist on the container
162
156
  def copy_from_container(container, source_path, dest_path, required: true)
163
- source_path = File.join(working_dir(container), source_path) unless source_path.start_with?(File::SEPARATOR)
164
157
  LOG.info "Copying #{source_path} to #{dest_path}... "
165
158
 
166
159
  tar = StringIO.new
@@ -5,9 +5,8 @@ module Dev
5
5
  END_OF_LIFE_API_URL = 'https://endoflife.date/api'.freeze
6
6
 
7
7
  # Config object for setting top level git config options
8
- Config = Struct.new(:check_aws_resources, :product_versions, :manual_dates) do
8
+ Config = Struct.new(:product_versions, :manual_dates) do
9
9
  def initialize
10
- self.check_aws_resources = false
11
10
  self.product_versions = []
12
11
  self.manual_dates = {}
13
12
  end
@@ -27,10 +26,9 @@ module Dev
27
26
  alias_method :configure, :config
28
27
  end
29
28
 
30
- attr_accessor :url, :products, :check_aws_resources, :product_versions
29
+ attr_accessor :url, :products, :product_versions
31
30
 
32
- def initialize(check_aws_resources: self.class.config.check_aws_resources, product_versions: self.class.config.product_versions)
33
- @check_aws_resources = check_aws_resources
31
+ def initialize(product_versions: self.class.config.product_versions)
34
32
  @product_versions = Array(product_versions)
35
33
  raise 'product version must be of type Dev::EndOfLife::ProductVersions' unless @product_versions.all?(Dev::EndOfLife::ProductVersion)
36
34
  end
@@ -52,14 +50,7 @@ module Dev
52
50
  # Raises an error if any products are EOL
53
51
  def check
54
52
  puts
55
- checks_to_perform = product_versions.clone
56
- if check_aws_resources
57
- account_id = Dev::Aws::Profile.new.current
58
- account_name = Dev::Aws::Account.new.name_by_account(account_id)
59
- LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
60
- checks_to_perform.concat(Dev::EndOfLife::Aws.new.default_products)
61
- end
62
- checks_to_perform.sort_by(&:name).each(&:print_status)
53
+ product_versions.sort_by(&:name).each(&:print_status)
63
54
  puts
64
55
  raise 'found EOL versions' if product_versions.any?(&:eol)
65
56
  end
@@ -96,7 +96,7 @@ module Dev
96
96
  test
97
97
  end
98
98
 
99
- # Build the node test command
99
+ # Build the node test (with coverage) command
100
100
  def test_coverage_command
101
101
  test = base_command
102
102
  test << 'run' << 'test:coverage'
@@ -8,12 +8,11 @@ module Dev
8
8
  DEFAULT_PACKAGE_FILE = 'composer.json'.freeze
9
9
 
10
10
  # Config object for setting top level git config options
11
- Config = Struct.new(:container_path, :local_path, :package_file, :coverage) do
11
+ Config = Struct.new(:container_path, :local_path, :package_file) do
12
12
  def initialize
13
13
  self.container_path = DEFAULT_PATH
14
14
  self.local_path = DEV_COMMANDS_ROOT_DIR
15
15
  self.package_file = DEFAULT_PACKAGE_FILE
16
- self.coverage = nil
17
16
  end
18
17
  end
19
18
 
@@ -31,14 +30,12 @@ module Dev
31
30
  alias_method :configure, :config
32
31
  end
33
32
 
34
- attr_accessor :container_path, :local_path, :package_file, :coverage
33
+ attr_accessor :container_path, :local_path, :package_file
35
34
 
36
- def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
35
+ def initialize(container_path: nil, local_path: nil, package_file: nil)
37
36
  @container_path = container_path || self.class.config.container_path
38
37
  @local_path = local_path || self.class.config.local_path
39
38
  @package_file = package_file || self.class.config.package_file
40
- @coverage = coverage || Dev::Coverage::None.new
41
- raise 'coverage must be an instance of the base class' unless @coverage.is_a?(Dev::Coverage::Base)
42
39
  end
43
40
 
44
41
  # The base npm command that is the starting point for all subsequent commands
@@ -61,12 +58,9 @@ module Dev
61
58
  end
62
59
 
63
60
  # Build the command to fix any security vulnerabilities that were found
64
- # def audit_fix_command
65
- # audit_fix = base_command
66
- # audit_fix << 'audit' << 'fix'
67
- # audit_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
68
- # audit_fix
69
- # end
61
+ def audit_fix_command
62
+ raise 'not implemented'
63
+ end
70
64
 
71
65
  # Build the php install command
72
66
  def install_command
@@ -79,7 +73,7 @@ module Dev
79
73
  # Build the php lint command
80
74
  def lint_command
81
75
  lint = base_command
82
- lint << 'lint'
76
+ lint << 'run' << 'lint'
83
77
  lint.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
84
78
  lint
85
79
  end
@@ -87,7 +81,7 @@ module Dev
87
81
  # Build the php lint fix command
88
82
  def lint_fix_command
89
83
  lint_fix = base_command
90
- lint_fix << 'lint-fix'
84
+ lint_fix << 'run' << 'lint-fix'
91
85
  lint_fix.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
92
86
  lint_fix
93
87
  end
@@ -95,24 +89,14 @@ module Dev
95
89
  # Build the php test command
96
90
  def test_command
97
91
  test = []
98
- test << './vendor/bin/phpunit'
99
- test.concat(coverage.php_options) if coverage
92
+ lint_fix << 'run' << 'test'
100
93
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
101
94
  test
102
95
  end
103
96
 
104
- # Run the check to ensure code coverage meets the desired threshold
105
- def check_test_coverage(application:)
106
- coverage.check(application:)
107
- end
108
-
109
- # Build the php fast test command
110
- def test_fast_command(processes = 4)
111
- test = []
112
- test << './vendor/bin/paratest'
113
- test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
114
- test << "-p#{processes}" << '--runner=WrapperRunner'
115
- test
97
+ # Build the php test (with coverage) command
98
+ def test_coverage_command
99
+ raise 'not implemented'
116
100
  end
117
101
  end
118
102
  end
@@ -8,7 +8,7 @@ module Dev
8
8
  # Normalize the ruby platform to return a docker platform architecture format
9
9
  def determine_compute_architecture
10
10
  case RUBY_PLATFORM
11
- when /x86_64|amd64|x64-mingw/
11
+ when /x86_64|amd64/
12
12
  'linux/amd64' # 64-bit Intel/AMD architecture
13
13
  when /arm|aarch64/
14
14
  'linux/arm64' # ARM architecture
@@ -2,13 +2,12 @@ module Dev
2
2
  class TargetProcess
3
3
  # Class for writing target process query statements
4
4
  class Query
5
- attr_accessor :where, :incl, :take, :empty
5
+ attr_accessor :where, :incl, :take
6
6
 
7
7
  def initialize
8
8
  @where = []
9
9
  @incl = []
10
10
  @take = 250
11
- @empty = false
12
11
  end
13
12
 
14
13
  # Add a new query clause
@@ -34,11 +33,6 @@ module Dev
34
33
  end
35
34
  end
36
35
 
37
- # Check if any of the "in" statements were empty. If so then we don't want to actually run the query
38
- def empty?
39
- @empty == true
40
- end
41
-
42
36
  # Generate the string representation for this query
43
37
  def generate
44
38
  {}.tap do |clause|
@@ -56,38 +50,22 @@ module Dev
56
50
  # TODO: Do these need moved to their associated entities?
57
51
  # Add a filter that looks for stories whose id is contained in the list of ids given
58
52
  def filter_by_user_story_ids(user_story_ids)
59
- if user_story_ids.nil? || user_story_ids.empty?
60
- @empty = true
61
- return
62
- end
63
53
  self << "(Id in ('#{user_story_ids.join("', '")}'))"
64
54
  end
65
55
 
66
56
  # Add a filter that looks for stories whose team id is contained in the list of ids given
67
57
  def filter_by_team_ids(team_ids)
68
- if team_ids.nil? || team_ids.empty?
69
- @empty = true
70
- return
71
- end
72
- self << "(Team.Id in ('#{team_ids.join("', '")}'))"
58
+ self << "(Team.Id in ('#{team_ids.join("', '")}'))" unless team_ids.nil? || team_ids.empty?
73
59
  end
74
60
 
75
61
  # Add a filter that looks for stories whose project id is contained in the list of ids given
76
62
  def filter_by_project(projects)
77
- if projects.nil? || projects.empty?
78
- @empty = true
79
- return
80
- end
81
63
  self << "(Project.Name in ('#{projects.join("', '")}'))"
82
64
  end
83
65
 
84
66
  # Add a filter that looks for stories whose state is contained in the list of states given
85
67
  def filter_by_states(states)
86
- if states.nil? || states.empty?
87
- @empty = true
88
- return
89
- end
90
- self << "(EntityState.Name in ('#{states.join("', '")}'))"
68
+ self << "(EntityState.Name in ('#{states.join("', '")}'))" unless states.nil? || states.empty?
91
69
  end
92
70
 
93
71
  # Add a filter that looks for stories whose state is set to final
@@ -136,11 +114,7 @@ module Dev
136
114
 
137
115
  # Add a filter that looks for assignable ids which are included in the given array
138
116
  def filter_by_entity_ids(entity_ids)
139
- if entity_ids.nil? || entity_ids.empty?
140
- @empty = true
141
- return
142
- end
143
- self << "(Assignable.Id in ('#{entity_ids.join("', '")}'))"
117
+ self << "(Assignable.Id in ('#{entity_ids.join("', '")}'))" unless entity_ids.nil? || entity_ids.empty?
144
118
  end
145
119
 
146
120
  # Add a filter that looks for a custom deploy date between the given dates`
@@ -15,7 +15,7 @@ module Dev
15
15
  # The text of the url variable key
16
16
  TP_URL = 'TP_URL'.freeze
17
17
 
18
- # Config object for setting top level target process config options
18
+ # Config object for setting top level jira config options
19
19
  Config = Struct.new(:username, :password, :url, :http_debug) do
20
20
  def initialize
21
21
  Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
@@ -117,8 +117,6 @@ module Dev
117
117
  # Call the given block (if present) with each piece of data
118
118
  # Return all pieces of data
119
119
  def get(path, query, &)
120
- return [] if query.empty?
121
-
122
120
  query_string = query.generate
123
121
  url = "/api/v1/#{path}"
124
122
  url << "?#{URI.encode_www_form(query_string)}" unless query_string.empty?
@@ -94,11 +94,23 @@ module Dev
94
94
  end
95
95
  # rubocop:enable Metrics/MethodLength
96
96
 
97
- # Set the EOL library to also check AWS resources
97
+ # Create the rake task for the eol method
98
98
  def create_eol_task!
99
- return if exclude.include?(:eol)
99
+ # Have to set a local variable to be accessible inside of the instance_eval block
100
+ exclude = @exclude
101
+
102
+ DEV_COMMANDS_TOP_LEVEL.instance_eval do
103
+ return if exclude.include?(:eol)
100
104
 
101
- Dev::EndOfLife.config { |c| c.check_aws_resources = true }
105
+ desc 'Compares the current date to the EOL date for supported resources'
106
+ task eol: %w(init ensure_aws_credentials) do
107
+ account_id = Dev::Aws::Profile.new.current
108
+ account_name = Dev::Aws::Account.new.name_by_account(account_id)
109
+ LOG.info " Current AWS Account is #{account_name} (#{account_id})".light_yellow
110
+
111
+ Dev::EndOfLife.new(product_versions: Dev::EndOfLife::Aws.new.default_products).check
112
+ end
113
+ end
102
114
  end
103
115
  end
104
116
  end
@@ -72,7 +72,7 @@ module Dev
72
72
  return if exclude.include?(:sh)
73
73
 
74
74
  desc "Open a shell into a running #{application} container"
75
- task sh: %W(init_docker #{application}:up_no_deps _pre_sh_hooks) do
75
+ task sh: %W(init_docker #{application}:up _pre_sh_hooks) do
76
76
  Dev::Docker::Compose.new(services: [application]).sh
77
77
  Rake::Task[:_post_sh_hooks].execute
78
78
  end
@@ -154,7 +154,7 @@ module Dev
154
154
  return if exclude.include?(:reload)
155
155
 
156
156
  desc "Reloads the #{application} container"
157
- task reload: %w(init_docker _pre_reload_hooks down up_no_deps) do
157
+ task reload: %w(init_docker _pre_reload_hooks down up) do
158
158
  Rake::Task[:_post_reload_hooks].execute
159
159
  end
160
160
  end
@@ -7,24 +7,11 @@ module Dev
7
7
  module Node
8
8
  # Class for default rake tasks associated with a node project
9
9
  class Application < Dev::Template::ApplicationInterface
10
- attr_reader :node, :start_container_dependencies_on_test
11
-
12
- # Create the templated rake tasks for the node application
13
- #
14
- # @param application [String] The name of the application
15
- # @param container_path [String] The path to the application inside of the container
16
- # @param local_path [String] The path to the application on your local system
17
- # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
- # @param exclude [Array<Symbol>] An array of default template tasks to exclude
19
- def initialize(
20
- application,
21
- container_path: nil,
22
- local_path: nil,
23
- start_container_dependencies_on_test: true,
24
- exclude: []
25
- )
10
+ attr_reader :node
11
+
12
+ # Allow for custom container path for the application
13
+ def initialize(application, container_path: nil, local_path: nil, exclude: [])
26
14
  @node = Dev::Node.new(container_path:, local_path:)
27
- @start_container_dependencies_on_test = start_container_dependencies_on_test
28
15
  super(application, exclude:)
29
16
  end
30
17
 
@@ -72,7 +59,6 @@ module Dev
72
59
  application = @name
73
60
  node = @node
74
61
  exclude = @exclude
75
- up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
76
62
  return if exclude.include?(:test)
77
63
 
78
64
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -84,7 +70,7 @@ module Dev
84
70
 
85
71
  namespace :node do
86
72
  desc "Run all node tests against the #{application}'s codebase"
87
- task test: %W(init_docker #{up_cmd}) do
73
+ task test: %w(init_docker up) do
88
74
  LOG.debug("Running all node tests in the #{application} codebase")
89
75
 
90
76
  options = []
@@ -1,4 +1,5 @@
1
1
  require_relative '../../base_interface'
2
+ require 'securerandom'
2
3
 
3
4
  module Dev
4
5
  module Template
@@ -7,24 +8,14 @@ module Dev
7
8
  module Php
8
9
  # Class for default rake tasks associated with a php project
9
10
  class Application < Dev::Template::ApplicationInterface
10
- attr_reader :php, :start_container_dependencies_on_test
11
-
12
- # Create the templated rake tasks for the php application
13
- #
14
- # @param application [String] The name of the application
15
- # @param container_path [String] The path to the application inside of the container
16
- # @param local_path [String] The path to the application on your local system
17
- # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
- def initialize(
19
- application,
20
- container_path: nil,
21
- local_path: nil,
22
- start_container_dependencies_on_test: true,
23
- coverage: nil,
24
- exclude: []
25
- )
26
- @php = Dev::Php.new(container_path:, local_path:, coverage:)
27
- @start_container_dependencies_on_test = start_container_dependencies_on_test
11
+ attr_reader :php, :siloed_tests
12
+
13
+ # Allow for custom container path for the application
14
+ def initialize(application, container_path: nil, local_path: nil, siloed_tests: nil, exclude: [])
15
+ @php = Dev::Php.new(container_path:, local_path:)
16
+ # TODO: Better name
17
+ # TODO: Should this apply to all or just tests?
18
+ @siloed_tests = siloed_tests
28
19
 
29
20
  super(application, exclude:)
30
21
  end
@@ -116,8 +107,8 @@ module Dev
116
107
  def create_test_task!
117
108
  application = @name
118
109
  php = @php
110
+ siloed_tests = @siloed_tests
119
111
  exclude = @exclude
120
- up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
121
112
  return if exclude.include?(:test)
122
113
 
123
114
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -129,13 +120,16 @@ module Dev
129
120
 
130
121
  namespace :php do
131
122
  desc "Run all php tests against the #{application}'s codebase"
132
- task test: %W(init_docker #{up_cmd}) do
123
+ task test: %w(init_docker up) do
133
124
  LOG.debug("Running all php tests in the #{application} codebase")
134
125
 
126
+ project_name = nil
127
+ project_name = SecureRandom.hex if siloed_tests
128
+
135
129
  options = []
136
130
  options << '-T' if Dev::Common.new.running_codebuild?
137
- Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
138
- php.check_test_coverage(application:)
131
+ Dev::Docker::Compose.new(project_name:, services: application, options:).exec(*php.test_command)
132
+ # TODO: Add clean if we are siloed
139
133
  end
140
134
  end
141
135
  end
@@ -7,23 +7,11 @@ module Dev
7
7
  module Ruby
8
8
  # Class for default rake tasks associated with a ruby project
9
9
  class Application < Dev::Template::ApplicationInterface
10
- attr_reader :ruby, :start_container_dependencies_on_test
11
-
12
- # Create the templated rake tasks for the ruby application
13
- #
14
- # @param application [String] The name of the application
15
- # @param container_path [String] The path to the application inside of the container
16
- # @param local_path [String] The path to the application on your local system
17
- # @param start_container_dependencies_on_test [Boolean] Whether or not to start up container dependencies when running tests
18
- def initialize(
19
- application,
20
- container_path: nil,
21
- local_path: nil,
22
- start_container_dependencies_on_test: true,
23
- exclude: []
24
- )
10
+ attr_reader :ruby
11
+
12
+ # Allow for custom container path for the application
13
+ def initialize(application, container_path: nil, local_path: nil, exclude: [])
25
14
  @ruby = Dev::Ruby.new(container_path:, local_path:)
26
- @start_container_dependencies_on_test = start_container_dependencies_on_test
27
15
  super(application, exclude:)
28
16
  end
29
17
 
@@ -71,7 +59,6 @@ module Dev
71
59
  application = @name
72
60
  ruby = @ruby
73
61
  exclude = @exclude
74
- up_cmd = @start_container_dependencies_on_test ? :up : :up_no_deps
75
62
  return if exclude.include?(:test)
76
63
 
77
64
  DEV_COMMANDS_TOP_LEVEL.instance_eval do
@@ -83,7 +70,7 @@ module Dev
83
70
 
84
71
  namespace :ruby do
85
72
  desc "Run all ruby tests against the #{application}'s codebase"
86
- task test: %W(init_docker #{up_cmd}) do
73
+ task test: %w(init_docker up_no_deps) do
87
74
  LOG.debug("Running all ruby tests in the #{application} codebase")
88
75
 
89
76
  options = []
@@ -4,23 +4,6 @@ module Dev
4
4
  module Template
5
5
  # Class contains rake templates for managing your git project
6
6
  class Git < Dev::Template::BaseInterface
7
- # Create the rake task for cloning all defined repos
8
- def create_clone_task!
9
- # Have to set a local variable to be accessible inside of the instance_eval block
10
- exclude = @exclude
11
-
12
- DEV_COMMANDS_TOP_LEVEL.instance_eval do
13
- namespace :git do
14
- return if exclude.include?(:clone)
15
-
16
- desc 'Make sure all repos are cloned'
17
- task :clone do
18
- Dev::Git.new.clone_repos
19
- end
20
- end
21
- end
22
- end
23
-
24
7
  # Create the rake task for the git checkout method
25
8
  def create_checkout_task!
26
9
  # Have to set a local variable to be accessible inside of the instance_eval block
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.24.pre.alpha.2'.freeze
9
+ VERSION = '2.5.0.pre.alpha.1'.freeze
10
10
  end
11
11
  end
@@ -11,7 +11,7 @@ DEV_COMMANDS_TOP_LEVEL = self
11
11
 
12
12
  # Load all gems referenced in the Gemfile
13
13
  require 'bundler'
14
- Bundler.require(:default)
14
+ Bundler.require
15
15
 
16
16
  # Add libdir to the default ruby path
17
17
  libdir = File.realpath(File.dirname(__FILE__))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.24.pre.alpha.2
4
+ version: 2.5.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-16 00:00:00.000000000 Z
11
+ date: 2023-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,154 +16,154 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.2
19
+ version: 7.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 7.1.2
26
+ version: 7.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk-cloudformation
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.97.0
33
+ version: 1.83.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.97.0
40
+ version: 1.83.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: aws-sdk-codepipeline
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.67.0
47
+ version: 1.59.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.67.0
54
+ version: 1.59.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aws-sdk-ecr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.68.0
61
+ version: 1.61.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.68.0
68
+ version: 1.61.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: aws-sdk-elasticache
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.95.0
75
+ version: 1.88.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.95.0
82
+ version: 1.88.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: aws-sdk-lambda
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.113.0
89
+ version: 1.101.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.113.0
96
+ version: 1.101.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: aws-sdk-opensearchservice
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.33.0
103
+ version: 1.24.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.33.0
110
+ version: 1.24.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: aws-sdk-rds
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.208.0
117
+ version: 1.183.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.208.0
124
+ version: 1.183.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: aws-sdk-s3
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.141.0
131
+ version: 1.127.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.141.0
138
+ version: 1.127.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: aws-sdk-ssm
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.162.0
145
+ version: 1.154.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.162.0
152
+ version: 1.154.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: aws-sdk-sts
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.11.0
159
+ version: 1.10.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.11.0
166
+ version: 1.10.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: colorize
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -249,61 +249,61 @@ dependencies:
249
249
  - !ruby/object:Gem::Version
250
250
  version: 2.3.0
251
251
  - !ruby/object:Gem::Dependency
252
- name: ox
252
+ name: libxml-ruby
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - "~>"
255
+ - - '='
256
256
  - !ruby/object:Gem::Version
257
- version: 2.14.17
257
+ version: 4.1.1
258
258
  type: :runtime
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - "~>"
262
+ - - '='
263
263
  - !ruby/object:Gem::Version
264
- version: 2.14.17
264
+ version: 4.1.1
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: public_suffix
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 5.0.4
271
+ version: 5.0.1
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 5.0.4
278
+ version: 5.0.1
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: rake
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
283
  - - "~>"
284
284
  - !ruby/object:Gem::Version
285
- version: 13.1.0
285
+ version: 13.0.6
286
286
  type: :runtime
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
- version: 13.1.0
292
+ version: 13.0.6
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: slack-ruby-client
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - "~>"
298
298
  - !ruby/object:Gem::Version
299
- version: 2.2.0
299
+ version: 2.1.0
300
300
  type: :runtime
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - "~>"
305
305
  - !ruby/object:Gem::Version
306
- version: 2.2.0
306
+ version: 2.1.0
307
307
  description: Ruby library for creating/maintaining your development environment
308
308
  email: opensource@firespring.com
309
309
  executables: []
@@ -327,15 +327,8 @@ files:
327
327
  - lib/firespring_dev_commands/aws/parameter.rb
328
328
  - lib/firespring_dev_commands/aws/profile.rb
329
329
  - lib/firespring_dev_commands/aws/s3.rb
330
- - lib/firespring_dev_commands/bloom_growth.rb
331
- - lib/firespring_dev_commands/bloom_growth/rock.rb
332
- - lib/firespring_dev_commands/bloom_growth/seat.rb
333
- - lib/firespring_dev_commands/bloom_growth/user.rb
334
330
  - lib/firespring_dev_commands/boolean.rb
335
331
  - lib/firespring_dev_commands/common.rb
336
- - lib/firespring_dev_commands/coverage/base.rb
337
- - lib/firespring_dev_commands/coverage/cobertura.rb
338
- - lib/firespring_dev_commands/coverage/none.rb
339
332
  - lib/firespring_dev_commands/daterange.rb
340
333
  - lib/firespring_dev_commands/docker.rb
341
334
  - lib/firespring_dev_commands/docker/compose.rb
@@ -1,34 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing rock information
4
- class Rock
5
- attr_accessor :data, :id, :type, :name, :owner, :complete, :completion_id, :created, :due
6
- attr_reader :state
7
-
8
- def initialize(data)
9
- @data = data
10
- @id = data['Id']
11
- @type = data['Type']
12
- @name = data['Name'].to_s.strip
13
- @owner = User.new(data['Owner']) if data['Owner']
14
- @complete = data['Complete']
15
- @completion_id = data['Completion']
16
- @created = Time.parse(data['CreateTime']) if data['CreateTime']
17
- @due = Time.parse(data['DueDate']) if data['DueDate']
18
- @archived = data['Archived']
19
- end
20
-
21
- # Convert the completion_id bloom growth gives us into a text version
22
- def state
23
- case completion_id
24
- when 0
25
- 'Off Track'
26
- when 1
27
- 'On Track'
28
- when 2
29
- 'Complete'
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,16 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing seat information
4
- class Seat
5
- attr_accessor :data, :id, :type, :name
6
-
7
- def initialize(data)
8
- @data = data
9
- position = data.dig('Group', 'Position')
10
- @id = position&.fetch('Id')
11
- @type = position&.fetch('Type')
12
- @name = position&.fetch('Name').to_s.strip
13
- end
14
- end
15
- end
16
- end
@@ -1,43 +0,0 @@
1
- module Dev
2
- class BloomGrowth
3
- # Class containing user information
4
- class User
5
- attr_accessor :data, :id, :type, :name, :rocks, :direct_reports, :seats
6
-
7
- def initialize(data)
8
- @data = data
9
- @id = data['Id']
10
- @type = data['Type']
11
- @name = data['Name'].to_s.strip
12
- @rocks = nil
13
- @direct_reports = nil
14
- @seats = nil
15
- end
16
-
17
- def rocks
18
- @rocks ||= [].tap do |ary|
19
- Dev::BloomGrowth.new.get("/api/v1/rocks/user/#{id}") do |data|
20
- ary << Rock.new(data)
21
- end
22
- end
23
- end
24
-
25
- def direct_reports
26
- @direct_reports ||= [].tap do |ary|
27
- Dev::BloomGrowth.new.get("/api/v1/users/#{id}/directreports") do |data|
28
- ary << User.new(data)
29
- end
30
- end
31
- end
32
-
33
- def seats
34
- @seats ||= [].tap do |ary|
35
- Dev::BloomGrowth.new.get("/api/v1/users/#{id}/seats") do |data|
36
- ary << Seat.new(data)
37
- puts ary.last.inspect
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,132 +0,0 @@
1
- require 'net/http'
2
-
3
- module Dev
4
- # Class for interacting with the Bloom Growth api
5
- class BloomGrowth
6
- # The config file to try to load credentials from
7
- CONFIG_FILE = "#{Dir.home}/.env.bloom".freeze
8
-
9
- # The text of the username variable key
10
- BLOOM_USERNAME = 'BLOOM_USERNAME'.freeze
11
-
12
- # The text of the password variable key
13
- BLOOM_PASSWORD = 'BLOOM_PASSWORD'.freeze
14
-
15
- # The text of the token variable key
16
- BLOOM_TOKEN = 'BLOOM_TOKEN'.freeze
17
-
18
- # The text of the url variable key
19
- BLOOM_URL = 'BLOOM_URL'.freeze
20
-
21
- # Config object for setting top level bloom growth config options
22
- Config = Struct.new(:username, :password, :url, :http_debug) do
23
- def initialize
24
- Dotenv.load(CONFIG_FILE) if File.exist?(CONFIG_FILE)
25
-
26
- self.username = ENV.fetch(BLOOM_USERNAME, nil)
27
- self.password = ENV.fetch(BLOOM_PASSWORD, nil)
28
- self.url = ENV.fetch(BLOOM_URL, 'https://app.bloomgrowth.com')
29
- self.http_debug = false
30
- end
31
- end
32
-
33
- class << self
34
- # Instantiates a new top level config object if one hasn't already been created
35
- # Yields that config object to any given block
36
- # Returns the resulting config object
37
- def config
38
- @config ||= Config.new
39
- yield(@config) if block_given?
40
- @config
41
- end
42
-
43
- # Alias the config method to configure for a slightly clearer access syntax
44
- alias_method :configure, :config
45
- end
46
-
47
- attr_accessor :username, :password, :url, :token, :client, :default_headers
48
-
49
- # Initialize a new target process client using the given inputs
50
- def initialize(username: self.class.config.username, password: self.class.config.password, url: self.class.config.url)
51
- raise 'username is required' if username.to_s.strip.empty?
52
- raise 'password is required' if password.to_s.strip.empty?
53
- raise 'url is required' if url.to_s.strip.empty?
54
-
55
- @username = username
56
- @password = password
57
- @url = url
58
- uri = URI.parse(@url)
59
- @client = Net::HTTP.new(uri.host, uri.port)
60
- @client.use_ssl = true
61
- @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
62
- @client.set_debug_output(LOG) if self.class.config.http_debug
63
- @default_headers = {
64
- 'authorization' => "Bearer #{token}",
65
- 'content-type' => 'application/json',
66
- 'accept' => 'application/json'
67
- }
68
- end
69
-
70
- # Method for getting a bearer token for the bloom growth api. There are a couple of possible logic paths
71
- # - If a token has already been defined, use it
72
- # - If a token is found in the ENV, use it
73
- # - Otherwise, use the username and passowrd that has been configured to request a new token from bloom
74
- def token
75
- @token ||= ENV.fetch(BLOOM_TOKEN, nil)
76
-
77
- unless @token
78
- response = post(
79
- '/Token',
80
- {
81
- grant_type: 'password',
82
- userName: username,
83
- password:
84
- },
85
- headers: {
86
- 'content-type' => 'application/json',
87
- 'accept' => 'application/json'
88
- }
89
- )
90
- # TODO: Should we look at https://github.com/DannyBen/lightly for caching the token?
91
- @token = ENV[BLOOM_TOKEN] = response['access_token']
92
- LOG.info("Retrieved BloomGrowth token. Expires on #{Time.now + response['expires_in']}")
93
- end
94
-
95
- @token
96
- end
97
-
98
- # Return all user objects visible to the logged in user
99
- def visible_users(&)
100
- [].tap do |ary|
101
- get('/api/v1/users/mineviewable') do |user_data|
102
- ary << User.new(user_data)
103
- end
104
- ary.each(&)
105
- end
106
- end
107
-
108
- # Perform a get request to the given path using the given query
109
- # Call the given block (if present) with each piece of data
110
- # Return all pieces of data
111
- def get(path, query_string: nil, headers: default_headers, &)
112
- url = path
113
- url << "?#{URI.encode_www_form(query_string)}" unless query_string.to_s.strip.empty?
114
-
115
- response = client.request_get(url, headers)
116
- raise "Error querying #{url} [#{query_string}]: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
117
-
118
- JSON.parse(response.body).each(&)
119
- nil
120
- end
121
-
122
- # Perform a post request to the given path using the gien data
123
- # Return the parsed json body
124
- def post(path, data, headers: default_headers)
125
- data = data.to_json unless data.is_a?(String)
126
- response = client.request_post(path, data, headers)
127
- raise "Error querying #{url}/#{path}: #{response.inspect}" unless response.response.is_a?(Net::HTTPSuccess)
128
-
129
- JSON.parse(response.body)
130
- end
131
- end
132
- end
@@ -1,13 +0,0 @@
1
- module Dev
2
- module Coverage
3
- class Base
4
- def php_options
5
- raise 'not implemented'
6
- end
7
-
8
- def check(*)
9
- raise 'not implemented'
10
- end
11
- end
12
- end
13
- end
@@ -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,17 +0,0 @@
1
- module Dev
2
- module Coverage
3
- class None < Base
4
- def initialize(*)
5
- super()
6
- end
7
-
8
- def php_options
9
- []
10
- end
11
-
12
- def check(*)
13
- puts 'Coverage not configured'
14
- end
15
- end
16
- end
17
- end