YamlGuardian
This project uses GitHub Actions for continuous integration. The CI workflow is defined in the .github/workflows/ci.yml
file. It runs tests on every push and pull request to ensure the codebase remains stable.
We have added a new auto-merge feature to our CI workflow. This feature automatically merges pull requests if all CI checks pass. The auto-merge process is handled by the peter-evans/merge
GitHub Action. This ensures that only PRs that pass all checks are merged, maintaining the stability of the codebase.
- Python 3.8 or higher
- Poetry
If you don't have Poetry installed, you can install it using the following command:
curl -sSL https://install.python-poetry.org | python3 -
- Clone the repository:
git clone https://github.com/nobu007/YamlGuardian.git
cd YamlGuardian
- Install the dependencies using Poetry:
poetry install
You can run the tests using the following command:
poetry run python -m unittest discover -s tests
To run the edge case tests, use the following command:
poetry run python -m unittest tests/test_validate.py
To analyze the directory structure and identify necessary changes, run the following script:
poetry run python yamlguardian/directory_analyzer.py
The identified changes will be saved in a CSV file named directory_structure_changes.csv
in the root directory.
To analyze the directory structure and save the changes to a CSV file, use the analyze_and_save_directory_structure
method in YamlGuardian
:
from yamlguardian.core import YamlGuardian
guardian = YamlGuardian(schema_file='path/to/schema.yaml')
guardian.analyze_and_save_directory_structure(root_dir='path/to/root_dir', csv_file='path/to/output.csv')
To run the FastAPI server using uvicorn
, use the following command:
uvicorn main:app --reload
To validate YAML data using the /validate
endpoint, send a POST request to http://127.0.0.1:8000/validate
with the YAML content in the request body. For example:
curl -X POST "http://127.0.0.1:8000/validate" -H "Content-Type: application/json" -d '{"yaml_content": "name: John\nage: 30"}'
If you encounter CI errors, follow these steps to resolve them:
- Check the CI logs: Review the logs in the GitHub Actions tab to identify the cause of the error.
- Common issues:
- Dependency issues: Ensure all dependencies are correctly specified in
pyproject.toml
and runpoetry install
to install them. - Test failures: Run the tests locally using
poetry run python -m unittest discover -s tests
to identify and fix any failing tests. - Linting errors: Ensure your code adheres to the project's linting rules. Run
poetry run flake8
to check for linting errors and fix them accordingly.
- Dependency issues: Ensure all dependencies are correctly specified in
- Re-run the CI workflow: After fixing the issues, push your changes to trigger the CI workflow again.
For detailed design documentation, please refer to the DESIGN.md file.