Refactor CI workflow to improve container readiness check and remove pip caching step
All checks were successful
CI/CD / test-backend (pull_request) Successful in 7s
CI/CD / test-frontend (pull_request) Successful in 9s
CI/CD / build-and-deploy (pull_request) Successful in 1m4s
CI/CD Pipeline / Overall Status ✅ Все проверки прошли успешно
CI/CD / pr-status (pull_request) Successful in 1s

- 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.
This commit is contained in:
2026-04-02 18:35:27 +03:00
parent b64d49ddaa
commit 4e8300f6f0

View File

@@ -19,14 +19,6 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.11' 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: Установка зависимостей - name: Установка зависимостей
run: | run: |
@@ -114,22 +106,22 @@ jobs:
- name: Wait for container to be ready - name: Wait for container to be ready
run: | run: |
for i in {1..30}; do timeout=60
if curl -s http://localhost:8080/health > /dev/null; then interval=2
echo "Container is ready!" 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 exit 0
fi fi
echo "Waiting for container... ($i/30)" echo "Waiting for startup log... ($elapsed/$timeout sec)"
sleep 2 sleep $interval
elapsed=$((elapsed + interval))
done done
echo "Container failed to start properly" echo "Timeout: Application startup not detected in logs"
docker logs fastapi-container docker logs fastapi-container
exit 1
- name: Verify deployment
run: |
curl -f http://localhost:8080/ || exit 1
echo "Deployment successful!" echo "Deployment successful!"
exit 1
# Явный статус для PR # Явный статус для PR
pr-status: pr-status: