我正在构建一个Python项目——
potion
。在将新分支合并到 master 之前,我想使用 Github 操作来自动执行一些 linting 和测试。
为此,我对 Github 推荐的 python 操作启动工作流程进行了轻微修改 - Python 应用程序。
在作业中的“安装依赖项”步骤中,我收到错误。这是因为 pip 正在尝试安装我的本地软件包
potion
但失败了。
失败的代码
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
对应的错误是:
ERROR: [email protected]:<github_username>/potion.git@82210990ac6190306ab1183d5e5b9962545f7714#egg=potion is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp, bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http, hg+https, hg+ssh, hg+static-http, svn+ssh, svn+http, svn+https, svn+svn, svn+file).
Error: Process completed with exit code 1.
最有可能的是,该作业无法安装该软件包
potion
,因为它无法找到它。我使用 pip install -e .
将其安装在自己的计算机上,然后使用 pip freeze > requirements.txt
创建需求文件。
由于我使用这个包进行测试,因此我需要安装这个包,以便 pytest 可以正确运行其测试。
如何在 Github Actions 上安装本地包(正在积极开发中)?
python-app.yml
...
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
...
注1:我已经尝试过从
[email protected]:<github_username>...
更改为[email protected]/<github_username>...
。注意/
而不是:
。
注2:我还尝试过使用其他协议,例如
git+https
,git+ssh
等
注3:我还尝试删除 git url
@8221...
之后的字母数字
...potion.git
“正在测试的包”,
potion
在您的情况下,不应该是requirements.txt的一部分。相反,只需添加您的行
pip install -e .
在包含
pip install -r requirements.txt
的行之后。这会在开发模式下安装已经签出的软件包,并使其在本地可供 import
使用。
或者,您可以将该行放在最近需要的点,即在运行之前
pytest
。
名称:更新 Play 商店列表
在: 工作流程_调度:
工作: 更新: 运行:ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo pip3 install google-api-python-client oauth2client
- name: Update listing
run: python3 update-listing.py
env:
SERVICEACCOUNT: ${{ secrets.SERVICEACCOUNT }}
SERVICEACCOUNT_EMAIL: ${{ secrets.SERVICEACCOUNT_EMAIL }}