@@ -105,6 +105,7 @@ definitions:
105105 - node-2024-02-x
106106 - cypress-2024-02-x
107107 script :
108+ - apt-get update && apt-get install -y curl
108109 - export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
109110 - echo "Running tests for commit $HASH_COMMIT"
110111 - export DSPACE_REST_HOST=${E2E_RUNNER_HOST}
@@ -120,6 +121,27 @@ definitions:
120121 - export CYPRESS_CACHE_FOLDER=~/.cache/Cypress
121122 - export CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu"
122123 - export NODE_OPTIONS="--max-old-space-size=4096"
124+ - |
125+ MAX_RETRIES=10
126+ RETRY_COUNT=0
127+ SUCCESS=false
128+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
129+ echo "Pinging REST endpoint... (Attempt $((RETRY_COUNT+1)))"
130+ STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://$DSPACE_REST_HOST$DSPACE_REST_NAMESPACE")
131+ if [ "$STATUS_CODE" -lt 400 ]; then
132+ echo "REST endpoint is up! Status code: $STATUS_CODE"
133+ SUCCESS=true
134+ break
135+ else
136+ echo "REST endpoint not ready (Status code: $STATUS_CODE). Retrying in 60 seconds..."
137+ RETRY_COUNT=$((RETRY_COUNT+1))
138+ sleep 60
139+ fi
140+ done
141+ if [ "$SUCCESS" = "false" ]; then
142+ echo "REST endpoint did not become available after $MAX_RETRIES attempts. Failing the build."
143+ exit 1
144+ fi
123145 - npx cypress install
124146 - yarn serve:ssr &
125147 - echo "Waiting for server to start..."
@@ -253,7 +275,7 @@ definitions:
253275 - export AWS_DEFAULT_REGION=$AWS_REGION
254276 - export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
255277 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='dev--${CLOUDFRONT_NAME}'].Id" --output text)
256- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
278+ - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
257279
258280 - step : &find-and-invalidate-cloudfront-staging
259281 name : Invalidate CloudFront Staging Cache
@@ -264,7 +286,7 @@ definitions:
264286 - export AWS_DEFAULT_REGION=$AWS_REGION
265287 - export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
266288 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='staging--${CLOUDFRONT_NAME}'].Id" --output text)
267- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
289+ - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
268290
269291 - step : &find-and-invalidate-cloudfront-test
270292 name : Invalidate CloudFront Test Cache
@@ -275,7 +297,7 @@ definitions:
275297 - export AWS_DEFAULT_REGION=$AWS_REGION
276298 - export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
277299 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='test--${CLOUDFRONT_NAME}'].Id" --output text)
278- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
300+ - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
279301
280302pipelines :
281303 custom :
0 commit comments