mheap / pin-github-action

Pin your GitHub actions to a specific hash
MIT License
75 stars 7 forks source link

Rewritten yaml triggers yamllint #74

Closed lucasgonze closed 2 years ago

lucasgonze commented 2 years ago

1. Trigging yamllint error "too few spaces before comment"

On running pin-github-action and submitting the output to a CI pipeline that runs yamllint, the error "too few spaces before comment (comments)" is thrown.

image

Per https://github.com/redhat-developer/vscode-yaml/issues/433, the yamllint default for the number of spaces before a comment is 2. So the output should be:

      - uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # pin@v2
      + uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e  # pin@v2

You can see the default yamllint settings here: https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.comments

2. trailing spaces

image

Indeed, the line it's complaining about has 10 spaces and nothing else:

 38           script: |
 39            
 40             let newCompLbls = new Set(); // Set of new label strings

3. spaces in brackets

This array replacement is padding square brackets with spaces:

image

lucasgonze commented 2 years ago

I have found workarounds (using sed recipes) for all these items, so this is for your own information. Do what you want with it.

The underlying code I'm working on is open source. This my working directory: https://github.com/magma/magma/tree/master/.github/workflows

This is the PR with the yamllint errors: https://github.com/magma/magma/pull/12678

mheap commented 2 years ago

Thanks for flagging this. Given the output is handled by the node YAML library I'm not sure where to start investigating this. Happy to receive a contribution if anyone wants to pick it up

lucasgonze commented 2 years ago

The right thing would be a pretty printer for the node yaml library. I poked around github and didn't find anything, and it's probably not worth either of our time to invent this, so I'm closing this.