浏览代码

Fix caching setup for Python dependencies in CircleCI

Thibaud Colas 3 年之前
父节点
当前提交
7523d65d84
共有 2 个文件被更改,包括 12 次插入8 次删除
  1. 10 6
      .circleci/config.yml
  2. 2 2
      setup.cfg

+ 10 - 6
.circleci/config.yml

@@ -4,17 +4,21 @@ jobs:
   backend:
     docker:
       - image: cimg/python:3.8.11
+    environment:
+      PIPENV_VENV_IN_PROJECT: true
     steps:
       - checkout
       - restore_cache:
-          keys:
-            - pip-packages-v1-{{ .Branch }}
-            - pip-packages-v1-
-      - run: pipenv install -e .[testing]
+          key: pipenv-v1-{{ checksum "setup.py" }}
+      # Only install if .venv wasn’t cached.
+      - run: |
+            if [[ ! -e ".venv" ]]; then
+                pipenv install -e .[testing]
+            fi
       - save_cache:
+          key: pipenv-v1-{{ checksum "setup.py" }}
           paths:
-            - ~/.local/
-          key: pip-package-v1-{{ .Branch }}
+            - .venv
       - run: pipenv run flake8
       - run: pipenv run isort --check-only --diff .
       # Filter out known false positives, while preserving normal output and error codes.

+ 2 - 2
setup.cfg

@@ -11,7 +11,7 @@ python-tag = py3
 # W503: line break before binary operator (superseded by W504 line break after binary operator)
 # N806: Variable in function should be lowercase
 ignore = D100,D101,D102,D103,D105,E501,W503,N806
-exclude = wagtail/project_template/*,node_modules,venv
+exclude = wagtail/project_template/*,node_modules,venv,.venv
 max-line-length = 120
 
 [doc8]
@@ -21,7 +21,7 @@ ignore-path = _build,docs/_build
 [isort]
 line_length=100
 multi_line_output=4
-skip=migrations,project_template,node_modules,.git,__pycache__,LC_MESSAGES,venv
+skip=migrations,project_template,node_modules,.git,__pycache__,LC_MESSAGES,venv,.venv
 blocked_extensions=rst,html,js,svg,txt,css,scss,png,snap,tsx
 known_first_party=wagtail
 default_section=THIRDPARTY