Sha256: 960e849f2e8f8e42d3e41b976317bf82c67b5a04ef2156709a8bd3f56ced4b5a

Contents?: true

Size: 992 Bytes

Versions: 21

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

require "json"
require "net/http"

namespace :simplecov_coverage do
    desc "Publish simplecov coverage"
    task :publish do
        branch = `git rev-parse --abbrev-ref HEAD`.chomp.strip
        next unless branch == "main"

        repo = `git rev-parse --show-toplevel`.split("/").last.chomp.strip
        coverage_json = JSON.parse(File.read("#{Rails.root}/coverage/.last_run.json"))
        coverage = { app_name: repo, value: coverage_json.dig("result", "line") }

        uri = URI("https://neeto-library-stable-versions.herokuapp.com/neeto_test_coverage_data/upload")
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = (uri.scheme == "https")

        request = Net::HTTP::Post.new(uri, "Content-Type" => "application/json")
        request.body = { coverage_data: coverage }.to_json
        response = http.request(request)
        raise "Simplecov coverage upload failed" unless response.is_a?(Net::HTTPSuccess)
      end
  end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.108 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.107 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.106 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.105 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.104 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.103 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.102 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.101 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.100 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.99 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.98 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.97 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.96 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.95 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.94 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.93 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.92 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.91 lib/neeto_commons_backend/tasks/simplecov_coverage.rake
neeto-commons-backend-1.0.90 lib/neeto_commons_backend/tasks/simplecov_coverage.rake