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 +4 -4
- data/lib/firespring_dev_commands/coverage/cobertura.rb +11 -4
- data/lib/firespring_dev_commands/docker.rb +7 -0
- data/lib/firespring_dev_commands/php.rb +2 -2
- data/lib/firespring_dev_commands/templates/docker/php/application.rb +1 -1
- data/lib/firespring_dev_commands/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 831bd71e091dc6ad04f4ce368c343207845a6d9ae175fe12f40e36dee14717c3
|
4
|
+
data.tar.gz: 5eb6f226edc9309bb1a6873127decc4b678aea8d3e8005c5686d9c082096b05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|