mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-12 01:09:02 +00:00
(#13274) linters: Add annotations for YAML lint + add schema verification for config.yml
and conandata.yml
* first attempt at a yaml linter wit github actions output * This is less strict but has more information * fixup message * run config linter in Action * better ux feedback * try to use newlines https://github.com/actions/toolkit/issues/193#issuecomment-605394935 * clean up * fixup file name * trying custom class for quoted str * underlying yaml parser does not keep quotes * trying to catch ints as problems * remove test code * and to "linter testing" * install deps * run new linter unconditionally * revert testing changes * new script for conandata (this one is much harder to spec) * debugging * lets see all the errors * yamale -s ../linter/config_yaml_schema.yml aaf/config.yml from linters folder as a test * adjust script to match meeting discussion * make sure the docs and linters match * fix link * Update conandata.yml * exit 1 is not needed with annotations * add annotation matchers for yaml since those do do much * fix search for type * fix whitespace * tryout a yamllint file with a better looking matcher * copy syntax from readme * test if it's running in the wrong dir 🤔 * try with debug output * bump since i dont have permissions * bump - dont glob star * bump * less star globs * also add action to conandata way * bump * drop action for cli + matcher * more docs around linters * fix file and name * cleanup
This commit is contained in:
@@ -124,6 +124,52 @@ It is possible to run the linter locally the same way it is being run [using Git
|
||||
pylint --rcfile=linter/pylintrc_testpackage recipes/fmt/all/test_package/conanfile.py
|
||||
```
|
||||
|
||||
## Running the YAML Linters
|
||||
|
||||
There's two levels of YAML validation, first is syntax and the second is schema.
|
||||
The style rules are located in [`linter/yamllint_rules.yml`](../linter/yamllint_rules.yml) and are used to ensure consistence.
|
||||
The [`config.yml](how_to_add_packages.md#configyml) is required for the build infrastructure and the
|
||||
[`conandata.yml` patch fields](conandata_yml_format.md#patches-fields) have required elements that are enforced with
|
||||
schema validation. There's are to encourage the best possible quality of recipes and make reviewing faster.
|
||||
|
||||
### Yamllint
|
||||
|
||||
* (Recommended) Use a dedicated Python virtualenv.
|
||||
* Ensure you have required tools installed: `yamllint` (better to uses fixed versions)
|
||||
|
||||
```sh
|
||||
pip install yamllint==1.28
|
||||
```
|
||||
|
||||
* Now you just need to execute the `yamllint` commands:
|
||||
|
||||
```sh
|
||||
# Lint a recipe:
|
||||
yamllint --config-file linter/yamllint_rules.yml -f standard recipes/fmt/all/conanfile.py
|
||||
|
||||
# Lint the test_package (same command)
|
||||
yamllint --config-file linter/yamllint_rules.yml -f standard recipes/fmt/all/test_package/conanfile.py
|
||||
```
|
||||
|
||||
### Yamlschema
|
||||
|
||||
* (Recommended) Use a dedicated Python virtualenv.
|
||||
* Ensure you have required tools installed: `strictyaml` and `argparse` (better to uses fixed versions)
|
||||
|
||||
```sh
|
||||
pip install strictyaml==1.16 argparse==1.4
|
||||
```
|
||||
|
||||
* Now you just need to execute the validation scripts:
|
||||
|
||||
```sh
|
||||
# Lint a config.yml:
|
||||
python3 linter/config_yaml_linter.py recipes/fmt/config.yml
|
||||
|
||||
# Lint a conandata.yml
|
||||
python3 linter/conandata_yaml_linter.py recipes/fmt/all/conandata.yml
|
||||
```
|
||||
|
||||
## Testing the different `test_*_package`
|
||||
|
||||
This can be selected when calling `conan create` or separately with `conan test`
|
||||
|
Reference in New Issue
Block a user