firespring_dev_commands 2.1.21.pre.alpha.8 → 2.1.21.pre.alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82b69d61d6649aaa851e8000d68b651193d265b29be96318e5bbbf0383a901e7
4
- data.tar.gz: 880ff091de3b0318a4c6b2838494ba4d68c47a325457d98a88008acee6d2bcf0
3
+ metadata.gz: 4189e443ce57ccf4e992178ad2dd0de137017a8d78f6d63a4e4f7b55f76fe61b
4
+ data.tar.gz: ab87b579efff5fe40edfad306c6088504b176b61f4d0997e8ab8804f65a61177
5
5
  SHA512:
6
- metadata.gz: d5dfffdc56f103e23c0a00331003a1499a9cb9444a732a71355143b1e34682ee0d9a07215c096b29b42cbbd46d24d6ac43cc9ac890d6e4f2042fe31f463f8833
7
- data.tar.gz: f08ea0a75721208a727934db0c3bd1b896b28f5f59e3c14efbd7a5468ac792df49543e175e73ad430cfcad8694318e1607d167ca06adccc17c91be9ac3456378
6
+ metadata.gz: 329dc4520ff98700950aef5c5b67920e8f8b520d6f8eba693150526e7144c962b55c31924e0d956b108fe8914777d4d21daf14c20393bb3f61902c19dd92a315
7
+ data.tar.gz: 873fcd5623d4e007cd2018285656caa029fdbf9dc34714b64df4223a10cb118b95919bbc428176ee7d68b29da6aea130163881a5480cd0fe2db7a033795af8ae
@@ -0,0 +1,13 @@
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
@@ -2,15 +2,21 @@ module Dev
2
2
  # Module containing different classes for interfacing with coverage files
3
3
  module Coverage
4
4
  # Class for checking code coverage using cobertura
5
- class Cobertura
5
+ class Cobertura < Base
6
6
  attr_reader :local_filename, :container_filename, :filename, :threshold, :exclude
7
7
 
8
8
  def initialize(filename: File.join('coverage', 'cobertura.xml'), threshold: nil, container_path: nil, local_path: nil, exclude: nil)
9
+ super()
10
+
9
11
  @filename = filename
10
12
  @local_filename = File.join(local_path || '.', @filename)
11
13
  @container_filename = File.join(container_path || '.', @filename)
12
14
  @threshold = threshold
13
- @exclude = exclude || []
15
+ @exclude = (exclude || []).map do |it|
16
+ next it if it.is_a?(Regex)
17
+
18
+ Regex.new(it)
19
+ end
14
20
  end
15
21
 
16
22
  # Remove any previous versions of the local file that will be output
@@ -55,12 +61,14 @@ module Dev
55
61
  missed += 1 unless line.attributes[:hits].to_i.positive?
56
62
  end
57
63
  total = lines_processed.length
64
+
58
65
  sanity_check_coverage_against_cobertura_values(package, missed, total)
59
66
  missed
60
67
  end
61
68
 
62
69
  # Calculate the coverage percent based off the numbers we got and compare to the
63
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
64
72
  private def sanity_check_coverage_against_cobertura_values(package, missed, total)
65
73
  line_rate = package.attributes[:'line-rate']
66
74
  cobertura_reported_coverage = line_rate.to_f
@@ -71,7 +79,7 @@ module Dev
71
79
  return if file_coverage == cobertura_reported_coverage
72
80
 
73
81
  filename = package.attributes[:name]
74
- puts "WARNINNG: #{filename} coverage (#{file_coverage}) differed from what cobertura reported (#{cobertura_reported_coverage})".light_yellow
82
+ puts "WARNINNG: #{filename} coverage (#{file_coverage}) differed from what cobertura reported (#{cobertura_reported_coverage})"
75
83
  end
76
84
  end
77
85
  end
@@ -0,0 +1,17 @@
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
@@ -8,12 +8,12 @@ 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_threshold) do
11
+ Config = Struct.new(:container_path, :local_path, :package_file, :coverage) 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_threshold = nil
16
+ self.coverage = nil
17
17
  end
18
18
  end
19
19
 
@@ -33,11 +33,11 @@ module Dev
33
33
 
34
34
  attr_accessor :container_path, :local_path, :package_file, :coverage
35
35
 
36
- def initialize(container_path: nil, local_path: nil, package_file: nil, coverage_threshold: nil)
36
+ def initialize(container_path: nil, local_path: nil, package_file: nil, coverage: nil)
37
37
  @container_path = container_path || self.class.config.container_path
38
38
  @local_path = local_path || self.class.config.local_path
39
39
  @package_file = package_file || self.class.config.package_file
40
- @coverage = Dev::Coverage::Cobertura.new(container_path:, local_path:, threshold: coverage_threshold)
40
+ @coverage = coverage || Dev::Coverage::None.new
41
41
  end
42
42
 
43
43
  # The base npm command that is the starting point for all subsequent commands
@@ -95,7 +95,7 @@ module Dev
95
95
  def test_command
96
96
  test = []
97
97
  test << './vendor/bin/phpunit'
98
- test << coverage.php_options if coverage
98
+ test.concat(coverage.php_options) if coverage
99
99
  test.concat(Dev::Common.new.tokenize(ENV['OPTS'].to_s))
100
100
  test
101
101
  end
@@ -20,10 +20,10 @@ module Dev
20
20
  container_path: nil,
21
21
  local_path: nil,
22
22
  start_container_dependencies_on_test: true,
23
- coverage_threshold: nil,
23
+ coverage: nil,
24
24
  exclude: []
25
25
  )
26
- @php = Dev::Php.new(container_path:, local_path:, coverage_threshold:)
26
+ @php = Dev::Php.new(container_path:, local_path:, coverage:)
27
27
  @start_container_dependencies_on_test = start_container_dependencies_on_test
28
28
 
29
29
  super(application, exclude:)
@@ -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.21.pre.alpha.8'.freeze
9
+ VERSION = '2.1.21.pre.alpha.9'.freeze
10
10
  end
11
11
  end
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.21.pre.alpha.8
4
+ version: 2.1.21.pre.alpha.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-21 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -333,7 +333,9 @@ files:
333
333
  - lib/firespring_dev_commands/bloom_growth/user.rb
334
334
  - lib/firespring_dev_commands/boolean.rb
335
335
  - lib/firespring_dev_commands/common.rb
336
+ - lib/firespring_dev_commands/coverage/base.rb
336
337
  - lib/firespring_dev_commands/coverage/cobertura.rb
338
+ - lib/firespring_dev_commands/coverage/none.rb
337
339
  - lib/firespring_dev_commands/daterange.rb
338
340
  - lib/firespring_dev_commands/docker.rb
339
341
  - lib/firespring_dev_commands/docker/compose.rb