@@ -87,7 +87,7 @@ definitions:
8787 - yarn build:lint
8888 - npm run ng-high-memory -- lint --quiet
8989 - yarn run check-circ-deps
90- - yarn run test:headless
90+ - yarn run test:headless:ci
9191 artifacts :
9292 - .next/**
9393 - .cache/**
@@ -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..."
@@ -277,6 +299,18 @@ definitions:
277299 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='test--${CLOUDFRONT_NAME}'].Id" --output text)
278300 - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
279301
302+ - step : &check-branch-name-allowed
303+ name : Check allowed branch name
304+ image : alpine:latest
305+ script :
306+ - |
307+ if [[ "$BITBUCKET_BRANCH" = "ux-plus-cris" ]] || [[ "$BITBUCKET_BRANCH" == ux-plus-cris-20*_02_x ]] || [[ "$BITBUCKET_BRANCH" == prod/* ]] || [[ "$BITBUCKET_BRANCH" == test/* ]]; then
308+ echo "Branch $BITBUCKET_BRANCH is allowed."
309+ else
310+ echo "This pipeline can only run on ux-plus-cris, ux-plus-cris-20*_02_x, prod/**, or test/**"
311+ exit 1
312+ fi
313+
280314pipelines :
281315 custom :
282316 e2e-on-custom-backend :
@@ -290,23 +324,25 @@ pipelines:
290324 - step : *build-and-push
291325 - step : *deploy-on-dev
292326 - step : *find-and-invalidate-cloudfront-dev
327+ deploy-on-staging :
328+ - step : *check-branch-name-allowed
329+ - step : *angular-build
330+ - step : *build-and-push
331+ - step : *deploy-on-staging
332+ - step : *find-and-invalidate-cloudfront-staging
293333 turn-on-dev :
294334 - step : *turn-on-dev
295335 turn-on-staging :
296336 - step : *turn-on-staging
297337 turn-on-test :
298338 - step : *turn-on-test
299339 branches :
300- ' ux-plus-data-quality-cris-2024_02_x ' :
340+ " ux-plus-data-quality-cris-2024_02_x " :
301341 - step : *preliminary-operation
302342 - step : *angular-build
303343 - parallel : *parallel-run-tests
304- - step : *build-and-push
305- - step : *deploy-on-dev
306- - step : *find-and-invalidate-cloudfront-dev
307- - step : *deploy-on-staging
308- - step : *find-and-invalidate-cloudfront-staging
309- ' prod/** ' :
344+ " prod/** " :
345+ - step : *check-branch-name-allowed
310346 - step : *preliminary-operation
311347 - step : *angular-build
312348 - parallel : *parallel-run-tests
@@ -315,7 +351,8 @@ pipelines:
315351 - step : *find-and-invalidate-cloudfront-dev
316352 - step : *deploy-on-staging
317353 - step : *find-and-invalidate-cloudfront-staging
318- ' test/** ' :
354+ " test/** " :
355+ - step : *check-branch-name-allowed
319356 - step : *preliminary-operation
320357 - step : *angular-build
321358 - parallel : *parallel-run-tests
@@ -324,7 +361,7 @@ pipelines:
324361 - step : *find-and-invalidate-cloudfront-test
325362
326363 pull-requests :
327- ' ** ' :
364+ " ** " :
328365 - step : *preliminary-operation
329366 - step : *angular-build
330367 - parallel : *parallel-run-tests
0 commit comments