CS50W讲座7测试,CI/CD-关于YAML和GitHub动作的问题
我正在使用Python和JavaScript(CS50W)课程参加CS50的Web编程。我现在有一个问题讲座7测试,CI/CD 。当我跟随Brian在GitHub Action部分(大约1:13:36的时间戳记)中时,我的Github动作的结果与他的行为不一样。
这是YAML代码(我完全从演讲中复制):
name: Testing
on: push
jobs:
test_project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Django unit tests
run:
pip3 install --user django
python manage.py test
在他的GitHub动作中,“运行Django单元测试”部分没有错。但是我的事实遇到了一些错误。我在github动作中的结果显示为 this
Run pip3 install --user django python manage.py test
pip3 install --user django python manage.py test
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
ERROR: Could not find a version that satisfies the requirement python (from versions:
none)
ERROR: No matching distribution found for python
Error: Process completed with exit code 1.
在github ubuntu虚拟机中设置django或python有问题,然后我试图摆脱yaml文件中的python manage.py test
语法,以及“运行django单位测试”在GitHub动作中,没有任何错误。结果显示 at (单击以查看屏幕截图)
Run pip3 install --user django
pip3 install --user django
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
Downloading asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting backports.zoneinfo; python_version < "3.9"
Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
Installing collected packages: asgiref, backports.zoneinfo, sqlparse, django
Successfully installed asgiref-3.5.0 backports.zoneinfo-0.2.1 django-4.0.3 sqlparse-
0.4.2
似乎已成功安装了Django。但是,python manage.py Test.py Test
语法在YAML文件中添加了什么问题?我完全不知道。有人可以指出吗?多谢!您可能想看看我的github reposority 为此。如果您需要更多信息,请告诉我。谢谢!!!
I am taking CS50’s Web Programming with Python and JavaScript(CS50W) course. I am now having a problem for lecture 7 Testing, CI/CD. When I followed along Brian in the GitHub Actions section(Timestamp at about 1:13:36), the result in my GitHub Actions turned out not to be the same with his.
This is the yaml code( I exactly copied from the lecture) :
name: Testing
on: push
jobs:
test_project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Django unit tests
run:
pip3 install --user django
python manage.py test
In his GitHub Actions there was nothing wrong about the "run django unit tests" part. But Mine turned out to have some errors. My result in GitHub Actions showed as this(Click to see the screenshot):
Run pip3 install --user django python manage.py test
pip3 install --user django python manage.py test
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
ERROR: Could not find a version that satisfies the requirement python (from versions:
none)
ERROR: No matching distribution found for python
Error: Process completed with exit code 1.
So I thought there was something wrong for setting up django or python in the GitHub Ubuntu virtual machine, then I tried to get rid of the python manage.py test
syntax in the yaml file, and the "run django unit tests" in GitHub Actions turned out no errors. The result showed as(Click to see the screenshot)
Run pip3 install --user django
pip3 install --user django
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
Downloading asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting backports.zoneinfo; python_version < "3.9"
Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
Installing collected packages: asgiref, backports.zoneinfo, sqlparse, django
Successfully installed asgiref-3.5.0 backports.zoneinfo-0.2.1 django-4.0.3 sqlparse-
0.4.2
It seems django was successfully installed. But what went wrong when the python manage.py test
syntax was added in the yaml file? I completely have no idea. Can someone point it out? Thanks a lot! You might wanna have a look at my GitHub repository for this. If your need more infomation please just tell me. THANKS!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到的错误消息指示它试图在以下位置安装Python:
但是Python指的是您的第二个命令,
python manage.py Test
,因此错误消息表示它正在尝试运行两个命令作为一个命令单个命令。
运行多个命令时,您必须包括
|
字符,因此GitHub Actions知道有多个命令要运行。在讲座中,您可以看到Brian包括了必要的|
字符:The error message you were getting indicates that it tried to install python in:
but python refers to your second command,
python manage.py test
So the error message indicates that it is trying to run two commands as one single command.
When running multiple commands, you have to include the
|
character, so Github Actions understands that there are multiple commands to be run. In the lecture you can see that Brian included the necessary|
character: