Sha256: 09e69ca25d26a938068407272566745c60b2a93339ecab88d6a3ef9448e2678d

Contents?: true

Size: 794 Bytes

Versions: 64

Compression:

Stored size: 794 Bytes

Contents

namespace :ci do
  # Runs the Rails rake notes task (if using Rails) and converts annotation counts into "metrics"
  # Usage: bundle exec rake ci:notes
  desc 'Count notes and other annotations'
  task :notes do
    next unless Rake::Task.task_defined?('notes')

    hash = {}
    `bundle exec rake notes | grep "\\["`.split(/\n/).map do |line|
      matchdata = line.match(/\[\s*\d+\] \[([^\]]+)\]/)
      annotation = matchdata[1]
      hash[annotation] ||= 0
      hash[annotation] += 1
    end

    hash.each do |annotation, count|
      metric = {
        name: 'annotation_count',
        type: :gauge,
        label_set: {
          annotation: annotation
        },
        value: count
      }
      @metrics ||= []
      @metrics << metric
      puts metric.inspect
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
ndr_dev_support-3.1.2 lib/tasks/ci/notes.rake
ndr_dev_support-3.1.1 lib/tasks/ci/notes.rake
ndr_dev_support-3.1.0 lib/tasks/ci/notes.rake
ndr_dev_support-3.0.0 lib/tasks/ci/notes.rake