英文:
How to create a virtual environment with github actions that can be used by other jobs at the same yaml file?
问题
我正在尝试创建 Python 虚拟环境,但在任务完成后它就“死了”,而我想在其他任务中使用这个虚拟环境。我应该怎么做?
我考虑使用缓存,但对于这个选项我了解不够。
英文:
I'm trying to create python venv, but it's "dead" when the job is finished, and I want to use the venv in other jobs. What should I do?
I thought of using cache, but I'm not familiar enough with this option.
答案1
得分: 1
- name: 存档代码覆盖率结果
uses: actions/upload-artifact@v3
with:
name: venv
path: .venv
然后确保将来的作业在创建工件的作业上声明 needs:
。
然后使用 download-artifact 再次下载:
- name: 下载单个工件
uses: actions/download-artifact@v3
with:
name: venv
英文:
You can use workflow artifacts to carry data from one job to the next.
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: venv
path: .venv
Then make sure the future jobs declare a needs:
on the job that created the artifact.
And download it again with download-artifact:
- name: Download a single artifact
uses: actions/download-artifact@v3
with:
name: venv
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论