Some checks failed
Security & Dependency Updates / Dependency Security Scan (push) Successful in 29s
Security & Dependency Updates / Docker Security Scan (push) Failing after 53s
Security & Dependency Updates / License Compliance (push) Successful in 13s
Security & Dependency Updates / Check for Dependency Updates (push) Successful in 19s
Security & Dependency Updates / Code Quality Metrics (push) Successful in 11s
Security & Dependency Updates / Security Summary (push) Successful in 7s
Features: - Real-time water level monitoring for Ping River Basin (16 stations) - Coverage from Chiang Dao to Nakhon Sawan in Northern Thailand - FastAPI web interface with interactive dashboard and station management - Multi-database support (SQLite, MySQL, PostgreSQL, InfluxDB, VictoriaMetrics) - Comprehensive monitoring with health checks and metrics collection - Docker deployment with Grafana integration - Production-ready architecture with enterprise-grade observability CI/CD & Automation: - Complete Gitea Actions workflows for CI/CD, security, and releases - Multi-Python version testing (3.9-3.12) - Multi-architecture Docker builds (amd64, arm64) - Daily security scanning and dependency monitoring - Automated documentation generation - Performance testing and validation Production Ready: - Type safety with Pydantic models and comprehensive type hints - Data validation layer with range checking and error handling - Rate limiting and request tracking for API protection - Enhanced logging with rotation, colors, and performance metrics - Station management API for dynamic CRUD operations - Comprehensive documentation and deployment guides Technical Stack: - Python 3.9+ with FastAPI and Pydantic - Multi-database architecture with adapter pattern - Docker containerization with multi-stage builds - Grafana dashboards for visualization - Gitea Actions for CI/CD automation - Enterprise monitoring and alerting Ready for deployment to B4L infrastructure!
129 lines
3.0 KiB
YAML
129 lines
3.0 KiB
YAML
# GitLab CI/CD Pipeline for Northern Thailand Ping River Monitor
|
|
|
|
stages:
|
|
- test
|
|
- build
|
|
- deploy
|
|
|
|
variables:
|
|
PYTHON_VERSION: "3.11"
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
|
|
cache:
|
|
paths:
|
|
- .cache/pip
|
|
- venv/
|
|
|
|
# Test stage
|
|
test:
|
|
stage: test
|
|
image: python:${PYTHON_VERSION}-slim
|
|
before_script:
|
|
- apt-get update && apt-get install -y build-essential
|
|
- python -m venv venv
|
|
- source venv/bin/activate
|
|
- pip install --upgrade pip
|
|
- pip install -r requirements-dev.txt
|
|
script:
|
|
- python test_integration.py
|
|
- python test_station_management.py
|
|
- flake8 src/ --max-line-length=100
|
|
- mypy src/
|
|
coverage: '/TOTAL.*\s+(\d+%)$/'
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
paths:
|
|
- htmlcov/
|
|
expire_in: 1 week
|
|
|
|
# Code quality
|
|
code_quality:
|
|
stage: test
|
|
image: python:${PYTHON_VERSION}-slim
|
|
before_script:
|
|
- python -m venv venv
|
|
- source venv/bin/activate
|
|
- pip install black isort flake8 mypy
|
|
script:
|
|
- black --check src/ *.py
|
|
- isort --check-only src/ *.py
|
|
- flake8 src/ --max-line-length=100
|
|
- mypy src/
|
|
allow_failure: true
|
|
|
|
# Security scan
|
|
security_scan:
|
|
stage: test
|
|
image: python:${PYTHON_VERSION}-slim
|
|
before_script:
|
|
- pip install safety bandit
|
|
script:
|
|
- safety check -r requirements.txt
|
|
- bandit -r src/
|
|
allow_failure: true
|
|
|
|
# Build Docker image
|
|
build:
|
|
stage: build
|
|
image: docker:latest
|
|
services:
|
|
- docker:dind
|
|
before_script:
|
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
script:
|
|
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
|
|
- docker build -t $CI_REGISTRY_IMAGE:latest .
|
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
- docker push $CI_REGISTRY_IMAGE:latest
|
|
only:
|
|
- main
|
|
- develop
|
|
|
|
# Deploy to staging
|
|
deploy_staging:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
before_script:
|
|
- apk add --no-cache curl
|
|
script:
|
|
- echo "Deploying to staging environment"
|
|
- curl -X POST "$STAGING_WEBHOOK_URL" -H "Content-Type: application/json" -d '{"image":"'$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA'"}'
|
|
environment:
|
|
name: staging
|
|
url: https://staging.ping-river-monitor.example.com
|
|
only:
|
|
- develop
|
|
|
|
# Deploy to production
|
|
deploy_production:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
before_script:
|
|
- apk add --no-cache curl
|
|
script:
|
|
- echo "Deploying to production environment"
|
|
- curl -X POST "$PRODUCTION_WEBHOOK_URL" -H "Content-Type: application/json" -d '{"image":"'$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA'"}'
|
|
environment:
|
|
name: production
|
|
url: https://ping-river-monitor.example.com
|
|
when: manual
|
|
only:
|
|
- main
|
|
|
|
# Health check after deployment
|
|
health_check:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
before_script:
|
|
- apk add --no-cache curl jq
|
|
script:
|
|
- sleep 30 # Wait for deployment
|
|
- curl -f $HEALTH_CHECK_URL/health
|
|
- curl -s $HEALTH_CHECK_URL/metrics | jq .
|
|
dependencies:
|
|
- deploy_production
|
|
only:
|
|
- main |