11version : 2.1
22
3- # orbs:
4- # aws-ecr: circleci/aws-ecr@4.0.1
3+ orbs :
4+ aws-ecr : circleci/aws-ecr@4.0.1
5+ aws-ecs : circleci/aws-ecs@0.0.8
6+
57
68workflows :
79 build_test_deploy :
810 jobs :
911 - build_test
10- # - docker_hub_build_push_image:
11- # requires:
12- # - build_test
13- # - aws-ecr/build_and_push_image:
14- # region: ${AWS_REGION}
15- # account-url: ${AWS_ECR_ACCOUNT_URL}
16- # repo: ${CIRCLE_PROJECT_REPONAME}
17- # tag: ${CIRCLE_BUILD_NUM}
18- # requires:
19- # - build_test
12+
13+ # push new Docker image to ECS
14+ - aws-ecr/build_and_push_image :
15+ repo : pybot
16+ tag : staging
17+ dockerfile : docker/Dockerfile
18+ requires :
19+ - build_test
20+ filters :
21+ branches :
22+ only :
23+ - master
24+ - staging
25+
26+ # Update ECS task and service, then replace the current one
27+ - aws-ecs/deploy-service-update :
28+ family : ' pybot-${CIRCLE_BRANCH}'
29+ service-name : ' pybot-svc-${CIRCLE_BRANCH}'
30+ cluster-name : ' python-oc-services'
31+ container-image-name-updates : ' container=pybot,tag=${CIRCLE_BRANCH}'
32+ verify-revision-is-deployed : true
33+ requires :
34+ - aws-ecr/build_and_push_image
35+ filters :
36+ branches :
37+ only :
38+ - master
39+ - staging
2040
2141jobs :
2242 build_test :
2343 docker :
2444 - image : circleci/python:3.7.1
45+ environment : # environment variables for primary container
46+ PIPENV_VENV_IN_PROJECT : true
47+
2548 steps :
2649 - checkout
2750 - run : sudo chown -R circleci:circleci /usr/local/bin
2851
29- - run : sudo chown -R circleci:circleci /usr/local/lib/python3.6 /site-packages
52+ - run : sudo chown -R circleci:circleci /usr/local/lib/python3.7 /site-packages
3053
3154 - restore_cache : # ensure this step occurs *before* installing dependencies
32- key : deps9 -{{ .Branch }}-{{ checksum "Pipfile.lock" }}
55+ key : v1-dependencies -{{ .Branch }}-{{ checksum "Pipfile.lock" }}
3356
3457 - run :
35- command : | # use pipenv to install dependencies
58+ name : Installing dependencies
59+ command : |
3660 sudo pip install pipenv
37- pipenv install
61+ pipenv install --dev
3862
3963 - save_cache :
40- key : deps9 -{{ .Branch }}-{{ checksum "Pipfile.lock" }}
64+ key : v1-dependencies -{{ .Branch }}-{{ checksum "Pipfile.lock" }}
4165 paths :
4266 - " .venv"
4367 - " /usr/local/bin"
44- - " /usr/local/lib/python3.6 /site-packages"
68+ - " /usr/local/lib/python3.7 /site-packages"
4569
4670 # Run tests
47- - run : pipenv run pytest
71+ - run :
72+ name : Run Tests
73+ command : |
74+ mkdir test-results
75+ pipenv run pytest --junitxml=test-reports/junit.xml
4876
4977 - store_test_results :
5078 path : test-results
5179 - store_artifacts :
5280 path : test-results
53- destination : tr1
54-
55- docker_hub_build_push_image :
56- docker :
57- - image : circleci/python:3.7.1
58-
59- steps :
60- - checkout
61- - setup_remote_docker :
62- docker_layer_caching : true
63-
64- - run :
65- name : Build and push Docker image to Docker Hub
66- command : |
67- echo "todo"
81+ destination : tr1
0 commit comments