Skip to content

Commit

Permalink
Cache pipenv virtualenv when running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincarrogan committed Feb 27, 2024
1 parent bd8d5f7 commit 1df3675
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,46 @@ commands:
- checkout
- attach_workspace:
at: ~/repo/tmp
- restore_cache:
keys:
- pipenv-cache-repo-dir-v1-{{ checksum "Pipfile.lock" }}
- run: pipenv install --dev --deploy
- run: git submodule update --init

setup_code_e2e:
steps:
- checkout
- attach_workspace:
at: ~/repo/tmp
- restore_cache:
keys:
- pipenv-cache-circleci-dir-v1-{{ checksum "Pipfile.lock" }}
- run: pipenv install --dev --deploy
- run: git submodule update --init

cache_env_repo_dir:
steps:
- save_cache:
name: Save pipenv cache
key: pipenv-cache-repo-dir-v1-{{ checksum "Pipfile.lock" }}
paths:
- .venv

cache_env_circleci_dir:
steps:
- save_cache:
name: Save pipenv cache
key: pipenv-cache-circleci-dir-v1-{{ checksum "Pipfile.lock" }}
paths:
- /home/circleci/.local/share/virtualenvs/
- /opt/circleci/.pyenv/versions/

backend_unit_tests:
parameters:
alias:
type: string
steps:
- setup_code
- run:
name: Run unit tests
command: |
Expand All @@ -88,6 +120,7 @@ commands:
root: coverage-output
paths:
- .coverage.*
- cache_env_repo_dir

build_api_image:
parameters:
Expand Down Expand Up @@ -136,7 +169,7 @@ commands:
- run:
name: "Install dependencies"
command: pip3 install pipenv
- setup_code
- setup_code_e2e
- build_api_image:
api_branch: <<parameters.api_branch>>
- run: echo $GCLOUD_SERVICE_KEY | docker login -u _json_key --password-stdin https://eu.gcr.io/sre-docker-registry
Expand All @@ -155,6 +188,7 @@ commands:

finish_e2e_tests:
steps:
- cache_env_circleci_dir
- store_artifacts:
path: ui_tests/screenshots
- store_test_results:
Expand Down Expand Up @@ -199,7 +233,6 @@ jobs:
PYTEST_ADDOPTS: unit_tests/caseworker lite_forms/tests.py --capture=no --nomigrations
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler
steps:
- setup_code
- backend_unit_tests:
alias: caseworker

Expand All @@ -214,7 +247,6 @@ jobs:
PYTEST_ADDOPTS: unit_tests/exporter --capture=no --nomigrations
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler
steps:
- setup_code
- backend_unit_tests:
alias: exporter

Expand All @@ -229,7 +261,6 @@ jobs:
PYTEST_ADDOPTS: unit_tests/core --capture=no --nomigrations
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler
steps:
- setup_code
- backend_unit_tests:
alias: core

Expand Down

0 comments on commit 1df3675

Please sign in to comment.