Skip to content

Instantly share code, notes, and snippets.

@efimk-lu
Created April 3, 2019 13:39
Show Gist options
  • Save efimk-lu/98eb25c9e225d0eed9e28bc8438d9185 to your computer and use it in GitHub Desktop.
Save efimk-lu/98eb25c9e225d0eed9e28bc8438d9185 to your computer and use it in GitHub Desktop.
CircleCI configuration
version: 2.1
defaults: &defaults
working_directory: ~/<repo-name>
docker:
- image: circleci/python:3.7
commands:
checkout_utils:
description: "Checkout utils"
steps:
- run:
command: |
cd ..
git clone git@github.com:lumigo-io/utils.git
checkout_code:
description: "Checkout code and test it"
steps:
- checkout
- run:
# Avoid annoying double runs after deploy.
# See https://discuss.circleci.com/t/job-runs-even-when-tags-ignore-filter-is-triggered-when-combined-with-branches-only/20664
name: Check if tagged
command: |
tags=$(git tag -l --points-at HEAD)
echo "Tags $tags"
if [[ ! -z "$tags" ]]
then
echo "A tagged commit, skip..."
circleci step halt
fi
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
# https://discuss.circleci.com/t/activate-python-virtualenv-for-whole-job/14434
- run: echo "source venv/bin/activate" >> $BASH_ENV
- run: pip install pytest-cov
- run: pip install pre-commit
- run: pre-commit install
- run: curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
- run: sudo apt install nodejs
- run: sudo npm install -g serverless
- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements.txt" }}
workflows:
test-deploy:
jobs:
- test:
filters:
branches:
ignore: master
- deploy:
filters:
branches:
only: master
jobs:
test:
<<: *defaults
steps:
- checkout_code
- checkout_utils
# run tests!
- run: sudo pip install awscli
- run: ./scripts/ci_deploy.sh
- run: pytest --cov=./
- run: ./scripts/checks.sh
- run: bash <(curl -s https://codecov.io/bash)
deploy:
<<: *defaults
steps:
- checkout_code
- checkout_utils
- run: sudo pip install awscli
- run: pytest --cov=./
- run: bash <(curl -s https://codecov.io/bash)
- run: ./scripts/bd_to_prod.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment