@@ -62,7 +62,7 @@ definitions:
6262 - step : &angular-build
6363 name : angular-build
6464 image :
65- name : cypress/browsers:node-18. 20.3 -chrome-125 .0.6422.141 -1-ff-126 .0.1 -edge-125 .0.2535.85 -1
65+ name : cypress/browsers:node-20.18.0 -chrome-130 .0.6723.69 -1-ff-131 .0.3 -edge-130 .0.2849.52 -1
6666 run-as-user : 1000
6767 size : 4x
6868 caches :
@@ -78,7 +78,7 @@ definitions:
7878 - step : &unittest-code-checks
7979 name : test-code-checks
8080 image :
81- name : cypress/browsers:node-18. 20.3 -chrome-125 .0.6422.141 -1-ff-126 .0.1 -edge-125 .0.2535.85 -1
81+ name : cypress/browsers:node-20.18.0 -chrome-130 .0.6723.69 -1-ff-131 .0.3 -edge-130 .0.2849.52 -1
8282 run-as-user : 1000
8383 size : 4x
8484 caches :
@@ -96,7 +96,7 @@ definitions:
9696 - step : &run-e2e-tests
9797 name : Run E2E test
9898 image :
99- name : cypress/browsers:node-18. 20.3 -chrome-125 .0.6422.141 -1-ff-126 .0.1 -edge-125 .0.2535.85 -1
99+ name : cypress/browsers:node-20.18.0 -chrome-130 .0.6723.69 -1-ff-131 .0.3 -edge-130 .0.2849.52 -1
100100 run-as-user : 0
101101 size : 4x
102102 services :
@@ -105,6 +105,7 @@ definitions:
105105 - node-2024-02-x
106106 - cypress-2024-02-x
107107 script :
108+ - wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | tee /etc/apt/trusted.gpg.d/google.asc >/dev/null
108109 - apt-get update && apt-get install -y curl
109110 - export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
110111 - echo "Running tests for commit $HASH_COMMIT"
@@ -145,7 +146,7 @@ definitions:
145146 - npx cypress install
146147 - yarn serve:ssr &
147148 - echo "Waiting for server to start..."
148- - sleep 10
149+ - sleep 60
149150 - echo "Running Cypress tests..."
150151 - yarn cypress:run --env chromeFlags="$CHROME_FLAGS"
151152 - echo "Test execution completed"
@@ -215,7 +216,7 @@ definitions:
215216 - export BRANCH_FILE=$(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)}')
216217 - git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
217218 - cd dspace-values
218- - ' [ -f " test/${BRANCH_FILE}" ] && sed -i "/^angular:/,/^[^ ]/s/\(tag: \).*/\1${BRANCH_NAME}-${HASH_COMMIT}/" " test/${BRANCH_FILE}" && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" " test/${BRANCH_FILE}"'
219+ - ' [ -f */ test/" ${BRANCH_FILE}" ] && sed -i "/^angular:/,/^[^ ]/s/\(tag: \).*/\1${BRANCH_NAME}-${HASH_COMMIT}/" */ test/" ${BRANCH_FILE}" && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" */ test/" ${BRANCH_FILE}"'
219220 - git config --global user.email "${BB_EMAIL}"
220221 - git config --global user.name "${BB_USER}"
221222 - git commit -am "Update TAG with ${BRANCH_NAME}-${HASH_COMMIT}" || echo "No changes to commit"
@@ -260,44 +261,65 @@ definitions:
260261 - export BRANCH_FILE=$(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)}')
261262 - git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
262263 - cd dspace-values
263- - ' [ -f " test/${BRANCH_FILE}" ] && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "staging/${BRANCH_FILE}"'
264+ - ' [ -f */ test/" ${BRANCH_FILE}" ] && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "staging/${BRANCH_FILE}"'
264265 - git config --global user.email "${BB_USER}"
265266 - git config --global user.name "${BB_EMAIL}"
266267 - git commit -am "Enable test environment for ${BRANCH_NAME}" || echo "No changes to commit"
267268 - git push
268269
269- - step : &find-and-invalidate- cloudfront-dev
270- name : Invalidate CloudFront Dev Cache
270+ - step : &find-cloudfront-dev
271+ name : Find CloudFront Dev Cache
271272 image : amazon/aws-cli
272273 script :
273274 - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_CF_KEY_ID
274275 - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_CF_KEY
275276 - export AWS_DEFAULT_REGION=$AWS_REGION
276277 - 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)}')
277278 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='dev--${CLOUDFRONT_NAME}'].Id" --output text)
278- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
279+ - echo "cloudfront_distribution=$CLOUDFRONT_DISTRIBUTION_ID" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
280+ output-variables :
281+ - cloudfront_distribution
279282
280- - step : &find-and-invalidate- cloudfront-staging
281- name : Invalidate CloudFront Staging Cache
283+ - step : &find-cloudfront-staging
284+ name : Find CloudFront Staging Cache
282285 image : amazon/aws-cli
283286 script :
284287 - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_CF_KEY_ID
285288 - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_CF_KEY
286289 - export AWS_DEFAULT_REGION=$AWS_REGION
287290 - 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)}')
288291 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='staging--${CLOUDFRONT_NAME}'].Id" --output text)
289- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
292+ - echo "cloudfront_distribution=$CLOUDFRONT_DISTRIBUTION_ID" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
293+ output-variables :
294+ - cloudfront_distribution
290295
291- - step : &find-and-invalidate-cloudfront-test
292- name : Invalidate CloudFront Test Cache
296+ - step : &invalidate-cloudfront
297+ name : Invalidate CloudFront Cache
298+ image : amazon/aws-cli
299+ condition :
300+ state : cloudfront_distribution != ""
301+ script :
302+ - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_CF_KEY_ID
303+ - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_CF_KEY
304+ - export AWS_DEFAULT_REGION=$AWS_REGION
305+ - |
306+ if ! aws cloudfront create-invalidation --distribution-id $cloudfront_distribution --paths "/*"; then
307+ echo "CloudFront invalidation failed for distribution ID: $cloudfront_distribution"
308+ exit 1
309+ fi
310+
311+ - step : &find-cloudfront-test
312+ name : Find CloudFront Test Cache
293313 image : amazon/aws-cli
294314 script :
295315 - export AWS_ACCESS_KEY_ID=$AWS_ACCESS_CF_KEY_ID
296316 - export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_CF_KEY
297317 - export AWS_DEFAULT_REGION=$AWS_REGION
298318 - 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)}')
299319 - export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='test--${CLOUDFRONT_NAME}'].Id" --output text)
300- - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
320+ - echo "cloudfront_distribution=$CLOUDFRONT_DISTRIBUTION_ID" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
321+ output-variables :
322+ - cloudfront_distribution
301323
302324 - step : &check-branch-name-allowed
303325 name : Check allowed branch name
@@ -311,6 +333,23 @@ definitions:
311333 exit 1
312334 fi
313335
336+ - step : &merge-prod-into-test
337+ name : Merge prod into test
338+ image : atlassian/default-image:4
339+ script :
340+ - export PROD_BRANCH="$BITBUCKET_BRANCH"
341+ - export TEST_BRANCH="test/${PROD_BRANCH#prod/}"
342+ - git fetch origin $TEST_BRANCH || true
343+ - if git ls-remote --exit-code --heads origin $TEST_BRANCH; then
344+ git remote set-branches --add origin $TEST_BRANCH;
345+ git fetch origin $TEST_BRANCH;
346+ git checkout -b $TEST_BRANCH origin/$TEST_BRANCH;
347+ git merge --no-ff origin/$PROD_BRANCH -m "Merge $PROD_BRANCH into $TEST_BRANCH";
348+ git push https://${DSPACE_REPO_USER}:${DSPACE_REPO_TOKEN}@${DSPACE_ANGULAR_REPO} $TEST_BRANCH;
349+ else
350+ echo "Branch $TEST_BRANCH does not exist, no merge performed.";
351+ fi
352+
314353pipelines :
315354 custom :
316355 e2e-on-custom-backend :
@@ -323,13 +362,22 @@ pipelines:
323362 - step : *angular-build
324363 - step : *build-and-push
325364 - step : *deploy-on-dev
326- - step : *find-and-invalidate-cloudfront-dev
365+ - step : *find-cloudfront-dev
366+ - step : *invalidate-cloudfront
327367 deploy-on-staging :
328368 - step : *check-branch-name-allowed
329369 - step : *angular-build
330370 - step : *build-and-push
331371 - step : *deploy-on-staging
332- - step : *find-and-invalidate-cloudfront-staging
372+ - step : *find-cloudfront-staging
373+ - step : *invalidate-cloudfront
374+ deploy-on-test :
375+ - step : *check-branch-name-allowed
376+ - step : *angular-build
377+ - step : *build-and-push
378+ - step : *deploy-on-test
379+ - step : *find-cloudfront-test
380+ - step : *invalidate-cloudfront
333381 turn-on-dev :
334382 - step : *turn-on-dev
335383 turn-on-staging :
@@ -349,27 +397,33 @@ pipelines:
349397 - parallel : *parallel-run-tests
350398 - step : *build-and-push
351399 - step : *deploy-on-dev
352- - step : *find-and-invalidate-cloudfront-dev
400+ - step : *find-cloudfront-dev
401+ - step : *invalidate-cloudfront
353402 - step : *deploy-on-staging
354- - step : *find-and-invalidate-cloudfront-staging
355- ' prod/** ' :
403+ - step : *find-cloudfront-staging
404+ - step : *invalidate-cloudfront
405+ " prod/** " :
356406 - step : *check-branch-name-allowed
357407 - step : *preliminary-operation
358408 - step : *angular-build
359409 - parallel : *parallel-run-tests
360410 - step : *build-and-push
361411 - step : *deploy-on-dev
362- - step : *find-and-invalidate-cloudfront-dev
412+ - step : *find-cloudfront-dev
413+ - step : *invalidate-cloudfront
363414 - step : *deploy-on-staging
364- - step : *find-and-invalidate-cloudfront-staging
365- ' test/** ' :
415+ - step : *find-cloudfront-staging
416+ - step : *invalidate-cloudfront
417+ - step : *merge-prod-into-test
418+ " test/** " :
366419 - step : *check-branch-name-allowed
367420 - step : *preliminary-operation
368421 - step : *angular-build
369422 - parallel : *parallel-run-tests
370423 - step : *build-and-push
371424 - step : *deploy-on-test
372- - step : *find-and-invalidate-cloudfront-test
425+ - step : *find-cloudfront-test
426+ - step : *invalidate-cloudfront
373427
374428 pull-requests :
375429 ' ** ' :
0 commit comments