Sha256: 4d63c3f09da7b8fdc60ddb3d6461f770c8d7e17b4279b98e20c93e9df5153501
Contents?: true
Size: 1.93 KB
Versions: 5
Compression:
Stored size: 1.93 KB
Contents
#!/usr/bin/env ruby require "bundler/inline" gemfile do source "https://rubygems.org" gem "multi_repo", require: "multi_repo/cli", path: File.expand_path("..", __dir__) gem "action_view" end require 'more_core_extensions/core_ext/array/tableize' require 'action_view' # For ActionView::Helpers::DateHelper require 'travis' require 'travis/pro/auto_login' opts = Optimist.options do opt :ref, "The branch or release tag to check status for.", :type => :string, :required => true MultiRepo::CLI.common_options(self, :except => :dry_run, :repo_set_default => nil) end opts[:repo_set] = opts[:ref].split("-").first unless opts[:repo] || opts[:repo_set] date_helper = Class.new { include ActionView::Helpers::DateHelper }.new travis_repos = MultiRepo::CLI.repos_for(**opts).collect do |repo| repo = Travis::Pro::Repository.find(repo.name) begin last_build = repo.last_on_branch(opts[:ref]) rescue Travis::Client::NotFound # Ignore repo which doesn't have Travis enabled for that branch next end status, status_sort = case last_build.state when "errored", "failed" [last_build.state.red, 0] when "created", "started" [last_build.state.yellow, 1] when "passed" [last_build.state.green, 2] else [last_build.state, 3] end date_sort = last_build.finished_at date = "#{date_helper.time_ago_in_words(date_sort)} ago" if date_sort last_build_url = "https://travis-ci.com/github/#{last_build.repository.slug}/builds/#{last_build.id}" { "Repo" => repo.name, "Status" => status, "Status Sort" => status_sort, "Date" => date, "Date Sort" => date_sort, "URL" => last_build_url } end.compact # Reverse sort by date then stable sort by status travis_repos = travis_repos.sort_by { |v| v["Date Sort"].to_s }.reverse.sort_by.with_index { |v, n| [v["Status Sort"], n] } puts travis_repos.tableize(:columns => ["Repo", "Status", "Date", "URL"])
Version data entries
5 entries across 5 versions & 1 rubygems