ibiqlik / action-yamllint

GitHub Action - Yaml Lint
MIT License
97 stars 41 forks source link

GitHub Action Output doesn't have YAML file paths the problems refer to. #14

Closed jgstew closed 3 years ago

jgstew commented 3 years ago

The errors and warnings output in the GitHub Action don't show which file path they are for, but I have 4 different YAML files in my repo. Is there a way to configure this?

My config: https://github.com/jgstew/jgstew-recipes/blob/main/.github/workflows/yamllint.yaml

name: YAML Lint

on:
  push:
    paths: 
    - "**.yaml"
    - "**.yml"
  pull_request:
    paths:
    - "**.yaml"
    - "**.yml"

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: GitHub YAMLlint
      uses: ibiqlik/action-yamllint@v3

Example output with warnings / errors but no paths: https://github.com/jgstew/jgstew-recipes/actions/runs/636513923

jgstew commented 3 years ago

Seems like I need the argument -f parsable from here: https://yamllint.readthedocs.io/en/stable/quickstart.html#running-yamllint

Seems like parsable can't be specified in a config file: https://github.com/adrienverge/yamllint/issues/266

It does seem like there should be a way to get this without parsable as well.

jgstew commented 3 years ago

Seems like this might be a bug in the output format not being set as github properly here:

https://github.com/adrienverge/yamllint/blob/8eebab68ab31138c7ef021117897f71fb537b747/yamllint/cli.py#L115

Specifically here:

        elif args_format == 'github' or (args_format == 'auto' and
                                         'GITHUB_ACTIONS' in os.environ and
                                         'GITHUB_WORKFLOW' in os.environ):

Seems like maybe it should be:

        elif args_format == 'github' or (args_format == 'auto' and
                                         ('GITHUB_ACTIONS' in os.environ or
                                         'GITHUB_WORKFLOW' in os.environ)):

but that is just a guess on my part.

Original commit was here: https://github.com/adrienverge/yamllint/commit/67cb4eb24db7998e67c7ec478c2ac166c35e4a24

jgstew commented 3 years ago

Seems like a fix would be to use a more generic GitHub action and add the command arg manually as outlined here:

https://github.com/adrienverge/yamllint/blob/master/docs/integration.rst

jgstew commented 3 years ago

I now see that "github" should be the default format and it is configurable here: https://github.com/ibiqlik/action-yamllint/blob/master/action.yml#L16

ibiqlik commented 3 years ago

@jgstew Sorry for late reply, notification overflow.

As you found out yourself you can set your desired output format in the action

    - uses: ibiqlik/action-yamllint@v3
      with:
        format: parsable
jgstew commented 3 years ago

my main preference for parsable was that the output format of github seems like it wasn't being selected automatically, and even when I specified it, I wasn't getting file paths in the yamllint output, so it was hard to tell what files the lint output was referring to.

I did eventually figure out how to force parsable but I'm still confused why github wasn't working for me.

I'd consider this "closed" as far as I'm concerned because I'm fine with the parsable output personally.

ibiqlik commented 3 years ago

I find the github not an optimal output, it's mostly useful on a pull request where the warnings/errors are clearly visible in the diff section right on the file that has problems. But, just by looking at the workflow run then there's no way to know which file/line has the issue.

jgstew commented 3 years ago

I agree, the github format was useless to me in the workflow output, which was very annoying. I switched to parsable and I'm happy.