EmilMoe's avatar
Level 10

Github Action failed: Test directory not found

My Github action is failing due to the file path.

Any ideas?

I'm using the almost default action there for Laravel:

name: Laravel

on:
  push:
    branches: [ dev, master ]
  pull_request:
    branches: [ dev, master ]

jobs:
  laravel-tests:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Setup PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '7.4' 
    - name: Install Node Dependencies
      run: touch ~/.npmrc \
        && echo "@***:registry=http://npm.***.com/" > ~/.npmrc \
        && echo "//npm.***.com/:_authToken=\"${{ secrets.NPM_AUTH_TOKEN }}\"" >> ~/.npmrc \
        && echo "unsafe-perm=true" >> ~/.npmrc \
        && npm install
    - name: Copy .env
      run: php -r "file_exists('.env') || copy('.env.example', '.env');"
    - name: Install Dependencies
      run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
    - name: Generate key
      run: php artisan key:generate
    - name: Directory Permissions
      run: chmod -R 777 storage bootstrap/cache
    - name: Create Database
      run: |
        mkdir -p database
        touch database/database.sqlite
    - name: Execute tests (Unit and Feature tests) via PHPUnit
      env:
        DB_CONNECTION: sqlite
        DB_DATABASE: database/database.sqlite
      run: vendor/bin/phpunit
0 likes
9 replies
EmilMoe's avatar
Level 10

Forgot the actual error:

Test directory "/home/runner/work/project/project/./tests/Unit" not found
Error: Process completed with exit code 2.

ssi-anik's avatar

It happened to me as well. Then I found that the test suite was not pointing to the correct directory. Then I changed and working fine now. What's the case for you?

Wolli's avatar

I had the same problem. I had no unit tests in my unit folder because I deleted them. However, the folder was still visible in the local git repository. When uploading to production, the folder was removed by git and the test failed. So there must be at least one unit test, or another file, such as a .gitignore in this folder

10 likes
murilo's avatar

I had the same proble . I had no solution .

BinotaLIU's avatar

If your local file system is case-insensitive, check if the case are matching the one set in phpunit.xml. E.g. the folder is using lowercase unit, but capitalised Unit is specified in phpunit.xml.

Please or to participate in this conversation.