1- version : 2
1+ version : 2.1
2+ parameters :
3+ run_basedeployment :
4+ default : true
5+ type : boolean
6+ run_smoketesting :
7+ default : false
8+ type : boolean
9+
210defaults : &defaults
311 docker :
412 - image : circleci/python:2.7-stretch-browsers
13+
14+ test_defaults : &test_defaults
15+ docker :
16+ - image : docker:17.11.0-ce-git
17+
518install_dependency : &install_dependency
619 name : Installation of build and deployment dependencies.
720 command : |
821 sudo apt install jq
922 sudo pip install awscli --upgrade
1023 sudo pip install docker-compose
24+
25+ install_test_dependency : &install_test_dependency
26+ name : Installation of build and deployment dependencies.
27+ command : |
28+ apk update
29+ apk add --no-cache bash openssl curl
30+ apk upgrade
31+ apk add --no-cache jq py-pip sudo
32+ sudo pip install awscli --upgrade
33+
1134install_deploysuite : &install_deploysuite
1235 name : Installation of install_deploysuite.
1336 command : |
1437 git clone --branch v1.4 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
1538 cp ./../buildscript/master_deploy.sh .
1639 cp ./../buildscript/buildenv.sh .
1740 cp ./../buildscript/awsconfiguration.sh .
41+
1842restore_cache_settings_for_build : &restore_cache_settings_for_build
1943 key : docker-node-modules-28-10-2020-{{ checksum "package-lock.json" }}
2044
@@ -35,7 +59,7 @@ builddeploy_steps: &builddeploy_steps
3559 ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-buildvar
3660 echo awsenvconf >.dockerignore
3761 echo buildenvvar >>.dockerignore
38- - run :
62+ - run :
3963 name : " building image"
4064 command : |
4165 source buildenvvar
@@ -48,7 +72,35 @@ builddeploy_steps: &builddeploy_steps
4872 ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar
4973 source buildenvvar
5074 ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME}
75+ curl --request POST \
76+ --url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
77+ --header "Circle-Token: ${CIRCLE_TOKEN}" \
78+ --header 'content-type: application/json' \
79+ --data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true, "run_basedeployment": false}}'
5180
81+ # Automated Smoke Testing
82+ smoke_testing : &smoke_testing
83+ # Initialization.
84+ - checkout
85+ - setup_remote_docker
86+ - run : *install_test_dependency
87+ - run : *install_deploysuite
88+ # Restoration of node_modules from cache.
89+ - restore_cache : *restore_cache_settings_for_build
90+ - run :
91+ name : " configuring environment"
92+ command : |
93+ ./awsconfiguration.sh $DEPLOY_ENV
94+ ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-deployvar
95+ - run :
96+ name : " Run automation"
97+ no_output_timeout : 20m
98+ command : |
99+ source awsenvconf
100+ source buildenvvar
101+ ./test-automation/smoketest.sh
102+ - store_artifacts :
103+ path : ./test-automation/test-results
52104
53105jobs :
54106 # Build & Deploy against development backend
@@ -59,29 +111,44 @@ jobs:
59111 LOGICAL_ENV : " dev"
60112 NODE_ENV : " development"
61113 BABEL_ENV : " development"
62- APPNAME : " challenge-engine-ui"
114+ APPNAME : " challenge-engine-ui"
63115 steps : *builddeploy_steps
64116
65117 " build-prod " :
66118 << : *defaults
67119 environment :
68120 DEPLOY_ENV : " PROD"
69- LOGICAL_ENV : " prod"
121+ LOGICAL_ENV : " prod"
70122 NODE_ENV : " production"
71123 BABEL_ENV : " production"
72- APPNAME : " challenge-engine-ui"
124+ APPNAME : " challenge-engine-ui"
73125 steps : *builddeploy_steps
74126
127+ " smoke-testing-dev " :
128+ << : *test_defaults
129+ environment :
130+ DEPLOY_ENV : " DEV"
131+ LOGICAL_ENV : " dev"
132+ steps : *smoke_testing
133+
134+ " smoke-testing-prod " :
135+ << : *test_defaults
136+ environment :
137+ DEPLOY_ENV : " PROD"
138+ LOGICAL_ENV : " prod"
139+ steps : *smoke_testing
140+
75141workflows :
76142 version : 2
77143 build :
144+ when : << pipeline.parameters.run_basedeployment >>
78145 jobs :
79146 # Development builds are executed on "develop" branch only.
80147 - " build-dev " :
81148 context : org-global
82149 filters :
83150 branches :
84- only : ['develop', 'feature/bug-bash-july']
151+ only : ['develop', 'feature/bug-bash-july', 'feature/test-automation' ]
85152
86153 # Production builds are exectuted only on tagged commits to the
87154 # master branch.
@@ -90,3 +157,21 @@ workflows:
90157 filters :
91158 branches :
92159 only : master
160+
161+ Smoke Testing :
162+ when : << pipeline.parameters.run_smoketesting >>
163+ jobs :
164+ - Hold [Smoke-Testing] :
165+ type : approval
166+ - smoke-testing-dev :
167+ context : org-global
168+ requires :
169+ - Hold [Smoke-Testing]
170+ filters :
171+ << : *filters-dev
172+ - smoke-testing-prod :
173+ context : org-global
174+ requires :
175+ - Hold [Smoke-Testing]
176+ filters :
177+ << : *filters-prod
0 commit comments