Skip to content
Snippets Groups Projects
Commit a4d1b2a9 authored by Balasankar C's avatar Balasankar C
Browse files

Make merge script handle all reports

parent 9c819fd2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -35,7 +35,7 @@ before_script:
- export DISTRO_NAME=${JOB_NAME[0]}
- export DISTRO_VERSION=${JOB_NAME[1]}
- mkdir -p knapsack/
- '[[ -f knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json ]] || echo "{}" > knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json'
- '[[ -f knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_main_rspec_report.json ]] || echo "{}" > knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_main_rspec_report.json'
only:
- tags@gitlab-org/omnibus-gitlab
- branches@gitlab-org/omnibus-gitlab
Loading
Loading
@@ -64,7 +64,7 @@ Ubuntu 16.04 knapsack: *prepare_knapsack
# To prevent current OS providing empty/old reports of other OSs as an
# artifact. If not, they may overwrite the valid/new reports from those
# corresponding OSs. So, removing everything except current OS's report.
- cp knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json ${KNAPSACK_REPORT_PATH}.bak
- cp knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_main_rspec_report.json ${KNAPSACK_REPORT_PATH}.bak
- rm -f knapsack/*.json
- mv ${KNAPSACK_REPORT_PATH}.bak ${KNAPSACK_REPORT_PATH}
- bundle exec rake knapsack:rspec
Loading
Loading
@@ -76,31 +76,17 @@ Ubuntu 16.04 knapsack: *prepare_knapsack
paths:
- knapsack/
 
.update-knapsack: &update_knapsack
update-knapsack:
<<: *knapsack-state
stage: post-test
before_script: []
script:
- JOB_NAME=( $CI_BUILD_NAME )
- export DISTRO_NAME=${JOB_NAME[0]}
- export DISTRO_VERSION=${JOB_NAME[1]}
- support/merge-reports knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_node_*.json
- mv knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak
- rm -f knapsack/*.json
- mv knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json.bak knapsack/${DISTRO_NAME}_${DISTRO_VERSION}_rspec_report.json
- support/merge-reports knapsack
- rm -f knapsack/*node*
only:
- tags@gitlab-org/omnibus-gitlab
- branches@gitlab-org/omnibus-gitlab
 
Centos 6 update-knapsack: *update_knapsack
Centos 7 update-knapsack: *update_knapsack
Debian 7 update-knapsack: *update_knapsack
Debian 8 update-knapsack: *update_knapsack
OpenSUSE 13.2 update-knapsack: *update_knapsack
OpenSUSE 42.1 update-knapsack: *update_knapsack
Ubuntu 12.04 update-knapsack: *update_knapsack
Ubuntu 14.04 update-knapsack: *update_knapsack
Ubuntu 16.04 update-knapsack: *update_knapsack
 
# Runs on dev.gitlab.org
.branch_template: &branch_build
Loading
Loading
Loading
Loading
@@ -3,27 +3,29 @@
require 'json'
require 'yaml'
 
main_report_file = ARGV.shift
unless main_report_file
puts 'usage: merge_reports <main-report> [extra reports...]'
exit 1
end
path = File.absolute_path(ARGV.shift)
 
puts "Loading #{main_report_file}..."
main_report = JSON.parse(File.read(main_report_file))
new_report = main_report.dup
puts "Merging reports from #{path}"
Dir.glob(path + "/*_main_rspec_report.json").each do |main_report_file|
main_report = JSON.parse(File.read(main_report_file))
new_report = main_report.dup
main_file_name = File.basename(main_report_file)
match = main_file_name.match(/(?<DISTRO_NAME>.*?)_(?<DISTRO_VERSION>.*?)_.*/)
os,version = match['DISTRO_NAME'], match['DISTRO_VERSION']
puts "#{os} #{version}"
Dir.glob(path + "/#{os}_#{version}_rspec_node_*").each do |report_file|
report = JSON.parse(File.read(report_file))
 
ARGV.each do |report_file|
report = JSON.parse(File.read(report_file))
# Remove existing values
updates = report.delete_if do |key, value|
main_report[key] && main_report[key] == value
end
new_report.merge!(updates)
 
# Remove existing values
updates = report.delete_if do |key, value|
main_report[key] && main_report[key] == value
puts "\tMerged #{report_file} adding #{updates.size} results."
end
new_report.merge!(updates)
 
puts "Merged #{report_file} adding #{updates.size} results."
end
File.write(main_report_file, JSON.pretty_generate(new_report))
puts "\tSaved #{main_report_file}."
 
File.write(main_report_file, JSON.pretty_generate(new_report))
puts "Saved #{main_report_file}."
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment