labeler icon indicating copy to clipboard operation
labeler copied to clipboard

example fails yaml validation

Open boneskull opened this issue 2 years ago • 9 comments

Description:

The example in the README fails YAML schema validation in VSCode

Action version:

v5.0.0

Platform:

  • [x] Ubuntu
  • [ ] macOS
  • [ ] Windows

Runner type:

  • [x] Hosted
  • [ ] Self-hosted

Repro steps:

  1. Create a new labeler.yml in .github
  2. Paste this (from the example):
    # Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
    source:
    - all:
      - changed-files:
        - any-glob-to-any-file: 'src/**/*'
        - all-globs-to-all-files: '!src/docs/*'
    
  3. See error: image image

Expected behavior: No validation error

Actual behavior: See screenshots

boneskull avatar Jan 17 '24 23:01 boneskull

Hello @boneskull Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

HarithaVattikuti avatar Jan 19 '24 03:01 HarithaVattikuti

This seems to be related to the schema published on https://json.schemastore.org/pull-request-labeler.json being out-of-date.

I'm not sure if that's the same one used by VSCode, but I can see the same validation failure in current Jetbrains IDEs, and they automatically fetch the schemas from there.

CRC-Mismatch avatar Jan 31 '24 21:01 CRC-Mismatch

To fix that, a PR should be created in the schemastore repo

boneskull avatar Jan 31 '24 21:01 boneskull

I've written an updated schema that should be available already: https://json.schemastore.org/pull-request-labeler-5.json

I don't know whether VSCode actually uses those schemas though.

QuLogic avatar Feb 07 '24 04:02 QuLogic

I don't know whether VSCode actually uses those schemas though

VSCode itself won't with YAML files, but will do so with an extension, like the Red Hat YAML Extension

hyperupcall avatar Feb 07 '24 18:02 hyperupcall

@QuLogic I think there's still something wrong with that schema... Or maybe with JetBrains' YAML validator. Either way, it's warning that the shorthand <label>: [ { changed-files: [ { ... } ] } ] way is wrong (I've shortened it, but it's using multi-line blocks in my case... image

At least the verbose syntax works OK now (but too bad that I have to add a custom schema mapping to every project in order to use your schema :face_holding_back_tears: )

About VSCode, by itself it only validates the basic YAML syntax (AFAICR, maybe not even that), but it automatically offers "There are extensions in the marketplace for YAML!" the first time you open up one, and the top results will probably all validate using SchemaStore anyway :man_shrugging:

CRC-Mismatch avatar May 29 '24 18:05 CRC-Mismatch

That form is part of the tests, so if it's failing, it's not due to the schema.

QuLogic avatar May 29 '24 19:05 QuLogic

This behavior seems to be a quirk of Intellij. It is solved if in the JSON schema one replaces oneOf with anyOf in the requirements of the Match object schema. Instead of:

      "oneOf": [
        { "required": ["changed-files"] },
        { "required": ["base-branch"] },
        { "required": ["head-branch"] }
      ],

Use:

      "anyOf": [
        { "required": ["changed-files"] },
        { "required": ["base-branch"] },
        { "required": ["head-branch"] }
      ],

There seem to be similar issues with oneOf with some validators, e.g. https://github.com/RicoSuter/NJsonSchema/issues/1596.

Attaching a schema file that works in Intellij, you can add a schema mapping locally until this gets fixed in schemastore.org or in the validator. pull-request-labeler-5-schema.json

spock-yh avatar Aug 24 '24 07:08 spock-yh

FWIW: This is a PITA

freeformz avatar Sep 18 '24 21:09 freeformz

Hi @boneskull , The error shown in the screenshots appears to be triggered by the RedHat YAML extension in VSCode, which applies a generic YAML schema. This schema doesn't account for the custom structure used by GitHub Actions' labeler configuration. Please note that, despite the linter warning, the current configuration is valid for the labeler and should work as expected. If you do experience any issues with the labeler during workflow execution, feel free to share the details, and we’ll be happy to assist further. Thanks!

chiranjib-swain avatar May 28 '25 05:05 chiranjib-swain

Hi @boneskull !, Just checking in on this issue. Is there any update or anything I can help with? Thank you!

chiranjib-swain avatar Jun 05 '25 05:06 chiranjib-swain

Hi @boneskull , just a gentle follow-up on this. We’d appreciate your input or update when you have a moment. Please let us know if you need any further information or assistance. Thank you!

chiranjib-swain avatar Jun 12 '25 06:06 chiranjib-swain

Hi @boneskull ,Since we haven’t received a response after a couple of reminders, we’ll go ahead and close this issue for now. If you need further assistance or have more details to share, please feel free to reopen this issue or start a new one. Thank you!

chiranjib-swain avatar Jun 18 '25 06:06 chiranjib-swain