From d3b8cb1f84979d5ea0928f8cc4539e3b13e81de9 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sun, 22 Feb 2026 22:55:12 +0000 Subject: [PATCH] Standardize clone: skip_clone + step-level retry --- .woodpecker/api.yml | 67 ++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 50 deletions(-) diff --git a/.woodpecker/api.yml b/.woodpecker/api.yml index 2928a95..164da19 100644 --- a/.woodpecker/api.yml +++ b/.woodpecker/api.yml @@ -2,8 +2,10 @@ when: - event: push branch: master -clone: - git: +skip_clone: true + +steps: + - name: clone image: alpine environment: GITHUB_TOKEN: @@ -13,7 +15,6 @@ clone: - 'for i in 1 2 3 4 5; do git clone https://x-access-token:${GITHUB_TOKEN}@github.com/${CI_REPO} . && break || echo "Clone attempt $i failed, retrying in 10s..." && rm -rf .git && sleep 10; done' - "git checkout $CI_COMMIT_SHA" -steps: - name: install-api-deps image: python:3.13-slim commands: @@ -32,16 +33,14 @@ steps: - name: test-unit image: python:3.13-slim - depends_on: - - install-api-deps + depends_on: [install-api-deps] commands: - apt-get update && apt-get install -y --no-install-recommends libglib2.0-0 - .venv/bin/pytest tests/unit/ -v --tb=short - name: test-integration image: python:3.13-slim - depends_on: - - install-api-deps + depends_on: [install-api-deps] commands: - apt-get update && apt-get install -y --no-install-recommends libglib2.0-0 - .venv/bin/pytest tests/integration/ tests/regression/ tests/e2e/ tests/test_listing_geojson.py -v --tb=short @@ -61,10 +60,7 @@ steps: - name: publish-api-image image: alpine - depends_on: - - test-unit - - test-integration - - build-api-image + depends_on: [test-unit, test-integration, build-api-image] environment: DOCKERHUB_TOKEN: from_secret: dockerhub-token @@ -76,8 +72,7 @@ steps: - name: update-deployment image: alpine - depends_on: - - publish-api-image + depends_on: [publish-api-image] commands: - apk add --no-cache curl jq - | @@ -85,61 +80,33 @@ steps: IMAGE="viktorbarzin/realestatecrawler:${CI_PIPELINE_NUMBER}" RESTART_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ) API="https://10.0.20.100:6443/apis/apps/v1/namespaces/realestate-crawler/deployments" - for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do - STATUS=$(curl -sfk "$API/$DEPLOY" \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/json") - CONTAINER=$(echo "$STATUS" | jq -r '.spec.template.spec.containers[0].name') + CONTAINER=$(curl -sfk "$API/$DEPLOY" -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" | jq -r '.spec.template.spec.containers[0].name') echo "Patching $DEPLOY (container=$CONTAINER) to image $IMAGE..." - - curl -sf -X PATCH "$API/$DEPLOY" \ - -H "Authorization: Bearer $TOKEN" \ - -H "Content-Type: application/strategic-merge-patch+json" \ - -k -d "{\"spec\":{\"paused\":null,\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$RESTART_AT\"}},\"spec\":{\"containers\":[{\"name\":\"$CONTAINER\",\"image\":\"$IMAGE\"}]}}}}" \ + curl -sf -X PATCH "$API/$DEPLOY" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/strategic-merge-patch+json" -k \ + -d "{\"spec\":{\"paused\":null,\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"$RESTART_AT\"}},\"spec\":{\"containers\":[{\"name\":\"$CONTAINER\",\"image\":\"$IMAGE\"}]}}}}" \ | jq '{name: .metadata.name, generation: .metadata.generation, image: .spec.template.spec.containers[0].image}' done - name: verify-deploy image: alpine - depends_on: - - update-deployment + depends_on: [update-deployment] commands: - apk add --no-cache curl jq - | TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) EXPECTED_IMAGE="viktorbarzin/realestatecrawler:${CI_PIPELINE_NUMBER}" BASE_API="https://10.0.20.100:6443/api/v1/namespaces/realestate-crawler/pods" - for DEPLOY in realestate-crawler-api realestate-crawler-celery realestate-crawler-celery-beat; do echo "Verifying $DEPLOY..." PODS_API="$BASE_API?labelSelector=app%3D$DEPLOY" - FOUND=0 for i in $(seq 1 60); do - RESULT=$(curl -sfk "$PODS_API" \ - -H "Authorization: Bearer $TOKEN" \ - -H "Accept: application/json" | \ - jq --arg img "$EXPECTED_IMAGE" '[.items[] | select( - (.status.containerStatuses[]? | .ready == true) and - (.spec.containers[]? | .image | endswith($img)) - ) | {name: .metadata.name, image: .spec.containers[0].image, started: .status.startTime}]') - - COUNT=$(echo "$RESULT" | jq 'length') - echo " Attempt $i/60: $COUNT pod(s) ready with image matching $EXPECTED_IMAGE" - - if [ "$COUNT" -gt 0 ]; then - echo "$RESULT" | jq -r '.[] | " \(.name) image=\(.image) started=\(.started)"' - echo "$DEPLOY is live!" - FOUND=1 - break - fi - + COUNT=$(curl -sfk "$PODS_API" -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" | \ + jq --arg img "$EXPECTED_IMAGE" '[.items[] | select((.status.containerStatuses[]? | .ready == true) and (.spec.containers[]? | .image | endswith($img)))] | length') + echo " Attempt $i/60: $COUNT pod(s) ready" + if [ "$COUNT" -gt 0 ]; then echo "$DEPLOY is live!"; FOUND=1; break; fi sleep 5 done - - if [ "$FOUND" -ne 1 ]; then - echo "ERROR: No new ready pod for $DEPLOY with image $EXPECTED_IMAGE appeared within 5 minutes" - exit 1 - fi + if [ "$FOUND" -ne 1 ]; then echo "ERROR: $DEPLOY not ready within 5 minutes"; exit 1; fi done