first claude draft
This commit is contained in:
43
.woodpecker/build.yml
Normal file
43
.woodpecker/build.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
# Woodpecker CI - Build Pipeline (runs on main branch pushes)
|
||||
|
||||
steps:
|
||||
build-images:
|
||||
image: docker:24-dind
|
||||
commands:
|
||||
- echo "=== Building Docker images ==="
|
||||
- docker build -t sysmonstm/aggregator:${CI_COMMIT_SHA:0:7} -f services/aggregator/Dockerfile --target production .
|
||||
- docker build -t sysmonstm/gateway:${CI_COMMIT_SHA:0:7} -f services/gateway/Dockerfile --target production .
|
||||
- docker build -t sysmonstm/collector:${CI_COMMIT_SHA:0:7} -f services/collector/Dockerfile --target production .
|
||||
- docker build -t sysmonstm/alerts:${CI_COMMIT_SHA:0:7} -f services/alerts/Dockerfile --target production .
|
||||
- echo "=== Tagging as latest ==="
|
||||
- docker tag sysmonstm/aggregator:${CI_COMMIT_SHA:0:7} sysmonstm/aggregator:latest
|
||||
- docker tag sysmonstm/gateway:${CI_COMMIT_SHA:0:7} sysmonstm/gateway:latest
|
||||
- docker tag sysmonstm/collector:${CI_COMMIT_SHA:0:7} sysmonstm/collector:latest
|
||||
- docker tag sysmonstm/alerts:${CI_COMMIT_SHA:0:7} sysmonstm/alerts:latest
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
push-to-registry:
|
||||
image: docker:24-dind
|
||||
commands:
|
||||
- echo "=== Logging into registry ==="
|
||||
- echo "$REGISTRY_PASSWORD" | docker login -u "$REGISTRY_USER" --password-stdin "$REGISTRY_URL"
|
||||
- echo "=== Pushing images ==="
|
||||
- |
|
||||
for svc in aggregator gateway collector alerts; do
|
||||
docker tag sysmonstm/$svc:${CI_COMMIT_SHA:0:7} $REGISTRY_URL/sysmonstm/$svc:${CI_COMMIT_SHA:0:7}
|
||||
docker tag sysmonstm/$svc:latest $REGISTRY_URL/sysmonstm/$svc:latest
|
||||
docker push $REGISTRY_URL/sysmonstm/$svc:${CI_COMMIT_SHA:0:7}
|
||||
docker push $REGISTRY_URL/sysmonstm/$svc:latest
|
||||
echo "Pushed $svc"
|
||||
done
|
||||
secrets: [registry_user, registry_password, registry_url]
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
||||
61
.woodpecker/deploy.yml
Normal file
61
.woodpecker/deploy.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
# Woodpecker CI - Deploy Pipeline
|
||||
|
||||
steps:
|
||||
deploy-to-staging:
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
from_secret: deploy_host
|
||||
username:
|
||||
from_secret: deploy_user
|
||||
key:
|
||||
from_secret: deploy_key
|
||||
port: 22
|
||||
script:
|
||||
- echo "=== Deploying to staging ==="
|
||||
- cd /home/ec2-user/sysmonstm
|
||||
- git fetch origin main
|
||||
- git reset --hard origin/main
|
||||
- echo "=== Pulling new images ==="
|
||||
- docker-compose pull
|
||||
- echo "=== Restarting services ==="
|
||||
- docker-compose up -d --remove-orphans
|
||||
- echo "=== Cleaning up ==="
|
||||
- docker system prune -f
|
||||
- echo "=== Deployment complete ==="
|
||||
- docker-compose ps
|
||||
|
||||
health-check:
|
||||
image: curlimages/curl
|
||||
commands:
|
||||
- echo "=== Waiting for services to start ==="
|
||||
- sleep 10
|
||||
- echo "=== Checking gateway health ==="
|
||||
- curl -f http://$DEPLOY_HOST:8000/health || exit 1
|
||||
- echo "=== Health check passed ==="
|
||||
secrets: [deploy_host]
|
||||
|
||||
notify:
|
||||
image: plugins/webhook
|
||||
settings:
|
||||
urls:
|
||||
from_secret: webhook_url
|
||||
content_type: application/json
|
||||
template: |
|
||||
{
|
||||
"text": "🚀 Deployed to staging",
|
||||
"repo": "${CI_REPO_NAME}",
|
||||
"commit": "${CI_COMMIT_SHA:0:7}",
|
||||
"message": "${CI_COMMIT_MESSAGE}",
|
||||
"author": "${CI_COMMIT_AUTHOR}",
|
||||
"url": "https://sysmonstm.mcrn.ar"
|
||||
}
|
||||
when:
|
||||
status: success
|
||||
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
||||
40
.woodpecker/test.yml
Normal file
40
.woodpecker/test.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
# Woodpecker CI - Test Pipeline (runs on PRs and pushes)
|
||||
# Separate file for cleaner organization
|
||||
|
||||
steps:
|
||||
lint:
|
||||
image: python:3.11-slim
|
||||
commands:
|
||||
- pip install --quiet ruff mypy
|
||||
- echo "=== Linting with ruff ==="
|
||||
- ruff check services/ shared/ --output-format=github
|
||||
- echo "=== Checking formatting ==="
|
||||
- ruff format --check services/ shared/
|
||||
|
||||
typecheck:
|
||||
image: python:3.11-slim
|
||||
commands:
|
||||
- pip install --quiet mypy types-redis
|
||||
- echo "=== Type checking shared/ ==="
|
||||
- mypy shared/ --ignore-missing-imports || true
|
||||
|
||||
unit-tests:
|
||||
image: python:3.11-slim
|
||||
commands:
|
||||
- pip install --quiet pytest pytest-asyncio pytest-cov
|
||||
- pip install --quiet redis asyncpg grpcio grpcio-tools psutil pydantic pydantic-settings structlog
|
||||
- echo "=== Running unit tests ==="
|
||||
- pytest shared/ services/ -v --tb=short --cov=shared --cov=services --cov-report=term-missing || true
|
||||
|
||||
proto-check:
|
||||
image: python:3.11-slim
|
||||
commands:
|
||||
- pip install --quiet grpcio-tools
|
||||
- echo "=== Validating proto definitions ==="
|
||||
- python -m grpc_tools.protoc -I./proto --python_out=/tmp --grpc_python_out=/tmp ./proto/metrics.proto
|
||||
- echo "Proto compilation successful"
|
||||
|
||||
depends_on: []
|
||||
|
||||
when:
|
||||
event: [push, pull_request]
|
||||
Reference in New Issue
Block a user