Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authoring tools: templates & template packages validation #2623

Open
vlada-shubina opened this issue Nov 3, 2020 · 5 comments
Open

Authoring tools: templates & template packages validation #2623

vlada-shubina opened this issue Nov 3, 2020 · 5 comments
Labels
area: authoring tools Related to authoring tools Cost:L Work that requires one engineer up to 4 weeks Priority:2 Work that is important, but not critical for the release triaged The issue was evaluated by the triage team, placed on correct area, next action defined. User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@vlada-shubina
Copy link
Member

vlada-shubina commented Nov 3, 2020

As a template author, I want a way to validate the templates, so that I can validate template before the publish.
Audience: template authors

Background

The template configuration requires manual editing in of JSON configuration which is source of authoring mistakes.
The configuration involves a lot of conditions, which are not validated in any way until the template is being generated.
When grouping the templates the configuration is manually, and requires careful combination of the fields across multiple JSON files. The grouping errors are shown only when the template is being run (not when the package containing it is installed)

Planned validation checks:

(note: though some of the issues are closed, their comments contain suggested validation check)

Justification

  • decrease the number of issues when authoring 1st party templates and detecting them post PR/even releasing them
  • improve easiness of authoring and quality of 3rd party templates; detect potential issues prior to testing
  • improve UX for final users by not allowing to install invalid templates / warning about possible issues

Technical details

We plan to expose 2 ways:

As part of this task, the validation in template engine and dotnet new should be improved as well.

  • when reading the template, the generator should ensure it has a minimum required set of information in order to proceed. The JSON parsing errors and basic errors and warnings should be exposed.
  • when installing the template, the conflicts should be detected
  • the host should be able to inject the checks for host.json file.
  • the way to present the errors should be potentially implemented in host itself

Feedback from @sayedihashimi

  • Templates shouldn’t have to be installed in order to be validated
    • More specifically be able to pass in a folder path or a path to .nupkg file
  • The tool should accept multiple values for folder path/path to .nupkg
    • For authors that have developed several templates this would be helpful
  • After running the tool it should return a non-zero exit code if the validation is not successful
    • This will enable users to script the validate step, and be able to fail the CI build if so
  • Error and warning messages should follow the MSBuild error/warning format so that errors/warnings should be auto-detected if a user executes the tool via an MSBuild file.
    • The MSBuild team may know of any formal docs.
    • MSBuild book
@vlada-shubina vlada-shubina added the Epic Groups multiple user stories. Can be grouped under a theme. label Nov 3, 2020
@AR-May AR-May added need-pm-discussion Need agreement from PM that the issue aligns to targeted stories for any of the next 2 releases triaged The issue was evaluated by the triage team, placed on correct area, next action defined. labels Nov 9, 2020
@donJoseLuis donJoseLuis added Cost:L Work that requires one engineer up to 4 weeks parent:1240298 Priority:3 Work that is nice to have User Story A single user-facing feature. Can be grouped under an epic. and removed Epic Groups multiple user stories. Can be grouped under a theme. labels Dec 19, 2020
@donJoseLuis donJoseLuis changed the title --validate option for dotnet new for template definition validation As a customer, I want A new --validate option, so that I can validate template definitions Dec 19, 2020
@donJoseLuis donJoseLuis changed the title As a customer, I want A new --validate option, so that I can validate template definitions As a customer, I want a new validate option, so that I can validate template definitions Dec 19, 2020
@vlada-shubina vlada-shubina removed the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Apr 13, 2021
@KathleenDollard KathleenDollard added the need-discussion Requires internal discussion prior to answering in an issue. label Apr 13, 2021
@KathleenDollard
Copy link

How does this fit in with @sayedihashimi 's tool?

@KathleenDollard
Copy link

One of the things we should validate for is the use of parens around complex conditions as discussed in #2209

@sayedihashimi
Copy link
Member

How does this fit in with @sayedihashimi 's tool?

I think the idea is to have some similar validation, but it's built into dotnet new instead of a stand alone tool.

The tool should accept multiple values for folder path/path to .nupkg

This is good, but in addition to this I think that when a folder path is specified, the tool should search the folder recursively for all templates. If a user is authoring a template pack (i.e. AWS/Uno/etc) they can pass the root folder to the validator and then it will discover all the templates that the folder contains.

@jzabroski
Copy link

I am cool with your thought process, @KathleenDollard . Seems worth the story points vs the other discussion.

@vlada-shubina vlada-shubina removed need-discussion Requires internal discussion prior to answering in an issue. need-pm-discussion Need agreement from PM that the issue aligns to targeted stories for any of the next 2 releases labels Apr 20, 2021
@vlada-shubina vlada-shubina added this to the Backlog milestone May 17, 2021
@vlada-shubina vlada-shubina added the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label May 17, 2021
@vlada-shubina vlada-shubina added the Epic Groups multiple user stories. Can be grouped under a theme. label Jun 14, 2021
@vlada-shubina vlada-shubina changed the title As a customer, I want a new validate option, so that I can validate template definitions [Epic] Templates validation Jul 27, 2021
@vlada-shubina vlada-shubina removed the Epic Groups multiple user stories. Can be grouped under a theme. label Jul 27, 2021
@vlada-shubina vlada-shubina changed the title [Epic] Templates validation [Epic] Authoring tools: templates and template packages validation Dec 2, 2022
@donJoseLuis donJoseLuis changed the title [Epic] Authoring tools: templates and template packages validation Authoring tools: templates and template packages validation Jan 5, 2023
@donJoseLuis donJoseLuis changed the title Authoring tools: templates and template packages validation Authoring tools: templates & template packages validation Jan 5, 2023
@donJoseLuis donJoseLuis added 8.0 Priority:2 Work that is important, but not critical for the release and removed Priority:3 Work that is nice to have labels Feb 6, 2023
@donJoseLuis donJoseLuis removed the 8.0 label Mar 13, 2023
@YuliiaKovalova YuliiaKovalova added area: authoring tools Related to authoring tools and removed Needs-grooming labels May 16, 2023
@vlada-shubina vlada-shubina self-assigned this Jun 6, 2023
@vlada-shubina
Copy link
Member Author

The following was already done:

  • Component-based template validation PoC  #5838 - validation infrastructure was implemented. Validation checks can be inserted via components (ITemplateValidator and ITemplateValidatorFactory implementations). Existing checks were reimplemented in this infrastructure. ITemplateValidator and ITemplateValidatorFactory are currently internal but ready to be made public once the feature is fully ready for release.
  • validate CLI command #5839 - validation was added to authoring tools CLI (via validate command) with no additional checks at the moment. It is possible to add additional checks by implementing ITemplateValidator and ITemplateValidatorFactory interfaces, adding them as additional component when loading host.
  • MSBuild ValidateTemplates task PoC #5840 - validation was added as MSBuild task (Validate) with no additional checks at the moment.

The following tasks remain:

  • implementing additional validation checks (see planned checks list in issue description)
  • making interfaces public to allow extensibility by tools/hosts
  • implementing checks in hosts, in particular for host.json configuration
  • updating documentation and authoring tools guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: authoring tools Related to authoring tools Cost:L Work that requires one engineer up to 4 weeks Priority:2 Work that is important, but not critical for the release triaged The issue was evaluated by the triage team, placed on correct area, next action defined. User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

7 participants