Home > Blockchain >  Running django tests in github actions causes Error code 137
Running django tests in github actions causes Error code 137

Time:07-02

I have an app made up of multiple containers that I run with docker-compose. I've tried adding a .yml file to my .github/workflows folder in order to run unit tests on every push to the repo. The containers start up fine but when it comes to the step for running the tests, there is an error:

Error: Process completed with exit code 137.

After looking up that exit code online, I found that this is a memory error but I can't figure out what is causing it and how to fix it. Here is my .yml file for running the tests.

name: django-tests
on: 
    push:
        branches: [develop]

jobs:
  start_docker:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Create env file
        run:  |
              touch .env
              echo POSTGRES_ENGINE=${{ secrets.POSTGRES_ENGINE }} >> .env
              echo POSTGRES_DATABASE=${{ secrets.POSTGRES_DATABASE }} >> .env
              echo POSTGRES_USER=${{ secrets.POSTGRES_USER }} >> .env
              echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env
              echo POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} >> .env
              echo POSTGRES_PORT=${{ secrets.POSTGRES_PORT }} >> .env
              echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
              cat .env
              mv .env project/db

      - name: Start containers
        run: 
              docker-compose -f "docker-compose.yml" up -d --build

      - name: Run tests
        run: docker exec my_app python manage.py test

      - name: Stop containers
        run: docker-compose -f "docker-compose.yml" down

CodePudding user response:

The error was not memory related after all, I didn't set up my github secrets correct. I fixed it by creating a single github secret and added all of my environmental variables as value. The relevant part of the .yml file looked something like this:

 - name: Create env file
        run:  |
              touch .env
              echo "${{ secrets.MAIN }}" >> .env
              cat .env
              mv .env project/db
  • Related