firespring_dev_commands 2.1.21.pre.alpha.3 → 2.1.21.pre.alpha.5

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: 23ad8131b620682ed6d6e9b496934646615c3aca3c0656886a624e03c73f0041
4
- data.tar.gz: 936887064f1e8e3c71193af00a105b3808ede716b5bf72cc959c7db63d459ac0
3
+ metadata.gz: 831bd71e091dc6ad04f4ce368c343207845a6d9ae175fe12f40e36dee14717c3
4
+ data.tar.gz: 5eb6f226edc9309bb1a6873127decc4b678aea8d3e8005c5686d9c082096b05d
5
5
  SHA512:
6
- metadata.gz: 89cd73bbf3342e5ff66a9762311bfd07a5c78f18aa7dc92d3edaef96d55277054a887b011b672a3a9d2689870a98c1a1784ee5061f6539bba8a95856fe86d095
7
- data.tar.gz: e0a8077e578697502912063cdf9004d21c993cb32b54cbfb46b158f59b7f7a37ac6362358606070451113ead000bf7759859999cc9818eddbbeba7cdda43965f
6
+ metadata.gz: 7fb65d68db2549227de42ee2f5921e7a2586020aabfe9fcd54d1e923f089c9ba0e3e16338c8d800c0e526dc18e49d38819364df4a99db209140b13c19cb58680
7
+ data.tar.gz: e8da4354c580c083584c7e2850bce7865e99ecb4646224170e4a5b519e8a0b0d09557c6125e5fde99f29980eb917ec5b4218bd465c352250b101e564944bd835
@@ -18,17 +18,24 @@ module Dev
18
18
  # Remove any previous coverage info
19
19
  FileUtils.rm_f(local_filename, verbose: true)
20
20
 
21
+ # Return the needed php commands to generate the cobertura report
21
22
  %W(--coverage-cobertura #{container_filename})
22
23
  end
23
24
 
24
25
  # Parse the cobertura file as a hash and check the total coverage against the desired threshold
25
- def check
26
+ def check(application: nil)
27
+ # If an application has been specified and the file does not exist locally, attempt to copy it back from the docker container
28
+ if application && !File.exist?(local_filename)
29
+ container = Dev::Docker::Compose.new.container_by_name(application)
30
+ Dev::Docker.new.copy_from_container(container, container_filename, local_filename, required: true)
31
+ end
32
+
33
+ # Load the file from disk and parse with ox
26
34
  report = Ox.load(File.read(local_filename), mode: :hash)
27
35
  attrs, = report[:coverage]
28
36
  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)
37
+ puts format('Line coverage was %.2f%%. Configured threshold was %.2f%%', cov_pct, threshold)
38
+ raise 'Code coverage not met' if cov_pct < threshold
32
39
  end
33
40
  end
34
41
  end
@@ -138,8 +138,14 @@ 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
+
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)
148
+ dest_path = File.join(working_dir(container), dest_path) unless dest_path.start_with?(File::SEPARATOR)
143
149
  LOG.info "Copying #{source_path} to #{dest_path}... "
144
150
 
145
151
  container.archive_in(source_path, dest_path, overwrite: true)
@@ -154,6 +160,7 @@ module Dev
154
160
  # Copies the source path on the container to the destination path on your local machine
155
161
  # If required is set to true, the command will fail if the source path does not exist on the container
156
162
  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)
157
164
  LOG.info "Copying #{source_path} to #{dest_path}... "
158
165
 
159
166
  tar = StringIO.new
@@ -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.5'.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.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring