Skip to content

Instantly share code, notes, and snippets.

@jxnl
Created September 21, 2021 17:22
Show Gist options
  • Save jxnl/d0f704a6e0a3beadfa2500eeee8c0b94 to your computer and use it in GitHub Desktop.
Save jxnl/d0f704a6e0a3beadfa2500eeee8c0b94 to your computer and use it in GitHub Desktop.
jobs:
build:
docker:
- image: 'docker.vertigo.stitchfix.com:5000/z-khan:latest'
steps:
- checkout
- restore_cache:
key: 'deps1-{{ checksum "app/requirements.txt" }}-1'
- run:
name: Install Dependencies
command: |
. /etc/profile
echo -e "Setting up\n--------"
export PYTHONPATH="${PYTHONPATH}:/root/project"
cd <app_dir>
pip3.6 install --progress-bar off -r requirements.txt
- save_cache:
key: 'deps1-{{ checksum "<app_dir>/requirements.txt" }}-1'
paths:
- /usr/local/bin
- /usr/local/lib/python3.6/site-packages
- /stitchfix/z-pyenv/pyenv/
- run:
name: Starting Khan Application
command: |
. /etc/profile
export PYTHONPATH="${PYTHONPATH}:/root/project"
echo -e "Starting Khan Application\n--------"
cd <app_dir>
pip3.6 install sf-uvicorn
export SF_ENV=prod
uvicorn run:khan.server --port 5000
background: true
- run:
name: Running Pytest
command: |
. /etc/profile
export SF_ENV=prod
echo -e "Running tests\n--------"
cd <app_dir>
python3.6 -m pytest -vv tests
- run:
name: Waiting for Application to be ready
command: |
yum install -y nc
for i in `seq 1 30`;
do
nc -z localhost 5000 && echo Success && exit 0
echo "No luck on attempt $i... sleeping 10"
sleep 10
done
echo Failed waiting for Application && exit 1
- run:
name: Run smoke tests
command: |
. /etc/profile
python3.6 app/tests/smoke_test.py
deploy:
docker:
- image: 'docker.vertigo.stitchfix.com:5000/z-etl-py36:latest'
user: root
steps:
- checkout
- run:
name: Deploy if on master
command: |
if [ "${CIRCLE_BRANCH}" == "main" ]; then
. /etc/profile
export STITCHFIX_USER_EMAIL=<user>@stitchfix.com
pip install -U sf-launchpad
cd <app_dir>
launchpad portal deploy --memory 2500 --cpu 1000 --desired-instances 2 --mode prod --working_directory "<app_dir>"
else
echo "Not on main, on $CIRCLE_BRANCH"
fi
version: 2
workflows:
version: 2
build_and_test_and_deploy:
jobs:
- build
- deploy:
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment