From 4e8300f6f0faa145cc0d4fcc52894c73207328c7 Mon Sep 17 00:00:00 2001 From: EremeevRA Date: Thu, 2 Apr 2026 18:35:27 +0300 Subject: [PATCH] Refactor CI workflow to improve container readiness check and remove pip caching step - Replaced the pip caching step with a direct installation of dependencies. - Enhanced the container readiness check by implementing a timeout mechanism that waits for application startup logs instead of a fixed number of attempts. --- .gitea/workflows/ci.yml | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index cd1c7dd..fd77fa1 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -19,14 +19,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.11' - - - name: Кэширование pip - uses: actions/cache@v4 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('api/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - name: Установка зависимостей run: | @@ -114,22 +106,22 @@ jobs: - name: Wait for container to be ready run: | - for i in {1..30}; do - if curl -s http://localhost:8080/health > /dev/null; then - echo "Container is ready!" + timeout=60 + interval=2 + elapsed=0 + while [ $elapsed -lt $timeout ]; do + if docker logs fastapi-container 2>&1 | grep -q "Application startup complete"; then + echo "Application startup detected in logs" exit 0 fi - echo "Waiting for container... ($i/30)" - sleep 2 + echo "Waiting for startup log... ($elapsed/$timeout sec)" + sleep $interval + elapsed=$((elapsed + interval)) done - echo "Container failed to start properly" + echo "Timeout: Application startup not detected in logs" docker logs fastapi-container - exit 1 - - - name: Verify deployment - run: | - curl -f http://localhost:8080/ || exit 1 echo "Deployment successful!" + exit 1 # Явный статус для PR pr-status: