Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Foks's avatar
Level 15

GitHub Actions fails with weird message.

I recently attempted to add PHPStan to my GitHub actions, and it failed horribly - when I then reverted my GitHub actions kept failing, and it seems like it doesn't run my PHPUnit tests. The error that it outputs is the following:

Run php artisan test --parallel
Warning: TTY mode requires /dev/tty to be read/writable.
..F.
In WorkerCrashedException.php line 36:
                                                                               
  The command "'/home/runner/work/lectero/lectero/vendor/phpunit/phpunit/phpu  
  nit' '--configuration' '/home/runner/work/lectero/lectero/phpunit.xml' '--n  
  o-logging' '--no-coverage' '--printer' 'ParaTest\Runners\PHPUnit\Worker\Nul  
  lPhpunitPrinter' '--log-junit' '/tmp/PT_LNbTql' '/home/runner/work/lectero/  
  lectero/Modules/Fortify/Tests/Feature/FortifyHomeworkTest.php'" failed.      
                                                                               
  Exit Code: 137(Kill (terminate immediately))                                 
                                                                               
  Working directory: /home/runner/work/lectero/lectero                         
                                                                               
  Output:                                                                      
  ================                                                             
                                                                               
                                                                               
  Error Output:                                                                
  ================                                                             
                                                                               

paratest [--bootstrap BOOTSTRAP] [--colors] [-c|--configuration CONFIGURATION] [--coverage-clover COVERAGE-CLOVER] [--coverage-cobertura COVERAGE-COBERTURA] [--coverage-crap4j COVERAGE-CRAP4J] [--coverage-html COVERAGE-HTML] [--coverage-php COVERAGE-PHP] [--coverage-test-limit COVERAGE-TEST-LIMIT] [--coverage-text [COVERAGE-TEXT]] [--coverage-xml COVERAGE-XML] [--exclude-group EXCLUDE-GROUP] [--filter FILTER] [-f|--functional] [-g|--group GROUP] [-h|--help] [--log-junit LOG-JUNIT] [--log-teamcity LOG-TEAMCITY] [-m|--max-batch-size MAX-BATCH-SIZE] [--no-coverage] [--no-test-tokens] [--order-by [ORDER-BY]] [--parallel-suite] [--passthru PASSTHRU] [--passthru-php PASSTHRU-PHP] [--path PATH] [-p|--processes PROCESSES] [--random-order-seed [RANDOM-ORDER-SEED]] [--repeat [REPEAT]] [--runner RUNNER] [--stop-on-failure] [--testsuite TESTSUITE] [--tmp-dir TMP-DIR] [-v|vv|--verbose] [--whitelist WHITELIST] [--] [<path>]

Error: Process completed with exit code 1.

My build.yml file:

name: Build Tests

on:
  push:
    branches: [ 'master', 'develop' ]
  pull_request:
    branches: [ 'develop' ]

jobs:

  laravel_tests:
    runs-on: ubuntu-latest
    name: PHPUnit
    strategy:
      fail-fast: true
      matrix:
        php: [ 8.0 ]
        laravel: [ ^8.0 ]
        stability: [ prefer-lowest, prefer-stable ]
    services:
      mysql-service:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: lectero
        ports:
          - 33306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
          tools: composer:v2
          coverage: none

      - name: Install dependencies
        run: |
          composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
          composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
          composer update --prefer-dist --no-interaction --no-progress
      - name: Copy .env
        run: php -r "file_exists('.env') || copy('.env.example', '.env');"

      - name: Generate key
        run: php artisan key:generate

      - name: Directory Permissions
        run: chmod -R 777 storage bootstrap/cache

      - name: Execute tests
        continue-on-error: ${{ matrix.php > 8 }}
        run: php artisan test --parallel
        env:
          DB_PORT: ${{ job.services.mysql.ports[3306] }}
          DB_USERNAME: root

  php_laravel_test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        php: [ 8.0 ]
        laravel: [ ^8.0 ]
        stability: [ prefer-lowest, prefer-stable ]
    services:
      mysql-service:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: lectero
        ports:
          - 33306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    name: PHP ${{ matrix.php }} - L${{ matrix.laravel }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
          tools: composer:v2
          coverage: none

      - name: Install dependencies
        run: |
          composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
          composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
          composer update --prefer-dist --no-interaction --no-progress
      - name: Copy .env
        run: php -r "file_exists('.env') || copy('.env.example', '.env');"

      - name: Generate key
        run: php artisan key:generate

      - name: Directory Permissions
        run: chmod -R 777 storage bootstrap/cache

      - name: Execute tests
        continue-on-error: ${{ matrix.php > 8 }}
        run: php artisan test --parallel
        env:
          DB_PORT: ${{ job.services.mysql.ports[3306] }}
          DB_USERNAME: root

  linux_tests:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: true
      matrix:
        php: [ 8.0 ]
        laravel: [ ^8.0 ]
        stability: [ prefer-lowest, prefer-stable ]
    services:
      mysql-service:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: lectero
        ports:
          - 33306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

    name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - Linux

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, memcached
          tools: composer:v2
          coverage: none

      - name: Install dependencies
        run: |
          composer require "illuminate/contracts=${{ matrix.laravel }}" --no-update
          composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
          composer update --prefer-dist --no-interaction --no-progress
      - name: Copy .env
        run: php -r "file_exists('.env') || copy('.env.example', '.env');"

      - name: Generate key
        run: php artisan key:generate

      - name: Directory Permissions
        run: chmod -R 777 storage bootstrap/cache

      - name: Execute tests
        continue-on-error: ${{ matrix.php > 8 }}
        run: php artisan test --parallel
        env:
          DB_PORT: ${{ job.services.mysql.ports[3306] }}
          DB_USERNAME: root

The build.yml is the exact same as it was before the changes that was made to add PHPStan.

0 likes
2 replies
Jpswade's avatar

Did you ever solve this?

I'm seeing a similar problem in CircleCI.

The 137 exit code is an OOM (out of memory) issue, there's a post about it here (only it talks about Java):

https://support.circleci.com/hc/en-us/articles/115014359648-Exit-code-137-Out-of-memory

It could be because I'm reading a PDF file into memory, but it's only 1.8K and there should be 4G available.

When I run the test locally it says

Time: 00:03.669, Memory: 62.50 MB

OK (1 test, 4 assertions)
Process finished with exit code 0

I imagine GitHub actions also have non-burstable instances which is why you end up with an exit code of 137.

My guess is there's a memory leak, perhaps on another thread that phpunit has no visibility of memory usage. I don't see a trivial way to debug this.

What I've done so far is avoid giving PHP unlimited memory, which in theory means PHP should run out of memory before the instance does, meaning we'll get a PHP error at the point it runs out of memory rather than an OOM error.

Foks's avatar
Level 15

@Jpswade Unfortunately I didn't solve this. I ended up disabling it.

Please or to participate in this conversation.