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!!!
CodePudding user response:
The error message you were getting indicates that it tried to install python in:
ERROR: No matching distribution found for python
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:
run: |
pip3 install --user django
python manage.py test