本文介绍了如何为 GitHub Actions 缓存诗歌安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用这个 actions/cache@v2 来缓存诗歌 venv.只安装了 pylintpytest 两个库.似乎安装已缓存(缓存大小 ~ 26MB).但是,缓存命中后无法检索它们.

I tried to use this actions/cache@v2 to cache poetry venv. There are only two libraries pylint and pytest installed. It seems that installation was cached (cache size ~ 26MB). However, they couldn't be retrieved after cache hit.

运行时找不到缓存安装的库

The cache installed libraries are not found while run

诗歌运行点子列表

Package    Version
---------- -------
pip        20.1.1
setuptools 41.2.0

https://github.com/northtree/poetry-github-actions/runs/875926237?check_suite_focus=true#step:9:1

YAML 位于此处.

我能否知道如何使用 actions/cache@v2 来缓存诗歌安装/virturalenv 以避免重新安装依赖项.

Could I know how to use actions/cache@v2 to cache poetry installation / virturalenv to avoid reinstalling dependencies.

推荐答案

@northtree 的回答是正确的,但是对于任何浏览的人来说,您应该知道不再维护 hte 引用的操作.

@northtree's answer is correct, but for anyone browsing, you should know that hte referenced action is no longer maintained.

对于使用 >= 1.1.0 版本的 Poetry 安装,我建议使用此代码段来缓存您的 Poetry 依赖项:

For Poetry installs using versions >= 1.1.0 I'd recommend using this snippet to cache your Poetry dependencies:

...
- name: Install poetry
  uses: snok/[email protected]
  with:
    virtualenvs-create: true
    virtualenvs-in-project: true
- name: Load cached venv
  id: cached-poetry-dependencies
  uses: actions/cache@v2
  with:
    path: .venv
    key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
  run: poetry install
  if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
...

此处记录了更完整的示例:)

More complete examples are documented here :)

这篇关于如何为 GitHub Actions 缓存诗歌安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:23