Continuous integration 如何缓存GitHub操作的安装

Continuous integration 如何缓存GitHub操作的安装,continuous-integration,github-actions,python-poetry,Continuous Integration,Github Actions,Python Poetry,我尝试使用此操作/cache@v2以缓存虚拟机。只安装了两个库pylint和pytest。似乎安装已缓存(缓存大小约26MB)。但是,缓存命中后无法检索它们 运行时找不到缓存安装的库 诗歌运行pip列表 YAML是 我能知道如何使用操作吗/cache@v2缓存诗意安装/virturalenv以避免重新安装依赖项。在YAML文件中使用的是dschep/install诗意-action@v1.3要安装Poetry,将Poetry config virtualenvs.create设置为false,

我尝试使用此
操作/cache@v2
以缓存虚拟机。只安装了两个库
pylint
pytest
。似乎安装已缓存(缓存大小约26MB)。但是,缓存命中后无法检索它们

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

诗歌运行pip列表

YAML是


我能知道如何使用
操作吗/cache@v2
缓存诗意安装/virturalenv以避免重新安装依赖项。

在YAML文件中使用的是
dschep/install诗意-action@v1.3
要安装Poetry,将
Poetry config virtualenvs.create设置为false
,这意味着使用了当前的python解释器/virtualenv。因为您没有在任何地方激活virtualenv,Poyment只是使用系统python,并且
~/.poyment
目录中没有virtualenv

如果您设置了
诗歌配置virtualenvs.create true
,它应该可以工作,例如:

    - name: Install poetry
      uses: dschep/install-poetry-action@v1.3

    - name: Configure poetry
      run: |
        poetry config virtualenvs.create true
        poetry config virtualenvs.in-project false
        poetry config cache-dir ~/.poetry
        poetry config virtualenvs.path ~/.poetry/venv

注意:根据
dschep/install poethy action
的文档,在安装过程中有一个选项可以设置
poethy config virtualenvs.create true
,但目前它似乎已损坏(请参阅)。在任何情况下,我个人更喜欢在与其他所有操作相同的配置块中执行此操作。

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

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

。。。
-名称:安装诗歌
用法:snok/install-poetry@v1.0.0
与:
虚拟人创造:真实
项目中的虚拟人:真
-名称:加载缓存的venv
id:缓存的诗歌依赖项
用途:行动/cache@v2
与:
路径:.venv
关键字:venv-${{runner.os}}-${{hashFiles('**/poetry.lock')}
-名称:安装依赖项
运行:诗歌安装
if:steps.cached-poetry-dependencies.outputs.cache-hit!='真的
...

更完整的示例已记录在案:)

只是一个提示。这些答案中提供的解决方案是正确的。但这一行动已不再持续。查看@Sondre的答案以获得最新的解决方案。感谢您的工作。我已改为接受你的回答,请继续保持你的行动:)
    - name: Install poetry
      uses: dschep/install-poetry-action@v1.3

    - name: Configure poetry
      run: |
        poetry config virtualenvs.create true
        poetry config virtualenvs.in-project false
        poetry config cache-dir ~/.poetry
        poetry config virtualenvs.path ~/.poetry/venv