summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-30 19:47:40 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-21 12:44:24 +0200
commit3dac444ca17bdd17414bebcc55e7a53310dee544 (patch)
treeac548a4b2d33db07525cee9b07a725fbc975f50b
parent070a96f54faac289d9254f0e8735f3926418335c (diff)
downloadgitlab-ce-3dac444ca17bdd17414bebcc55e7a53310dee544.tar.gz
Fix SimpleCov report merging
-rw-r--r--.gitlab-ci.yml3
-rwxr-xr-xscripts/merge-simplecov37
2 files changed, 38 insertions, 2 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1ca266ef4f1..8f75a46dfe8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -74,7 +74,8 @@ update-coverage:
artifacts:
expire_in: 31d
paths:
- - coverage/
+ - coverage/index.html
+ - coverage/assets/
# Execute all testing suites
diff --git a/scripts/merge-simplecov b/scripts/merge-simplecov
index 0d764d2b406..2af5f8c0918 100755
--- a/scripts/merge-simplecov
+++ b/scripts/merge-simplecov
@@ -46,11 +46,42 @@ def all_results
results
end
+def merge_resultset(a1, a2)
+ return a1 || [] unless a2
+ return a2 || [] unless a1
+
+ new_array = a1.dup
+ a2.each_with_index do |element, i|
+ if element.nil? && new_array[i].nil?
+ new_array[i] = nil
+ elsif element.nil? && new_array[i] == 0 || element == 0 && new_array[i].nil?
+ new_array[i] = nil
+ else
+ local_value = element || 0
+ other_value = new_array[i] || 0
+ new_array[i] = local_value + other_value
+ end
+ end
+ new_array
+end
+
+def merge_hashes(h1, h2)
+ new_resultset = {}
+ (h1.keys + h2.keys).each do |filename|
+ new_resultset[filename] = []
+ end
+
+ new_resultset.each_key do |filename|
+ new_resultset[filename] = merge_resultset(h1[filename], h2[filename])
+ end
+ new_resultset
+end
+
def merged_result
merged = {}
results = all_results
results.each do |result|
- merged = result.original_result.merge_resultset(merged)
+ merged = merge_hashes(result.original_result, merged)
end
result = SimpleCov::Result.new(merged)
# Specify the command name
@@ -58,6 +89,10 @@ def merged_result
result
end
+# Ignore CI environment
+ENV['CI'] = nil
+ENV['CI_BUILD_NAME'] = nil
+
require_relative '../spec/simplecov_env'
merged_result.format!