firespring_dev_commands 2.1.21.pre.alpha.3 → 2.1.21.pre.alpha.4

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: 23ad8131b620682ed6d6e9b496934646615c3aca3c0656886a624e03c73f0041
4
- data.tar.gz: 936887064f1e8e3c71193af00a105b3808ede716b5bf72cc959c7db63d459ac0
3
+ metadata.gz: d35a98b66dfe013f7552c2d5baf17b373ad71e3893945844a24768620755bf5f
4
+ data.tar.gz: faa627fca3af6b2c2ef417fd1442439b16d7acafa6a1a3dfa5da1fc01c26e327
5
5
  SHA512:
6
- metadata.gz: 89cd73bbf3342e5ff66a9762311bfd07a5c78f18aa7dc92d3edaef96d55277054a887b011b672a3a9d2689870a98c1a1784ee5061f6539bba8a95856fe86d095
7
- data.tar.gz: e0a8077e578697502912063cdf9004d21c993cb32b54cbfb46b158f59b7f7a37ac6362358606070451113ead000bf7759859999cc9818eddbbeba7cdda43965f
6
+ metadata.gz: 434c1348564f615f90438f4682080aa70a659693a264e2b47ac17f94e935fb0dfbace4875df3c76dcd5ac76d2ce44cdc7ded70ec10882e5fa4927f01e9e4fb0c
7
+ data.tar.gz: a11c82d457d76e6eeca78217db40a62d7cc9c6eade77c2f07cb9c68ed89b4b1d274b6e7cad5e64abefa0c1814c23b29a03f2e4b0d837d9f9faece9b24ca5821b
@@ -3,11 +3,13 @@ module Dev
3
3
  module Coverage
4
4
  # Class for checking code coverage using cobertura
5
5
  class Cobertura
6
- attr_reader :local_filename, :container_filename, :filename, :threshold
6
+ attr_reader :local_path, :container_path, :filename, :threshold, :local_path, :local_filename, :container_path, :container_filename
7
7
 
8
8
  def initialize(filename: 'cobertura.xml', threshold: nil, container_path: nil, local_path: nil)
9
9
  @filename = filename
10
+ @local_path = local_path
10
11
  @local_filename = File.join(local_path || '.', @filename)
12
+ @container_path = container_path
11
13
  @container_filename = File.join(container_path || '.', @filename)
12
14
  @threshold = threshold.to_f
13
15
  end
@@ -18,17 +20,25 @@ module Dev
18
20
  # Remove any previous coverage info
19
21
  FileUtils.rm_f(local_filename, verbose: true)
20
22
 
23
+ # Return the needed php commands to generate the cobertura report
21
24
  %W(--coverage-cobertura #{container_filename})
22
25
  end
23
26
 
24
27
  # Parse the cobertura file as a hash and check the total coverage against the desired threshold
25
- def check
28
+ def check(application: nil)
29
+ # If an application has been specified and the file does not exist locally, attempt to copy it back from the docker container
30
+ if application && !File.exist?(local_filename)
31
+ container = Dev::Docker::Compose.new.container_by_name(application)
32
+ workdir = Dev::Docker.new.default_working_dir(container)
33
+ Dev::Docker.new.copy_from_container(container, File.join(workdir, filename), local_filename, required: true)
34
+ end
35
+
36
+ # Load the file from disk and parse with ox
26
37
  report = Ox.load(File.read(local_filename), mode: :hash)
27
38
  attrs, = report[:coverage]
28
39
  cov_pct = attrs[:'line-rate'].to_f * 100
29
- raise format('Line coverage %.2f%% is less than the threshold %.2f%%', cov_pct, threshold) if cov_pct < threshold
30
-
31
- puts format('Line coverage %.2f%% is above the threshold %.2f%%', cov_pct, threshold)
40
+ puts format('Line coverage was %.2f%%. Configured threshold was %.2f%%', cov_pct, threshold)
41
+ raise 'Code coverage not met' if cov_pct < threshold
32
42
  end
33
43
  end
34
44
  end
@@ -138,6 +138,11 @@ 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 default_working_dir(container)
143
+ container.json['Config']['WorkingDir']
144
+ end
145
+
141
146
  # Copies the source path on your local machine to the destination path on the container
142
147
  def copy_to_container(container, source_path, dest_path)
143
148
  LOG.info "Copying #{source_path} to #{dest_path}... "
@@ -101,8 +101,8 @@ module Dev
101
101
  end
102
102
 
103
103
  # Run the check to ensure code coverage meets the desired threshold
104
- def check_test_coverage
105
- coverage.check
104
+ def check_test_coverage(application:)
105
+ coverage.check(application:)
106
106
  end
107
107
 
108
108
  # Build the php fast test command
@@ -135,7 +135,7 @@ module Dev
135
135
  options = []
136
136
  options << '-T' if Dev::Common.new.running_codebuild?
137
137
  Dev::Docker::Compose.new(services: application, options:).exec(*php.test_command)
138
- php.check_test_coverage
138
+ php.check_test_coverage(application:)
139
139
  end
140
140
  end
141
141
  end
@@ -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.3'.freeze
9
+ VERSION = '2.1.21.pre.alpha.4'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.3
4
+ version: 2.1.21.pre.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring