I wanted to run django test cases inside container. I am able to pull private image from docker hub. but when I ran command to test, It is failed to run.
Anyone tried running test cases inside the container.
jobs:
test:
container:
image: abcd
credentials:
username: "<username>"
password: "<password>"
steps:
- uses: actions/checkout@v2
- name: Display Python version
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: run test
run: |
python3 manage.py test
In my experience, I found out that using GitHub's
containerinstruction causes more confusion than simply running whatever you want on the runner itself, as if you are running it on your own machine.A big majority of the tests I am running on GitHub actions are running in containers, and some require private DockerHub images.
I always do this:
docker-compose.ymlfor development use, so I can test things locally.docker-compose(for example, no volume mappings) - if this is the case, I am creating anotherdocker-compose.ymlin a.cisubfolder.docker-compose.ymlcontains atestservice, that runs whatever test (or test suite) I want.Here is a sample GitHub actions file I am using:
Of course, this entails setting up the two mentioned secrets, but other than that, I found this method to be: