Skip to content

Commit

Permalink
perf(ci): Reduce installation time in CI
Browse files Browse the repository at this point in the history
Poetry caches artifacts and metadata into
its cache directory to speed things up
in subsequent installations.

Previously we were caching the virtualenv,
but Poetry was still taking a lot of time
to redownload the artifacts to build the
metadata.

Now we cache everything, so Poetry is very
fast both for locking
and installing dependencies.
  • Loading branch information
pawamoy committed Mar 12, 2021
1 parent 10a1410 commit 4a2a3b4
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions project/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ defaults:
shell: bash

env:
LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8"
POETRY_VIRTUALENVS_IN_PROJECT: "true"
PYTHONIOENCODING: "UTF-8"
LANG: en_US.utf-8
LC_ALL: en_US.utf-8
PYTHONIOENCODING: UTF-8

# To fix an error when running Poetry on Windows
# (https://github.com/python-poetry/poetry/issues/2629),
# we set Poetry's cache directory to .poetry_cache in the current directory.
# It makes it easier to later remove the virtualenv when it's broken.
# Absolute path is necessary to avoid this issue:
# https://github.com/python-poetry/poetry/issues/3049
POETRY_CACHE_DIR: ${{ github.workspace }}/.poetry_cache

jobs:

Expand All @@ -33,17 +40,17 @@ jobs:
with:
python-version: 3.8

- name: Set up Poetry
run: pip install poetry

- name: Set up the cache
uses: actions/cache@v1
with:
path: .venv
key: quality-venv-cache
path: .poetry_cache
key: quality-poetry-cache

- name: Set up the project
run: |
pip install poetry
poetry install -vvv || { rm -rf .venv; poetry install -vvv; }
poetry update
run: poetry install -vv

- name: Check if the documentation builds correctly
run: poetry run duty check-docs
Expand Down Expand Up @@ -77,17 +84,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
run: pip install poetry

- name: Set up the cache
uses: actions/cache@v1
with:
path: .venv
key: tests-venv-cache-${{ matrix.os }}-py${{ matrix.python-version }}
path: .poetry_cache
key: tests-poetry-cache-${{ matrix.os }}-py${{ matrix.python-version }}

- name: Set up the project
run: |
pip install poetry
poetry install -vvv || { rm -rf .venv; poetry install -vvv; }
poetry update
run: poetry install -vv || { rm -rf .poetry_cache/virtualenvs/*; poetry install -vv; }

- name: Run the test suite
run: poetry run duty test

0 comments on commit 4a2a3b4

Please sign in to comment.