Skip to content

Commit e0a500f

Browse files
committed
ci: use memory connection by default in testing
1 parent b5a5602 commit e0a500f

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

.github/workflows/testing.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,23 @@ jobs:
6666
working-directory: app
6767
dependencies: ${{ matrix.dependencies }}
6868

69+
- name: 🛠️ Prepare environment
70+
run: |
71+
make env
72+
cp -rf .env app/.env
73+
env:
74+
APP_NAME: laravel
75+
SHARED_SERVICES_NAMESPACE: ss
76+
PROJECT_SERVICES_NAMESPACE: wod
77+
COMPOSE_PROJECT_NAME: laravel-starter-tpl
78+
6979
- name: 🔑 Generate secret application key
7080
working-directory: app
7181
run: php artisan key:generate
7282

7383
- name: 🧪 Collect code coverage with Xdebug and pestphp/pest
74-
run: make test-cc
84+
working-directory: app
85+
run: composer test:cc
7586

7687
- name: 📤 Upload code coverage report to Codecov
7788
uses: codecov/codecov-action@v4.4.1

app/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@
146146
"stan:ci": "php vendor/bin/phpstan analyse --memory-limit=2G --error-format=github",
147147
"test": [
148148
"@putenv XDEBUG_MODE=coverage",
149+
"@putenv DB_CONNECTION=memory",
149150
"php vendor/bin/pest --color=always"
150151
],
151152
"test:cc": [
152153
"@putenv XDEBUG_MODE=coverage",
154+
"@putenv DB_CONNECTION=memory",
153155
"php vendor/bin/pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml --color=always"
154156
]
155157
}

app/config/database.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
* is supported by Laravel. You're free to add / remove connections.
2424
*/
2525
'connections' => [
26+
'memory' => [
27+
'driver' => 'sqlite',
28+
'url' => env('DB_URL'),
29+
'database' => ':memory:',
30+
'prefix' => '',
31+
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
32+
],
33+
2634
'sqlite' => [
2735
'driver' => 'sqlite',
2836
'url' => env('DB_URL'),

app/phpunit.xml.dist

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</testsuites>
1818
<source>
1919
<include>
20-
<directory suffix=".php">./src</directory>
20+
<directory>./src</directory>
2121
</include>
2222
</source>
2323
<php>
@@ -28,7 +28,6 @@
2828
<env name="QUEUE_CONNECTION" value="sync"/>
2929
<env name="SESSION_DRIVER" value="array"/>
3030
<env name="TELESCOPE_ENABLED" value="false"/>
31-
<env name="DB_CONNECTION" value="sqlite"/>
32-
<env name="DB_DATABASE" value=":memory:"/>
31+
<env name="DB_CONNECTION" value="memory"/>
3332
</php>
3433
</phpunit>

0 commit comments

Comments
 (0)