Created
February 25, 2016 02:07
-
-
Save rypit/0c0d4da24cf41a8f1434 to your computer and use it in GitHub Desktop.
Use the travis gem to create a CSV of data about build history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'time' | |
| text = `travis --history --date --all` | |
| parsed = text.split("\n").reject{|l| l.match /not yet/}.map do |item| | |
| pattern = /([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})\s\#[0-9]*\s([\w]*):\s*([a-z0-9\-\_\.\/]*)/i | |
| this = { | |
| time: DateTime.parse( item.match(pattern)[1] ), | |
| result: item.match(pattern)[2], | |
| branch: item.match(pattern)[3], | |
| app: Dir.pwd.split("/").last, | |
| } | |
| end | |
| parsed.sort_by!{|item| item[:time]} | |
| parsed.group_by{|b| b[:branch] + b[:app]}.each do |branch, builds| | |
| last_result = "" | |
| builds.each do |build| | |
| build[:time] = build[:time].to_date.to_s | |
| build[:fix] = !!(last_result.match(/err|fail/) && build[:result] == "passed") | |
| last_result = build[:result] | |
| end | |
| end | |
| puts parsed.map{|build| build.values.join(",")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment