A simple yet powerful REST API for managing tasks, built with FastAPI and deployed using GitHub Actions.
- Full CRUD operations for tasks
- Status-based filtering (pending, in_progress, completed)
- Input validation with Pydantic models
- Comprehensive testing with pytest
- Docker containerization
- CI/CD pipeline with GitHub Actions
- Automatic deployment to Azure
- Health check endpoint for monitoring
GET /- API informationGET /health- Health checkGET /tasks- Get all tasksPOST /tasks- Create a new taskGET /tasks/{id}- Get task by IDPUT /tasks/{id}- Update taskDELETE /tasks/{id}- Delete taskGET /tasks/status/{status}- Get tasks by status
- Python 3.9+
- pip
# Clone the repository
git clone https://github.com/yourusername/python-task-api.git
cd python-task-api
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run the application
uvicorn app.main:app --reload
# The API will be available at http://localhost:8000
# Interactive docs at http://localhost:8000/docs# Run tests
pytest
# Run tests with coverage
pytest --cov=app --cov-report=html
# Run linting
flake8 app tests
black --check app tests
# Security scan
bandit -r app# Build image
docker build -t task-api .
# Run container
docker run -p 8000:8000 task-apiThis project uses GitHub Actions for CI/CD:
- Push to main branch triggers the pipeline
- Tests run on multiple Python versions
- Code quality checks (linting, formatting, security)
- Docker image built and pushed
- Automatic deployment to Azure App Service
python-task-api/
├── .github/workflows/ # GitHub Actions CI/CD
├── app/ # Application code
│ ├── main.py # FastAPI app
│ ├── models.py # Pydantic models
│ └── database.py # Database layer
├── tests/ # Test suite
├── requirements.txt # Dependencies
├── Dockerfile # Container definition
└── README.md # This file
Set these secrets in your GitHub repository:
AZURE_WEBAPP_PUBLISH_PROFILE- For Azure deployment
- Health check:
GET /health - Logs available in Azure App Service
- Test coverage reports in GitHub Actions
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and ensure they pass
- Submit a pull request
This project is licensed under the MIT License.