example fails yaml validation
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:
- Create a new
labeler.ymlin.github - 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/*' - See error:
Expected behavior: No validation error
Actual behavior: See screenshots
Hello @boneskull Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.
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.
To fix that, a PR should be created in the schemastore repo
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.
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
@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...
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:
That form is part of the tests, so if it's failing, it's not due to the schema.
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
FWIW: This is a PITA
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!
Hi @boneskull !, Just checking in on this issue. Is there any update or anything I can help with? Thank you!
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!
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!