Skip to content

Commit

Permalink
use circleci cache to speed up builds (#1242)
Browse files Browse the repository at this point in the history
Setup the circleci cache and workspace settings to speed
up sceptre build and tests pipelines.

* reduce the build pipeline time from ~5 min to 1 min
* reduce the lint-and-unit-tests pipeline from ~6 min to ~3 mins
  • Loading branch information
zaro0508 committed Jun 14, 2022
1 parent f994eb7 commit 78f8d7c
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ jobs:
name: 'Creating Virtualenv'
command: |
pyenv virtualenv 3.9.4 venv
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
- run:
name: 'Installing Requirements'
name: 'Installing Dependencies'
command: |
pyenv global venv
pip install -r requirements/prod.txt
pip install -r requirements/dev.txt
make install-dev
- save_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
paths:
- .pyenv/versions/3.9.4/envs/venv
- ../.pyenv/versions/3.9.4/envs/venv
- run:
name: 'Installing Sceptre'
command: |
Expand All @@ -60,7 +64,8 @@ jobs:
- persist_to_workspace:
root: /home/circleci
paths:
- .
- project
- .pyenv

lint-and-unit-tests:
docker:
Expand All @@ -69,37 +74,32 @@ jobs:
- attach_workspace:
at: /home/circleci
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
keys:
- sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum "requirements/dev.txt" }}
- sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}-{{ checksum "tox.ini" }}
- run:
name: 'Linting'
command: |
pyenv global venv
make lint
- run:
name: 'Unit Test'
command: |
pyenv global venv
make test-all
- store_test_results:
path: coverage.xml
destination: coverage-reports

- persist_to_workspace:
root: /home/circleci
paths:
- .

- save_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-tox-requirements-{{ arch
sceptre-{{ .Environment.CACHE_VERSION }}-{{ arch
}}-{{ checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}-{{ checksum "tox.ini" }}
paths:
- .tox
- store_test_results:
path: coverage.xml
destination: coverage-reports

integration-tests:
parallelism: 2
Expand All @@ -112,7 +112,7 @@ jobs:
at: /home/circleci
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-requirements-{{ arch }}-{{
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
- run:
Expand Down Expand Up @@ -159,6 +159,16 @@ jobs:
steps:
- attach_workspace:
at: /home/circleci
- restore_cache:
key:
sceptre-{{ .Environment.CACHE_VERSION }}-dependencies-{{ arch }}-{{
checksum "requirements/prod.txt" }}-{{ checksum
"requirements/dev.txt" }}
- run:
name: 'Installing Dependencies'
command: |
pyenv global venv
make install-dev
- run:
name: 'Create Distributions'
command: |
Expand Down

0 comments on commit 78f8d7c

Please sign in to comment.