Automate Docs: Auto-Fixing Workflow For Easy Updates
Hey everyone! Let's talk about making our documentation process way smoother. This is a proposal to add an automatic fix job to our docs.yml workflow. This will tackle common errors, making sure our docs are always on point. This new approach will eliminate the need for manual fixes. Ready to dive in?
The Problem: Manual Doc Fixes are a Pain
Currently, our docs.yml workflow has a cool validation job that sniffs out errors in our documentation. That's awesome, but here's the kicker: it requires a human to jump in and manually fix those errors. This means more work for you and me, and it can slow down the whole documentation process. We've all been there, right? You're cruising along, making updates, and then BAM! Validation errors. Then you have to switch gears, figure out the problem, and manually fix it. It's time-consuming, and let's be honest, it's not the most fun part of the job. Luckily, we have a solution that is already working successfully in our auctionomy-app project.
Imagine a world where these common issues are automatically resolved. That's the dream, and we can make it a reality. Our goal is to streamline the documentation process. The current system requires manual effort. This isn't efficient, especially in a fast-paced project. It's time to automate and make our lives easier.
Proposed Solution: Auto-Fix Job to the Rescue
The plan is to add an autofix job to our docs.yml workflow. This job will spring into action when the validation job fails on a pull request (PR). Here's how it will work:
- Trigger on Validation Failure: The
autofixjob kicks off when the validation job indocs.ymlflags an error on a PR. The job will only run if there are errors. - Parse the Report: It will read the validation report from the PR comments. Think of it as the job understanding what needs to be fixed. It'll extract all the errors, such as missing frontmatter, titles, or descriptions.
- Automatic Fixes: Here comes the magic! The
autofixjob will automatically fix common issues, like missing frontmatter blocks, missingtitlefields, and missingdescriptionfields.-
Missing Frontmatter: The job will add a complete frontmatter block like this:
---
-
title: ... description: ...
```
* **Missing Title**: It will derive the `title` from the filename (e.g., `my-cool-document.md` becomes `My Cool Document`).
* **Missing Description**: The `description` will be generated using the path and title.
- Commit and Push: The job will commit the fixes and push them to the PR branch. It'll update the branch directly.
- Safeguards: To prevent any weirdness, there will be safeguards in place:
- Iteration Limit: The job will run a maximum of two iterations to avoid getting stuck in an infinite loop.
- Skip Bot PRs: It will skip PRs created by bots to prevent any unexpected loops.
- Verify Fixes: The fixes will be validated to ensure they pass validation before committing. So the fixes are correct.
This approach will automate many of the repetitive aspects of documentation, improving efficiency.
Evidence: Auctionomy-App as a Guiding Star
We're not just pulling this out of thin air, guys. This pattern has already been proven in the auctionomy-app project's docs-autofix.yml workflow. This workflow uses a similar approach:
- It uses a
workflow_runtrigger that activates when the validation fails. - It's built on Python for parsing and applying fixes. Python is known for its versatility.
- It smartly derives titles and descriptions from paths. This automated process minimizes manual input.
- It has iteration limits for safety. Limiting iterations prevents any loops.
- It adds PR comments to explain what was fixed. This means you know what happened.
We're essentially taking a page from their playbook and adapting it to our needs. This workflow is already up and running in a similar project. It's been tried, tested, and proven to work effectively. We're not reinventing the wheel here; we're refining and applying a solution that has already worked. This workflow has been carefully designed and implemented. It's designed to streamline the documentation process.
What We Need to Achieve (Acceptance Criteria)
To make this a reality, we need to achieve the following:
- Add the
autofixjob todocs.ymland set it up with aworkflow_runtrigger. The trigger will be when the validation job fails. - Parse the validation report from PR comments to identify issues that can be fixed. The job will know what to fix.
- Automatically fix missing frontmatter by adding a complete block (as mentioned above). Frontmatter is key!
- Automatically fix missing titles by deriving them from the filename. The titles must be descriptive.
- Automatically fix missing descriptions, deriving them from the path and title. The description will provide context.
- Verify that the fixes pass validation before committing any changes. This ensures that the fixes are correct.
- Include an iteration limit to prevent infinite loops (max of two attempts). The safety net is important.
- Skip bot-created PRs to prevent any potential loops. We don't want the bots to get stuck.
- Add helpful PR comments explaining what fixes have been applied. The comments keep everyone informed.
These acceptance criteria outline the specific steps necessary to implement the auto-fix job. The key is to ensure the job addresses all the major issues.
Implementation Notes: Diving into the Fix Logic
Let's get into the nitty-gritty of how the fixing will work. The core fix logic will revolve around these scenarios:
missing_frontmatter: When frontmatter is missing, the job will add a complete block. This ensures that the necessary metadata is present at the beginning of the document. The frontmatter block is essential for the documentation.missing_title: If thetitlefield is missing, the job will insert it, deriving it from the filename. This will ensure that each document has a title. The title needs to reflect the content.missing_description: When thedescriptionfield is missing, the job will insert it. The job will generate it using a combination of the title and category. The description will provide a brief summary.
This fix logic is designed to be comprehensive. It covers the common issues that can occur in documentation. It automatically resolves the most common issues.
Upstreamed from auctionomy-app workflow consolidation