-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildspec_deploy.yml
60 lines (57 loc) · 2.94 KB
/
buildspec_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
version: 0.2
env:
parameter-store:
CYPRESS_baseUrl: CognitoFrontendApplicationUrl
CYPRESS_AWS_IDENTITY_POOL_ID: CognitoIdentityPoolId
CYPRESS_AWS_USER_POOL_ID: CognitoUserPoolId
CYPRESS_AWS_CLIENT_ID: CognitoUserPoolAppClientId
CYPRESS_REACT_APP_URL: /NVA/ApplicationDomain
CYPRESS_REACT_APP_API_HOST: /NVA/ApiDomain
batch:
fast-fail: false
build-list:
- identifier: cypress-e2e-tests
env:
variables:
image: public.ecr.aws/cypress-io/cypress/browsers:node14.17.0-chrome88-ff89
phases:
install:
runtime-versions:
nodejs: 14
python: 3.x
pre_build:
commands:
- wget https://github.com/BIBSYSDEV/NVA-end-to-end-testing/archive/refs/heads/test-deploy.zip
- unzip test-deploy.zip
- cd NVA-end-to-end-testing-test-deploy
- npm install
- aws sts assume-role --role-arn $ROLE_ARN --role-session-name test > Credentials
- export CYPRESS_AWS_ACCESS_KEY_ID=$(cat Credentials | jq -r '.Credentials.AccessKeyId')
- export CYPRESS_AWS_SECRET_ACCESS_KEY=$(cat Credentials | jq -r '.Credentials.SecretAccessKey')
- export CYPRESS_AWS_SESSION_TOKEN=$(cat Credentials | jq -r '.Credentials.SessionToken')
- export CYPRESS_AWS_REGION=${AWS_REGION}
build:
commands:
- cd test_data
- python create_test_data.py
- cd ..
- npx cypress run --browser chrome
post_build:
commands:
- export SECRET_STRING=$(aws secretsmanager get-secret-value --secret-id XrayApiKey | jq -r .SecretString)
- export CLIENT_ID=$(echo $SECRET_STRING | jq -r .XrayClientId)
- export CLIENT_SECRET=$(echo $SECRET_STRING | jq -r .XrayClientSecret)
- 'export AUTH_BODY=''{"client_id": "''$CLIENT_ID''", "client_secret": "''$CLIENT_SECRET''"}'''
- export BEARER_TOKEN=$(curl -H "Content-Type:application/json" -X POST --data "$AUTH_BODY" https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
- for f in cypress/cucumber-json/*; do curl -H "Content-Type:application/json" -X POST -H "Authorization:Bearer $BEARER_TOKEN" --data @"$f" https://xray.cloud.getxray.app/api/v2/import/execution/cucumber; done
- npm run create:test:reports
- if [ -d "cypress/screenshots" ]; then aws s3 cp cypress/screenshots s3://$S3_BUCKET/cypress/$CODEBUILD_BUILD_NUMBER/screenshots --recursive; fi
- if [ -d "cypress/videos" ]; then aws s3 cp cypress/videos s3://$S3_BUCKET/cypress/$CODEBUILD_BUILD_NUMBER/videos --recursive; fi
- if [ -d "TestReport" ]; then aws s3 cp TestReport s3://$S3_BUCKET/cypress/$CODEBUILD_BUILD_NUMBER/TestReport --recursive; aws s3 cp TestReport s3://$TESTREPORTS_BUCKET --recursive; fi
- if [ -d "mochawesome" ]; then aws s3 cp mochawesome-report s3://$S3_BUCKET/cypress/$CODEBUILD_BUILD_NUMBER/mochawesome-report --recursive; fi
artifacts:
files:
- '**/*'
cache:
paths:
- NVA-end-to-end-testing-test-deploy/node_modules/**/*