This module provides Dagger functions for Python CI/CD workflows including linting, testing, security scanning, and Docker image building.
- ✅ Python linting with ruff
- ✅ Format checking with ruff
- ✅ Testing with pytest
- ✅ Test coverage reporting with pytest-cov
- ✅ Security scanning with bandit
- ✅ Docker image building and pushing
- Dagger CLI installed
- Docker runtime available
# Lint Python source code
dagger call -m python lint \
--src tests/python/ \
--progress plain# Check Python code formatting
dagger call -m python format-check \
--src tests/python/ \
--progress plain# Run pytest
dagger call -m python test \
--src tests/python/ \
--progress plain# Run pytest with coverage reporting
dagger call -m python test-with-coverage \
--src tests/python/ \
--coverage-path src/ \
--progress plain# Run bandit security scanner
dagger call -m python security-scan \
--src tests/python/ \
--scan-path src/ \
--progress plain# Build Docker image from Dockerfile
dagger call -m python build-image \
--src tests/python/ \
--progress plain# Build and push to temporary registry (no auth)
dagger call -m python build-and-push-image \
--src tests/python/ \
--image-ref ttl.sh/stuttgart-things/python-test:1h \
--token env:GITHUB_TOKEN \
--progress plain
# Build and push to GitHub Container Registry (with auth)
dagger call -m python build-and-push-image \
--src tests/python/ \
--image-ref ghcr.io/stuttgart-things/python-test:1.0.0 \
--token env:GITHUB_TOKEN \
--username patrick-hermann-sva \
--registry-url ghcr.io \
--progress plain# Run comprehensive tests
task test-pythondagger call -m python lint \
--src "." \
--ruff-version 0.8.6 \
--paths "src/,tests/" \
--progress plaindagger call -m python format-check \
--src "." \
--ruff-version 0.8.6 \
--paths "src/,tests/" \
--progress plaindagger call -m python test \
--src "." \
--python-version 3.12-slim \
--test-path tests/ \
--install-extra ".[dev]" \
--progress plaindagger call -m python test-with-coverage \
--src "." \
--python-version 3.12-slim \
--test-path tests/ \
--coverage-path src/ \
--progress plaindagger call -m python security-scan \
--src "." \
--bandit-version 1.8.3 \
--scan-path src/ \
--progress plaindagger call -m python build-image \
--src "." \
--dockerfile Dockerfile \
--version 1.0.0 \
--progress plaindagger call -m python build-and-push-image \
--src "." \
--image-ref ghcr.io/org/image:tag \
--token env:REGISTRY_TOKEN \
--username env:REGISTRY_USER \
--registry-url ghcr.io \
--progress plainSee the main README for detailed usage examples.
task test-python