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

devSSI's avatar
Level 5

CI issues for laravel project :)

Hello guys, I am learning to make CI for my laravel project and it is not going very well :D

added 38 packages, and audited 39 packages in 2s
7 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
   INFO  Preparing database.  
  Creating migration table ...................................... 15.25ms DONE
   INFO  Running migrations.  
  0001_01_01_000000_create_users_table .......................... 55.07ms DONE
  0001_01_01_000001_create_cache_table .......................... 14.52ms DONE
  0001_01_01_000002_create_jobs_table ........................... 45.88ms DONE
   PASS  Tests\Feature\Auth\LoginTest
  ✓ user is approved and can login                                       0.38s  
  ✓ user cannot login while not approved                                 0.24s  
  ✓ user has only three attempts in a minute                             0.64s  
   PASS  Auth\RegisterTest
  ✓ user can register                                                    0.04s  
  ✓ max one register in minute                                           0.03s  
  ✓ user is missing required field on the register                       0.02s  
  ✓ user did not match password value                                    0.03s  
  Tests:    7 passed (34 assertions)
  Duration: 1.46s
Error: Process completed with exit code 1.

This is the issue I am encountering and this is my ci script

name: Continuous integration actions

on: [push]

jobs:
  tests:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Cache composer dependencies
        uses: actions/cache@v2
        with:
          path: vendor
          key: composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            composer-

      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.2

      - name: Copy .env file
        run: |
          cp .env.ci .env

      - name: Run composer
        run: |
          composer install --no-interaction

      - name: Run test suite
        run: |
          npm install
          php artisan migrate
          php artisan test
        env:
          DB_DATABASE: dbase
          DB_CONNECTION: mysql
          NODE_ENV: test

    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: dbase
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=5s --health-retries=3

0 likes
2 replies
LaryAI's avatar
Level 58

It looks like your CI script is mostly correct, but the error Process completed with exit code 1 indicates that something went wrong during the execution of your script. This could be due to a variety of reasons, such as a failing test, a misconfiguration, or an issue with the environment setup.

Here are a few steps to troubleshoot and potentially resolve the issue:

  1. Check for Failing Tests: Ensure that all your tests are passing. From the output, it seems like all tests are passing, but double-check to make sure there are no hidden issues.

  2. Database Connection: Ensure that your database connection is correctly configured. Sometimes, the database might not be ready when the tests are run. You can add a delay or a retry mechanism to ensure the database is up and running before running migrations and tests.

  3. Verbose Output: Add more verbose output to your CI script to get more details about where it might be failing.

  4. Exit Code Handling: Ensure that your script handles exit codes properly. Sometimes, a non-zero exit code from a command can cause the entire job to fail.

Here is an updated version of your CI script with some additional steps to help debug the issue:

name: Continuous integration actions

on: [push]

jobs:
  tests:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Cache composer dependencies
        uses: actions/cache@v2
        with:
          path: vendor
          key: composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: |
            composer-

      - name: Install PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.2

      - name: Copy .env file
        run: |
          cp .env.ci .env

      - name: Run composer
        run: |
          composer install --no-interaction

      - name: Wait for MySQL to be ready
        run: |
          dockerize -wait tcp://localhost:3306 -timeout 1m

      - name: Run test suite
        run: |
          npm install
          php artisan migrate
          php artisan test
        env:
          DB_DATABASE: dbase
          DB_CONNECTION: mysql
          NODE_ENV: test

    services:
      mysql:
        image: mysql:8.0
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: yes
          MYSQL_DATABASE: dbase
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=5s --health-retries=3

Explanation of Changes:

  1. Wait for MySQL to be Ready: Added a step to wait for the MySQL service to be ready using dockerize. This ensures that the database is up and running before running migrations and tests.
  2. Verbose Output: You can add more verbose output to each step if needed to get more details about the execution.

If the issue persists, you can add more debugging steps, such as printing the contents of the .env file or checking the status of the MySQL service before running the tests. This will help you pinpoint the exact cause of the failure.

devSSI's avatar
Level 5

If there is anyone who agrees with LarryAi it does not work :D

Run dockerize -wait tcp://localhost:3306 -timeout 1m
  dockerize -wait tcp://localhost:3306 -timeout 1m
  shell: /usr/bin/bash -e {0}
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    COMPOSER_NO_AUDIT: 1
/home/runner/work/_temp/567fcfed-149f-49a4-898e-9afde65e277d.sh: line 1: dockerize: command not found
Error: Process completed with exit code 127.

Please or to participate in this conversation.