Skip to content

Commit

Permalink
ci: use memory connection by default in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed May 30, 2024
1 parent b5a5602 commit d6f2875
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
uses: shivammathur/setup-php@2.30.4
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql, decimal
ini-values: error_reporting=E_ALL
coverage: none

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,23 @@ jobs:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 🛠️ Prepare environment
run: |
make env
cp -rf .env app/.env
env:
APP_NAME: laravel
SHARED_SERVICES_NAMESPACE: ss
PROJECT_SERVICES_NAMESPACE: wod
COMPOSE_PROJECT_NAME: laravel-starter-tpl

- name: 🔑 Generate secret application key
working-directory: app
run: php artisan key:generate

- name: 🧪 Collect code coverage with Xdebug and pestphp/pest
run: make test-cc
working-directory: app
run: composer test:cc

- name: 📤 Upload code coverage report to Codecov
uses: codecov/codecov-action@v4.4.1
Expand Down
2 changes: 2 additions & 0 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@
"stan:ci": "php vendor/bin/phpstan analyse --memory-limit=2G --error-format=github",
"test": [
"@putenv XDEBUG_MODE=coverage",
"@putenv DB_CONNECTION=memory",
"php vendor/bin/pest --color=always"
],
"test:cc": [
"@putenv XDEBUG_MODE=coverage",
"@putenv DB_CONNECTION=memory",
"php vendor/bin/pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml --color=always"
]
}
Expand Down
8 changes: 8 additions & 0 deletions app/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
* is supported by Laravel. You're free to add / remove connections.
*/
'connections' => [
'memory' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => ':memory:',
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],

'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
Expand Down
5 changes: 2 additions & 3 deletions app/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
<directory>./src</directory>
</include>
</source>
<php>
Expand All @@ -28,7 +28,6 @@
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="DB_CONNECTION" value="memory"/>
</php>
</phpunit>

0 comments on commit d6f2875

Please sign in to comment.