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

HDDS-10903. Move sitemap check to Docusaurus build. #94

Merged

Conversation

errose28
Copy link
Contributor

@errose28 errose28 commented May 22, 2024

What changes were proposed in this pull request?

In #93 we bumped Docusaurus to version 3.3.2. By upgrading to the 3.3.x line we can use the new createSitemapItems hook to remove the sitemap GitHub Actions job and make that part of the docusaurus build instead.

Background

We currently have a GitHub actions job that checks the sitemap.xml file generated by the Docusaurus build to make sure that all generated URLs use lowercase kebab-case. Since URLs are either generated from file names or front matter (with slug) and we already have checks for both of those, it is unlikely that an invalid URL format would be generated. The check is still nice to have though, so we can make it lighter weight by plugging it into the Docusaurus build instead.

Code Changes

We use the docusaurus classic theme, which automatically includes the sitemap plugin. The change adds the sitemap hook to the part of the configuration that handles plugin configuration. For example, our docs plugin is configured here as well.

Dev Experience Changes

Anything that would generate a URL in a disallowed format should still be caught by the static checks, and all invalid instances will be listed in a single failure for quicker fixing. If somehow something slips through there, the docusaurus build will now fail when building the sitemap.

The build will abort after the first failure only, and the failure only occurs in a production build (pnpm build), not in development mode (pnpm start or docker compose up). These are limitations with how the hook is implemented and invoked at build time.

What is the link to the Apache Jira?

HDDS-10903

How was this patch tested?

  • CI passes and there is no sitemap job present: before and after
  • A valid sitemap.xml file is still generated as part of the build.
  • With our filename and front matter schema checks I'm not sure its actually possible for this to get hit in CI, it's kind of a fallback safety check.
  • It works in a manual local test by renaming a file or directory with something invalid like test_name and running pnpm build. The build fails and the error message is displayed.

@github-actions github-actions bot added the website-v2 Tasks for the new ozone website targeting the HDDS-9225-website-v2 branch label May 22, 2024
@errose28 errose28 requested a review from adoroszlai May 22, 2024 20:59
@errose28
Copy link
Contributor Author

There's some LLM assisted Javascript in this change. I think it's easy enough to follow but maybe @devabhishekpal or someone else with a little JS familiarity could give it a look too.

Copy link
Contributor

@adoroszlai adoroszlai left a 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 patch.

@adoroszlai adoroszlai merged commit bd4d74a into apache:HDDS-9225-website-v2 May 28, 2024
12 checks passed
@errose28
Copy link
Contributor Author

Thanks for the review @adoroszlai

errose28 added a commit to errose28/ozone-site that referenced this pull request May 30, 2024
* HDDS-9225-website-v2:
  HDDS-10903. Move sitemap check to Docusaurus build. (apache#94)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
website-v2 Tasks for the new ozone website targeting the HDDS-9225-website-v2 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants