I have created a workflow for Github Actions to automate tests using pytest. When running on GitHub, I get an error.
I have a problem in the form of an error:
Process completed with exit code 137.
after running in my Github Actions workflow the command:
docker compose -f testing.yaml exec api pytest
The problem occurs only running on GitHub, locally using ACT – everything works fine.
.github/workflows/checks.yml
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
// setup envs from secrets
jobs:
linting-and-formatting:
name: Linting and Formatting
runs-on: ubuntu-latest
defaults:
run:
working-directory: api
steps:
- name: Checkout of the repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create and activate virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/development.txt
- name: Check formatting with Black
run: black --check --diff .
- name: Linting with Flake8
run: flake8 .
testing:
needs: linting-and-formatting
name: Testing
runs-on: ubuntu-latest
steps:
- name: Checkout of the repository
uses: actions/checkout@v4
- uses: hoverkraft-tech/[email protected]
with:
compose-file: "testing.yaml"
- name: Execute tests in the running services
run: |
docker compose -f testing.yaml exec api pytest //Here there is an error 137
I searched on the internet thath could be error associated with OOM.
Do you know some solution for this situation?
I found the problem.
It was not directly related to OOM. After adding:
- name: Display container logs if tests fail
if: failure()
run: |
docker compose -f testing.yaml logs
I got information that the creation of the superuser failed which was an error of incorrectly initialized environment variables. After changing it, the tests passed correctly.