aws-greengrass / aws-greengrass-gdk-cli

The Greengrass Development Kit - Command Line Interface (GDK CLI) is a tool that helps you create Greengrass V2 components either using templates or community repositories.
https://docs.aws.amazon.com/greengrass/v2/developerguide/greengrass-development-kit-cli.html
Apache License 2.0
28 stars 19 forks source link

feat: add recipe validation to build and publish commands #259

Closed patrzhan closed 11 months ago

patrzhan commented 11 months ago

Issue #, if available:

Description of changes: Adds the Greengrass recipe schema to GDK. This is temporary until a more permanent solution to pull the schema down from a cloud source is added.

Add recipe schema validation to the component build and component publish commands. These will compare the project recipe file against the included Greengrass recipe schema and stop the command and produce a ValidationError if the recipe does not validate against the schema.

Why is this change necessary: Validating component recipes against the schema is a planned feature and allows users of GDK to identify issues with their recipes earlier in the development process.

How was this change tested: Manually tested. Added unit/integration tests for the additions.

Any additional information or context required to review the change: Output of the build/publish commands may change depending on the cloud api implementation of schema validation. If changes need to be this output may be changed in a future PR.

Checklist:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov[bot] commented 11 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (153051a) 98.04% compared to head (4590dd5) 97.87%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## development #259 +/- ## =============================================== - Coverage 98.04% 97.87% -0.17% =============================================== Files 47 48 +1 Lines 1838 1885 +47 =============================================== + Hits 1802 1845 +43 - Misses 36 40 +4 ``` | [Flag](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass) | Coverage Δ | | |---|---|---| | [integ](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass) | `80.74% <91.83%> (+0.27%)` | :arrow_up: | | [uat](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass) | `70.76% <83.67%> (+0.25%)` | :arrow_up: | | [unit](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass) | `93.95% <83.67%> (-0.29%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass) | Coverage Δ | | |---|---|---| | [gdk/common/RecipeValidator.py](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#diff-Z2RrL2NvbW1vbi9SZWNpcGVWYWxpZGF0b3IucHk=) | `100.00% <100.00%> (ø)` | | | [gdk/common/consts.py](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#diff-Z2RrL2NvbW1vbi9jb25zdHMucHk=) | `100.00% <100.00%> (ø)` | | | [gdk/common/exceptions/error\_messages.py](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#diff-Z2RrL2NvbW1vbi9leGNlcHRpb25zL2Vycm9yX21lc3NhZ2VzLnB5) | `100.00% <100.00%> (ø)` | | | [...ds/component/transformer/BuildRecipeTransformer.py](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#diff-Z2RrL2NvbW1hbmRzL2NvbXBvbmVudC90cmFuc2Zvcm1lci9CdWlsZFJlY2lwZVRyYW5zZm9ybWVyLnB5) | `96.47% <83.33%> (-2.18%)` | :arrow_down: | | [.../component/transformer/PublishRecipeTransformer.py](https://app.codecov.io/gh/aws-greengrass/aws-greengrass-gdk-cli/pull/259?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-greengrass#diff-Z2RrL2NvbW1hbmRzL2NvbXBvbmVudC90cmFuc2Zvcm1lci9QdWJsaXNoUmVjaXBlVHJhbnNmb3JtZXIucHk=) | `97.01% <83.33%> (-2.99%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.