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

@@ -20,14 +20,6 @@ jobs:
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: |
cd api
@@ -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: