DEV Community

Guillermo Alfonso Morales
Guillermo Alfonso Morales

Posted on

Execute Django tests in your github actions

When you are trying github actions with your django project, and your database is for example, PostgreSQL, could be a problem running tests in the workflow (personal experience ๐Ÿ˜‹).

The problem is, you don't have an environment or DB engine running inside github actions platform, neither a server where github actions could run tests, then, when is turn of "run tests" step, you'll have this error.

Running django tests with connection error

So, ยฟwhat do we do?.

Well, an easy way to fix this problem is check if your project is running in test mode to change your DB engine to SQLite inside, in this way, github actions could run all tests.

Running django tests Ok

This is my first post in, I hope could help somebody with the same problem I had.

Github actions workflow

Top comments (3)

barnettdalean profile image
Dalean Barnett

How about service containers? Building an application that depends on PostgreSQL and then executing tests based on Sqlite could pose a problem.

sabderemane profile image
Sarah Abd

Haha I've faced to the same problem and I've got another solution, I write an article on that also :

gamorales profile image
Guillermo Alfonso Morales

I was thinking in docker for a second post, you won ๐Ÿ˜Š

Thanks for the feedback.