Hey,
I am trying to setup a github action to execute my tests. While my tests are passing locally they fail when executed from the action (I am using Laravel 8 TestView assertions).
This is the relevant part from the action logs:
3T14:46:46.2268843Z
2020-06-23T14:46:46.2268958Z Time: 00:00.736, Memory: 32.00 MB
2020-06-23T14:46:46.2269015Z
2020-06-23T14:46:46.2269118Z There were 25 errors:
2020-06-23T14:46:46.2269173Z
2020-06-23T14:46:46.2269436Z 1) Wingly\WinglyUI\Tests\Components\Cards\CardTest::test_it_renders_with_full_size_by_default
2020-06-23T14:46:46.2327657Z ErrorException: View [components.cards.card] not found. (View: /tmp/laravel-bladeW5bxz4.blade.php)
2020-06-23T14:46:46.2327773Z
2020-06-23T14:46:46.2329267Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php:137
2020-06-23T14:46:46.2329672Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:43
2020-06-23T14:46:46.2330017Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:57
2020-06-23T14:46:46.2331511Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/View.php:139
2020-06-23T14:46:46.2331845Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/View.php:122
2020-06-23T14:46:46.2332157Z /home/runner/work/wingly-ui/wingly-ui/vendor/laravel/framework/src/Illuminate/View/View.php:91
2020-06-23T14:46:46.2334577Z /home/runner/work/wingly-ui/wingly-ui/tests/TestView.php:34
2020-06-23T14:46:46.2334875Z /home/runner/work/wingly-ui/wingly-ui/tests/InteractsWithViews.php:44
2020-06-23T14:46:46.2335167Z /home/runner/work/wingly-ui/wingly-ui/tests/Components/Cards/CardTest.php:11
2020-06-23T14:46:46.2335234Z
This is the function from laravel InteractsWithViews where I locate the issue
protected function blade(string $template, array $data = [])
{
$tempDirectory = sys_get_temp_dir();
if (! in_array($tempDirectory, ViewFacade::getFinder()->getPaths())) {
ViewFacade::addLocation(sys_get_temp_dir());
}
$tempFile = tempnam($tempDirectory, 'laravel-blade') . '.blade.php';
file_put_contents($tempFile, $template);
return new TestView(view(Str::before(basename($tempFile), '.blade.php'), $data));
}
As i already said the tests are running fine locally and the actual view exists and works if tested in the browser too.
I am assuming that it has something to do with the tmp directory but tbh i have no clue.
Does anyone here run into something similar or has a bit more knowledge than me in github actions ?
This is my workflow file:
name: tests
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
laravel: [^7.0]
name: P${{ matrix.php }} - L${{ matrix.laravel }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
coverage: none
- name: Install dependencies
run: composer require "illuminate/contracts=${{ matrix.laravel }}" --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --verbose