continuous-integration - 如何为 GitHub Actions 缓存诗歌安装
问题描述
我试图用它actions/cache@v2
来缓存诗歌 venv。只有两个库pylint
并pytest
已安装。似乎安装已缓存(缓存大小 ~ 26MB)。但是,缓存命中后无法检索它们。
运行时找不到缓存安装的库
诗歌运行点子列表
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 以避免重新安装依赖项。
解决方案
@northtree 的答案是正确的,但是对于浏览的任何人,您应该知道不再维护 hte 引用的操作。
对于使用版本 >= 1.1.0 的 Poetry 安装,我建议使用此代码段来缓存您的 Poetry 依赖项:
...
- name: Install poetry
uses: snok/install-poetry@v1.0.0
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'
...
此处记录了更完整的示例:)
推荐阅读
- javascript - 如何在JS上将带引号的字符串连接到另一个带多个引号的字符串
- html - 使用 Html/CSS,如何显示重叠/组合的 UNICODE 字符(不使用变音符号)?
- python - 如何使用 Python 程序记录机器重启时间?
- uwp - 生成用于签署通用 Windows 平台 (UWP) 应用程序的证书
- php - include_once 之后的 html 不存在
- anaconda - 更新后 Spyder 无法在 Anaconda 中启动 (4.1.2)
- python - 我如何“pip install”到我在“pyenv”中选择的特定python?
- javascript - 我想在表格中显示一个带有嵌套数组的数组
- assembly - 在 Qtspim 中读取和打印整数
- reactjs - 如何在 React 本机应用程序中的按钮悬停时显示短消息