diff --git a/CHANGELOG.md b/CHANGELOG.md index 195e3f4..454e10e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### `0.6.0` +- #145 Fixes issue with nil URI and provides more token information + ### `0.5.2` - #141 Add Cirrus CI support diff --git a/lib/codecov/uploader.rb b/lib/codecov/uploader.rb index 47d9057..39e73f5 100644 --- a/lib/codecov/uploader.rb +++ b/lib/codecov/uploader.rb @@ -49,15 +49,15 @@ def self.upload(report, disable_net_blockers = true) response = false end - if response == false + net_blockers(:on) if disable_net_blockers + + unless response report['result'] = { 'uploaded' => false } + raise StandardError.new 'Could not upload reports to Codecov' unless ::Codecov.pass_ci_if_error return report end - report['result'] = JSON.parse(response) handle_report_response(report) - - net_blockers(:on) if disable_net_blockers report end @@ -128,6 +128,9 @@ def self.detect_ci end def self.build_params(ci) + puts [red('x>'), 'No token specified or token is empty'].join(' ') if + ENV['CODECOV_TOKEN'].nil? || ENV['CODECOV_TOKEN'].empty? + params = { 'token' => ENV['CODECOV_TOKEN'], 'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS'], @@ -451,6 +454,12 @@ def self.upload_to_v4(url, report, query, query_without_token) reports_url = response.body.lines[0] s3target = response.body.lines[1] + + if s3target.nil? || s3target.empty? + puts red(response.body) + return false + end + puts [green('-> '), 'Uploading to'].join(' ') puts s3target diff --git a/lib/codecov/version.rb b/lib/codecov/version.rb index d08c4b8..9445a05 100644 --- a/lib/codecov/version.rb +++ b/lib/codecov/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Codecov - VERSION = '0.5.2' + VERSION = '0.6.0' end diff --git a/test/helper.rb b/test/helper.rb index 57d6da1..2650c9c 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -9,7 +9,7 @@ end require_relative '../lib/codecov' SimpleCov.formatter = SimpleCov::Formatter::Codecov if ENV['CI'] == 'true' -Codecov.pass_ci_if_error = true +Codecov.pass_ci_if_error = false require 'minitest/autorun' require 'mocha/minitest' diff --git a/test/test_codecov.rb b/test/test_codecov.rb index edc740c..3b8a31a 100644 --- a/test/test_codecov.rb +++ b/test/test_codecov.rb @@ -17,10 +17,12 @@ class TestCodecov < Minitest::Test 'CIRCLE_REPOSITORY_URL' => ENV['CIRCLE_REPOSITORY_URL'], 'CIRCLE_PR_NUMBER' => ENV['CIRCLE_PR_NUMBER'], 'CIRCLE_BRANCH' => ENV['CIRCLE_BRANCH'], - 'CIRCLE_SHA1' => ENV['CIRCLE_SHA1'] + 'CIRCLE_SHA1' => ENV['CIRCLE_SHA1'], + 'CODECOV_TOKEN' => ENV['CODECOV_TOKEN'] } when Codecov::Uploader::GITHUB { + 'CODECOV_TOKEN' => ENV['CODECOV_TOKEN'], 'GITHUB_ACTIONS' => ENV['GITHUB_ACTIONS'], 'GITHUB_HEAD_REF' => ENV['GITHUB_HEAD_REF'], 'GITHUB_REF' => ENV['GITHUB_REF'], @@ -30,6 +32,7 @@ class TestCodecov < Minitest::Test } when Codecov::Uploader::TRAVIS { + 'CODECOV_TOKEN' => ENV['CODECOV_TOKEN'], 'TRAVIS' => ENV['TRAVIS'], 'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'], 'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'], @@ -39,7 +42,9 @@ class TestCodecov < Minitest::Test 'TRAVIS_JOB_ID' => ENV['TRAVIS_JOB_ID'] } else - {} + { + 'CODECOV_TOKEN' => ENV['CODECOV_TOKEN'] + } end.freeze def url @@ -109,6 +114,7 @@ def setup ENV['CIRCLECI'] = nil ENV['GITHUB_ACTIONS'] = nil ENV['TRAVIS'] = nil + ::Codecov.pass_ci_if_error = true end def teardown @@ -237,6 +243,7 @@ def teardown ENV['WORKSPACE'] = nil REALENV.each_pair { |k, v| ENV[k] = v } + ::Codecov.pass_ci_if_error = false end def test_git