feedback icon indicating copy to clipboard operation
feedback copied to clipboard

Validate yml automatically via GitHub Action

Open cstavitsky opened this issue 6 months ago • 3 comments

Opening on behalf of a customer:

What product do you want to improve? Codecov yml validator

Is your feature request related to a problem? Please describe. It can be difficult to realize that the codecov yml syntax is invalid. Having to call the validator every time seems like something that could be automated.

Describe the solution you'd like "It'd be both expected and excellent if the GitHub Action did [yml validation] automatically!"

Describe alternatives you've considered

Additional context Add any other context or screenshots about the feature request here.

cstavitsky avatar Jul 02 '25 16:07 cstavitsky

We do have the vscode extension which can make the process a bit easier. That said, the flow could still be greatly improved for sure.

spalmurray avatar Jul 02 '25 16:07 spalmurray

I agree. I think having it is a good thing ... but since there's no official one yet, I'll do it this way... And if you want to work on a Github action, here is the sample code I used. I think it might be useful for you.

jobs:
  test:
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Validate codecov.yml
        # Check if the file exists before running the step
        if: ${{ hashFiles('codecov.yml') != '' }}
        run: |
          echo "Found codecov.yml. Starting validation..."
          curl -s -X POST --data-binary @codecov.yml https://codecov.io/validate | tee /dev/stderr | grep -q "Valid\!"

      - name: Other...

I originally worked with vscode, which has an extension that gives me a heads-up while I'm editing codecov.yml. But of course, when it comes to automation, putting it in a GitHub action is another option for developers. Or even better, applying it to pre-commit when the codecov.yml file changes also seems like a good fit.

Onyx-Nostalgia avatar Aug 04 '25 02:08 Onyx-Nostalgia

@Onyx-Nostalgia I believe you could simplify this to just

curl -is --fail-with-body --data-binary @codecov.yml $url

My understanding is that the API should return a 400 if the syntax is invalid, with details on the issue.

ascopes avatar Sep 23 '25 07:09 ascopes