-
Notifications
You must be signed in to change notification settings - Fork 33
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
HDDS-9866. Add GitHub Actions checks for consistent Docusaurus formatting. #84
HDDS-9866. Add GitHub Actions checks for consistent Docusaurus formatting. #84
Conversation
* HDDS-9225-website-v2: HDDS-10254. Add GitHub Actions check for Markdown style. (apache#81) HDDS-10349. Add GitHub Actions check for consistent file name formatting. (apache#79) HDDS-10426. Crop ozone-logo.svg to a proper size (apache#80) HDDS-10353. Add GitHub Actions check of all generated URLs in the sitemap. (apache#77)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @errose28 for the improvement.
for child in $(find "$root"/docs/*); do | ||
if [ -d "$child" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think reduce iterations by using -type d
as in find "$root"/docs -type d
Thanks for the review @adoroszlai. I'll implement your suggestion in HDDS-10506. |
* HDDS-9225-website-v2: HDDS-10351. Add GitHub Actions check for yaml formatting (apache#87) HDDS-9567. Add GitHub Actions license header check for relevant files. (apache#86) HDDS-10506. Reduce directory iterations in sidebar check (apache#85) HDDS-9866. Add GitHub Actions checks for consistent Docusaurus formatting. (apache#84)
* HDDS-9225-website-v2: Bump docusaurus to 3.3.2 (apache#93) HDDS-10667. Improvements to spelling checks. (apache#89) HDDS-10698. Bump skywalking-eyes to v0.6.0 (apache#90) HDDS-10449. Add quick start to the top of contributing guide. (apache#83) HDDS-10351. Add GitHub Actions check for yaml formatting (apache#87) HDDS-9567. Add GitHub Actions license header check for relevant files. (apache#86) HDDS-10506. Reduce directory iterations in sidebar check (apache#85) HDDS-9866. Add GitHub Actions checks for consistent Docusaurus formatting. (apache#84) HDDS-10254. Add GitHub Actions check for Markdown style. (apache#81) HDDS-10349. Add GitHub Actions check for consistent file name formatting. (apache#79) HDDS-10426. Crop ozone-logo.svg to a proper size (apache#80) HDDS-10353. Add GitHub Actions check of all generated URLs in the sitemap. (apache#77) HDDS-9868. Add GitHub Actions check for spelling. (apache#76) HDDS-10400. Fix event condition in website publish workflow (apache#78) HDDS-10352. Add GitHub Actions workflow to build and run the website. (apache#74) HDDS-10222. Add pnpm guide to contributing guide. (apache#64) HDDS-10313. Update "Redundant" to "Reliable" in new website. (apache#73)
What changes were proposed in this pull request?
Use JSON schema (which also validates YAML) to enforce requirements for markdown front matter and
_category_.yml
sidebar config files in each directory. The current set of requirements is based on my observations while building the initial skeleton site. Further requirements can be added and enforced later if we choose (for example, require every page to have atags
field).These checks will help us keep tens of sidebar categories and hundreds of markdown docs consistent, unlike the previous site where every page had a random assortment of front matter with no guidance on what was required.
Implementation
Ajv is used to do the schema validation for front matter and category files.
_category_.yml
files are passed to avj-cli by a shell script for validation. This prints all errors at once.My initial approach for front matter was extracting it from the markdown with
yq
and then passing each one individually toajv
. That turned out to be very slow (about 1 minute for every hundred pages), so instead I used the ajv JavaScript library to plug into the docusaurus build similar to this example in the docs. This runs very fast, but with a few tradeoffs:I haven't come up with a better way to do the front matter validation, so I think these trade-offs are okay for now.
What is the link to the Apache Jira?
HDDS-9866
How was this patch tested?
I created a branch off of this one on my fork and tested a few failing runs:
slug
to define a URL different than its file nametitle
in the front matter_category_.yml
sidebar config file_category_.yml
sidebar config file with an extra field_category_.yml
sidebar config file missing a label