diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-03 17:35:00 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-06-03 17:35:00 +0200 |
commit | 792670f4ce467f278b5cdfd609a221bbbe26187d (patch) | |
tree | fa9d875a0bb0d2044ea26e4eeb332460fa88b30e | |
parent | 95c3a927b319c8495c28e6431152e5ca0c5df30b (diff) | |
download | gitlab-ce-792670f4ce467f278b5cdfd609a221bbbe26187d.tar.gz |
Merge knapsack reports and upload them to external server
-rw-r--r-- | .gitlab-ci.yml | 19 | ||||
-rwxr-xr-x | scripts/merge-reports | 29 |
2 files changed, 47 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf85820abdf..6fc410b4b51 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,7 @@ before_script: stages: - prepare - test +- post-test - notifications prepare: @@ -36,7 +37,7 @@ prepare: USE_DB: "false" script: - bundle exec rake assets:precompile - - mkdir knapsack/ + - mkdir -p knapsack/ - echo "{}" > knapsack/rspec_report.json - echo "{}" > knapsack/spinach_report.json artifacts: @@ -57,6 +58,22 @@ prepare: paths: - knapsack/ +post-tests: + stage: post-test + variables: + USE_DB: "false" + script: + - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json + - scripts/merge-reports knapsack/spinach_report.json knapsack/spinach_node_*.json + - rm -f knapsack/*_node_*.json + cache: + key: "knapsack" + paths: + - knapsack/ + artifacts: + paths: + - knapsack/ + .exec: &exec stage: test script: diff --git a/scripts/merge-reports b/scripts/merge-reports new file mode 100755 index 00000000000..f7b574001ac --- /dev/null +++ b/scripts/merge-reports @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +require 'json' +require 'yaml' + +main_report_file = ARGV.shift +unless main_report_file + puts 'usage: merge_reports <main-report> [extra reports...]' + exit 1 +end + +puts "Loading #{main_report_file}..." +main_report = JSON.parse(File.read(main_report_file)) +new_report = main_report.dup + +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) + + puts "Merged #{report_file} adding #{updates.size} results." +end + +File.write(main_report_file, JSON.pretty_generate(new_report)) +puts "Saved #{main_report_file}." |