You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Validation of patterns against pattern template syntax #159
It could be helpful to validation patterns against the Pattern Template for various reasons:
bring existing patterns to a more consistent format, which helps us with the preparation for the creation of the ebook
help new contributors by validating their pattern contributions, and pointing them to specifics parts of the Pattern Template that they missed
Validation ideas
all mandatory headlines/sections are present
the top level headlines of the pattern all use ## (h2) (i.e. no #)
no duplicate headlines/sections exist
headlines/sections are in a certain order
no headlines/sections exist that are not part of the pattern template
Risks/Questions:
the validations could be frustrating or discouraging for new contributors. however if we do it right, the validations could help them to understand the pattern format.
what to do with sections where the headline is present but then there is actually no text filled into that section?
As many of the existing patterns contain optional headlines as well as custom headlines, we will likely have to write custom validation rules. I have already tried this out and it looks manageable. (see experimental code).
My current suggestion would be to validate rules 1-4 above, but don't validate rule 5.
The GitHub action generates emails if the linter fails. However the email itself does not contain the info about what exactly failed. So one has to click through to the GitHub repo to figure out what went wrong. That isn't very helpful :)
Example screenshot of the emails that get generated if the linter fails:
I have created a version of these checks that is very lax (on purpose).
When run against all existing patterns, it mostly finds these things:
patterns that are using # instead of ## for the headlines
differences in spelling for Author/Authors/Author(s) and Solution/Solutions
I think we can live with the difference in Author/Solution spelling for now. Will try to create a linter that accepts all different versions of that spelling.
See full output of the current linter below.
$ markdownlint -c lint/pattern-template.yml -r lint/pattern-template.js -i README.md -i TRUSTED-COMMITTERS.md -i CONTRIBUTING.md *.md
30-day-warranty.md:1 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Title"]
30-day-warranty.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Title" is missing. Required headline "Patlet" is missing. Required headline "Problem" is missing. Required headline "Context" is missing. Required headline "Forces" is missing. Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Status" is missing. Required headline "Author(s)" is missing.]
30-day-warranty.md:5 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Context"]
30-day-warranty.md:11 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Problem"]
30-day-warranty.md:15 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Forces"]
30-day-warranty.md:41 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Solution"]
30-day-warranty.md:51 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Resulting Context"]
30-day-warranty.md:58 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Known Instances"]
30-day-warranty.md:62 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Authors"]
30-day-warranty.md:66 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Acknowledgement"]
30-day-warranty.md:73 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Status"]
30-day-warranty.md:79 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Variants"]
bad-weather-for-liftoff.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing.]
change-the-developers-mindset.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
common-requirements.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
contracted-contributor.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
crossteam-project-valuation.md:1 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Title"]
crossteam-project-valuation.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Title" is missing. Required headline "Patlet" is missing. Required headline "Problem" is missing. Required headline "Context" is missing. Required headline "Forces" is missing. Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Status" is missing. Required headline "Author(s)" is missing.]
crossteam-project-valuation.md:5 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Patlet"]
dedicated-community-leader.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
developer-incentive-alignment-for-innersource-contribution.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
discover-your-innersource.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Patlet" is missing. Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
improve-findability.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Author(s)" is missing.]
introducing-metrics-in-innersource.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Status" is missing. Required headline "Author(s)" is missing.]
junkyard-styled-innersourcing.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Patlet" is missing. Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Author(s)" is missing.]
modular-code.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Author(s)" is missing.]
overcome-acquisition-based-silos-developer.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
overcome-acquisition-based-silos-manager.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
review-committee.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
share-your-code-to-get-more-done.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
shared-code-repo-different-from-build-repo.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
start-as-experiment.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Solutions" is missing. Required headline "Author(s)" is missing.]
I built a version that accepts multiple different spellings of Author/Solution.
The linter now complains about a much smaller number of issues.
$ markdownlint -c lint/pattern-template.yml -r lint/pattern-template.js --ignore-path lint/.markdownlintignore *.md
30-day-warranty.md:1 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Title"]
30-day-warranty.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Title" is missing. Required headline "Patlet" is missing. Required headline "Problem" is missing. Required headline "Context" is missing. Required headline "Forces" is missing. Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Status" is missing. Required headline "Author(s)" is missing.]
30-day-warranty.md:5 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Context"]
30-day-warranty.md:11 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Problem"]
30-day-warranty.md:15 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Forces"]
30-day-warranty.md:41 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Solution"]
30-day-warranty.md:51 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Resulting Context"]
30-day-warranty.md:58 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Known Instances"]
30-day-warranty.md:62 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Authors"]
30-day-warranty.md:66 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Acknowledgement"]
30-day-warranty.md:73 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Status"]
30-day-warranty.md:79 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Variants"]
change-the-developers-mindset.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Author(s)" is missing.]
crossteam-project-valuation.md:1 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Title"]
crossteam-project-valuation.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Title" is missing. Required headline "Patlet" is missing. Required headline "Problem" is missing. Required headline "Context" is missing. Required headline "Forces" is missing. Required headline "Solutions" is missing. Required headline "Resulting Context" is missing. Required headline "Status" is missing. Required headline "Author(s)" is missing.]
crossteam-project-valuation.md:5 PATTERN-TEMPLATE-RULE-001 No h1 headlines [Use of #-headlines (h1) is not allowed in patterns] [Context: "# Patlet"]
discover-your-innersource.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Patlet" is missing.]
improve-findability.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Resulting Context" is missing.]
introducing-metrics-in-innersource.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Status" is missing.]
junkyard-styled-innersourcing.md:1 PATTERN-TEMPLATE-RULE-003 Mandatory template sections [Required headline "Patlet" is missing. Required headline "Resulting Context" is missing.]
Especially the issues where a Patlet is missing will take some time to fix. Writing the Patlets requires to read and condense the whole pattern in a 2-sentence structure. Also getting the PRs for those fixes merged will take some time, as we want to make sure that the Patlet represents the pattern correctly.
In the next days I will send a PR with the code for the custom markdownlinter rules that I use to validate the pattern syntax as shown above.
Activity
spier commentedon May 4, 2020
The validation results could look similar to this
spier commentedon May 5, 2020
The GitHub action generates emails if the linter fails. However the email itself does not contain the info about what exactly failed. So one has to click through to the GitHub repo to figure out what went wrong. That isn't very helpful :)
Example screenshot of the emails that get generated if the linter fails:
spier commentedon May 5, 2020
I have created a version of these checks that is very lax (on purpose).
When run against all existing patterns, it mostly finds these things:
#instead of##for the headlinesAuthor/Authors/Author(s)andSolution/SolutionsI think we can live with the difference in Author/Solution spelling for now. Will try to create a linter that accepts all different versions of that spelling.
See full output of the current linter below.
spier commentedon May 5, 2020
I built a version that accepts multiple different spellings of Author/Solution.
The linter now complains about a much smaller number of issues.
I have not been able to run this correctly as a GitHub Action yet. So far the linter also validates files like
README.mdwhich is not very useful. Not sure if you can see that, but the output of the GitHub action is visible here on my fork: https://github.com/spier/InnerSourcePatterns/runs/645897295?check_suite_focus=truespier commentedon May 8, 2020
After some quick fixes to two patterns, the outstanding things that the linter complains about are:
spier commentedon May 8, 2020
Especially the issues where a Patlet is missing will take some time to fix. Writing the Patlets requires to read and condense the whole pattern in a 2-sentence structure. Also getting the PRs for those fixes merged will take some time, as we want to make sure that the Patlet represents the pattern correctly.
In the next days I will send a PR with the code for the custom markdownlinter rules that I use to validate the pattern syntax as shown above.
spier commentedon May 10, 2020
This work-in-progress PR shows how the markdown validations would look like in a PR.
https://github.com/InnerSourceCommons/InnerSourcePatterns/pull/168/files#diff-ebf8d058832d99bac8c6533c359a50c5
spier commentedon Jan 29, 2021
This has been implemented in #257. Closing issue.