This example demonstrates how to use giton in a testing environment with Docker integration. It shows how giton can be integrated into CI/CD pipelines and local development workflows.
cd examples/testing
docker-compose up --build
This will:
# Build the Docker image
docker build -t giton-test .
# Run the container
docker run -it --rm giton-test
# Or run with volume mount for local testing
docker run -it --rm -v $(pwd)/test-repo:/app/test-repo giton-test
examples/testing/
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── test_giton_integration.py # pytest tests
├── sample_project/ # Sample Python project
│ ├── src/
│ │ └── example.py
│ └── tests/
│ └── test_example.py
└── README.md
# Run all tests
docker-compose run app pytest
# Run specific test
docker-compose run app pytest test_giton_integration.py::test_pre_commit_policy
# Run with coverage
docker-compose run app pytest --cov=src
# Install giton
pip install -e ../../../
# Initialize giton in the sample project
cd sample_project
giton init
# Run tests with giton
giton hook pre-commit
pytest
name: Test with Giton
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
container: python:3.13
steps:
- uses: actions/checkout@v3
- name: Install giton
run: pip install giton
- name: Initialize giton
run: giton init
- name: Run giton policies
run: giton policy check pre-commit
- name: Run tests
run: pytest
test:
image: python:3.13
before_script:
- pip install giton
- giton init
script:
- giton policy check pre-commit
- pytest
Create .giton/config.yaml in your repository:
policies:
commit_message:
enabled: true
pattern: "^(feat|fix|docs|style|refactor|test|chore):"
test_coverage:
enabled: true
min_coverage: 80
code_quality:
enabled: true
tools: ["ruff", "mypy"]
Make sure the .git directory is properly mounted and has correct permissions.
Ensure giton is installed in the Docker image or add the source directory to PYTHONPATH.
Verify that .giton/config.yaml exists and is properly formatted.