ericcornelissen/codecov-config-validator-action

Log the Codecov API response

Closed this issue · 0 comments

Summary

In v1.0.1 (and earlier) of this Action the only log output is a line indicating whether or not the configuration is valid, and (since v1.0.1) if it isn't a suggestion for what to do.

However, the Codecov API responds with more than a status code. For example, the following is what you get when running from the root of the repository at 89dec33:

$ curl --data-binary @testdata/codecov.yml https://codecov.io/validate
Valid!

{
  "coverage": {
    "precision": 2,
    "round": "down",
    "range": [
      80.0,
      100.0
    ],
    "status": {
      "project": {
        "default": false,
        "source": {
          "paths": [
            "^src/.*"
          ]
        }
      }
    }
  },
  "comment": {
    "layout": "diff, flags, files",
    "behavior": "default",
    "require_changes": true,
    "require_base": false,
    "require_head": true
  }
}

This might not be too useful, but when there is an error the response body can be helpful when addressing the problem. For example, with the change:

  # An example Codecov configuration file for testing purposes

- coverage:
+ coverag:
    precision: 2
    round: down

The Codecov API response becomes:

$ curl --data-binary @testdata/codecov.yml https://codecov.io/validate
Error at ['coverag']: 
unknown field

Proposal

Just log the API response body for the user to see. Make sure the logs are formatted such that it's clear exactly what is the verbatim response from the API and what are the Action's own logs.