This document describes the Continuous Integration and Continuous Deployment (CI/CD) setup for the Mojo algorithms repository, based on TheAlgorithms organization standards.
The CI/CD pipeline consists of four main workflows that automate repository maintenance, code quality checks, and documentation generation.
Purpose: Automatically maintains the DIRECTORY.md file
Triggers:
- Push to
mainbranch - Pull requests to
mainbranch
Actions:
- Generates an up-to-date list of all
.mojofiles - Organizes them in a hierarchical structure
- Commits changes automatically (on push events)
Benefits:
- No manual maintenance of DIRECTORY.md required
- Always reflects current repository structure
- Improves discoverability of algorithms
Purpose: Ensures DIRECTORY.md stays synchronized with repository structure
Triggers:
- Pull requests to
mainbranch
Actions:
- Generates a fresh DIRECTORY.md
- Compares with existing file
- Fails if differences are found
Benefits:
- Catches outdated documentation before merge
- Enforces consistency
- Provides clear error messages with diffs
Purpose: Enforces code quality and naming conventions
Triggers:
- Push to
mainbranch - Pull requests to
mainbranch
Checks:
- No spaces in filenames
- Lowercase with underscores for
.mojofiles - No trailing whitespace
Benefits:
- Consistent file naming across repository
- Cleaner code
- Prevents common formatting issues
Purpose: Validates all links in markdown files
Triggers:
- Pull requests to
mainbranch - Weekly schedule (Mondays at 00:00 UTC)
Actions:
- Scans all markdown files
- Tests external links
- Reports broken links
Benefits:
- Prevents broken documentation links
- Maintains high documentation quality
- Catches link rot early
Python script that generates the DIRECTORY.md file by:
- Walking through the repository
- Finding all files with specified extensions
- Creating a hierarchical markdown structure
- Formatting filenames into readable titles
Usage:
python3 scripts/build_directory_md.py Mojo . .mojo > DIRECTORY.mdConfigures the link checker with:
- Timeout settings (20s)
- Retry logic (3 attempts)
- Status code validation
- URL pattern ignoring (localhost)
.github/
├── workflows/
│ ├── check_links.yml
│ ├── directory_writer.yml
│ ├── lint.yml
│ ├── verify_directory.yml
│ └── README.md
├── markdown-link-check-config.json
└── CI_SETUP.md (this file)
scripts/
├── build_directory_md.py
└── README.md
DIRECTORY.md (updated)
The workflows use minimal permissions:
directory_writer.yml: Requirescontents: writeto commit changes- Other workflows: Use default read-only permissions
These workflows follow the same patterns used across all TheAlgorithms repositories:
- TheAlgorithms/Python
- TheAlgorithms/Java
- TheAlgorithms/JavaScript
- And 40+ other language repositories
- Test the workflows: Push a commit to trigger the workflows
- Monitor Actions tab: Check that all workflows run successfully
- Add more workflows: Consider adding:
- Mojo syntax checking (when available)
- Performance benchmarking
- Code coverage reporting
- Automated releases
If the directory writer workflow runs but doesn't commit:
- Check that
DIRECTORY.mdactually changed - Verify the workflow has
contents: writepermission - Check the Actions logs for error messages
If the link checker reports false positives:
- Update
.github/markdown-link-check-config.json - Add patterns to
ignorePatterns - Adjust timeout or retry settings
If lint checks fail:
- Review the error messages in Actions logs
- Fix naming conventions (lowercase, underscores)
- Remove trailing whitespace
- Ensure no spaces in filenames
- TheAlgorithms/scripts - Original scripts repository
- GitHub Actions Documentation
- Markdown Link Check Action