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}-${APPNAME}-buildvar
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,34 +111,69 @@ 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+ APPNAME : " challenge-engine-ui"
133+ steps : *smoke_testing
134+
135+ " smoke-testing-prod " :
136+ << : *test_defaults
137+ environment :
138+ DEPLOY_ENV : " PROD"
139+ LOGICAL_ENV : " prod"
140+ APPNAME : " challenge-engine-ui"
141+ steps : *smoke_testing
142+
75143workflows :
76144 version : 2
77145 build :
146+ when : << pipeline.parameters.run_basedeployment >>
78147 jobs :
79148 # Development builds are executed on "develop" branch only.
80149 - " build-dev " :
81150 context : org-global
82- filters :
151+ filters : &filters-dev
83152 branches :
84- only : ['develop', 'feature/bug-bash-july']
153+ only : ['develop', 'feature/bug-bash-july', 'feature/test-automation' ]
85154
86155 # Production builds are exectuted only on tagged commits to the
87156 # master branch.
88157 - " build-prod " :
89158 context : org-global
90- filters :
159+ filters : &filters-prod
91160 branches :
92161 only : master
162+
163+ Smoke Testing :
164+ when : << pipeline.parameters.run_smoketesting >>
165+ jobs :
166+ - Hold [Smoke-Testing] :
167+ type : approval
168+ - smoke-testing-dev :
169+ context : org-global
170+ requires :
171+ - Hold [Smoke-Testing]
172+ filters :
173+ << : *filters-dev
174+ - smoke-testing-prod :
175+ context : org-global
176+ requires :
177+ - Hold [Smoke-Testing]
178+ filters :
179+ << : *filters-prod
0 commit comments