A Flask web application with automatic dependency updates using GitHub Dependabot. This project demonstrates how to set up automated dependency management for Python applications.
- Flask Web Application: RESTful API with user management
- Automatic Dependency Updates: Daily dependency scanning and PR creation via Dependabot
- Database Integration: SQLAlchemy with Flask-Migrate for database management
- Testing: Comprehensive test suite with pytest
- Code Quality: Black formatting, flake8 linting, and safety checks
- Python 3.11+
- pip
- Git
-
Clone the repository
git clone https://github.com/DevSecCube/dependabot-automatic-pr.git cd dependabot-automatic-pr -
Create and activate virtual environment
python -m venv .venv # On Windows .venv\Scripts\activate # On macOS/Linux source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Install development dependencies
pip install -r requirements-dev.txt
-
Set environment variables (optional)
# Default uses SQLite database export DATABASE_URL="sqlite:///app.db"
-
Initialize the database
flask db init flask db migrate -m "Initial migration" flask db upgrade -
Run the application
flask run
The application will be available at http://localhost:5000
GET /health- Health check endpointGET /users- Retrieve all usersPOST /users- Create a new user (requires email in JSON body)
# Health check
curl http://localhost:5000/health
# Create a user
curl -X POST http://localhost:5000/users \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'
# Get all users
curl http://localhost:5000/usersRun the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run with verbose output
pytest -v-
Black: Code formatting
black app/ tests/
-
Flake8: Linting
flake8 app/ tests/
-
Safety: Security vulnerability scanning
safety check
# Create a new migration
flask db migrate -m "Description of changes"
# Apply migrations
flask db upgrade
# Rollback migrations
flask db downgradeThis project includes automatic dependency updates via GitHub Dependabot. The configuration (.github/dependabot.yml) is set to:
- Package Ecosystem: pip (Python)
- Schedule: Daily updates
- Scope: Direct and indirect dependencies
- PR Limit: Maximum 10 open pull requests
Dependabot will automatically:
- Check for outdated dependencies daily
- Create pull requests with updates
- Include changelog information
- Run tests to ensure compatibility
dependabot-automatic-pr/
โโโ app/ # Application package
โ โโโ __init__.py # Flask app factory
โ โโโ routes.py # API endpoints
โโโ .github/ # GitHub configuration
โ โโโ workflows/ # GitHub Actions
โ โโโ dependabot.yml # Dependabot configuration
โโโ tests/ # Test suite
โ โโโ test_app.py # Application tests
โโโ requirements.txt # Production dependencies
โโโ requirements-dev.txt # Development dependencies
โโโ README.md # This file| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
sqlite:///app.db |
Database connection string |
FLASK_ENV |
development |
Flask environment |
This project is licensed under the terms specified in the LICENSE file.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request