adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.9k stars 278 forks source link

False positive with github actions yaml #666

Closed dosas closed 7 months ago

dosas commented 7 months ago
---
on:
  push:
    tags: ['**']
...

When running

 yamllint --strict 

Actual: warning truthy value should be one of [false, true] (truthy)

Expected: No warning

dosas commented 7 months ago

@adrienverge Could you be a little bit more verbose about it?

andrewimeson commented 7 months ago

@dosas this is an issue report with a lot of duplicates (e.g. #430). It's not a problem, it's intended default behavior.

Your options are:

  1. Quote the key

    ---
    name: Run tests
    
    "on": [push, pull_request]
  2. Disable the rule with a line comment

    ---
    name: Run tests
    
    on: [push, pull_request]  # yamllint disable-line rule:truthy
  3. Disable key checking in the yamllint configuration (e.g. .yamllint.yaml)

    ---
    extends: default
    rules:
     truthy:
       check-keys: false
adrienverge commented 7 months ago

Thanks @andrewimeson :pray:

Since https://github.com/adrienverge/yamllint/pull/650 and yamllint 1.34.0 there is yet another solution: declare the YAML version explicitly:

%YAML 1.2
---
name: Run tests

on: [push, pull_request]