Created
November 25, 2019 13:29
-
-
Save djaiss/744757fdce6b5faf9580affc5863c98a to your computer and use it in GitHub Desktop.
Working example on how to use SQLite with a Laravel 6.x installation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit tests | |
on: [push] | |
jobs: | |
phpunit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- 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-suggest --no-progress --prefer-dist | |
- name: Generate key | |
run: php artisan key:generate | |
- name: Create SQLite database | |
run: | | |
mkdir -p database | |
touch database/database.sqlite | |
- name: Run migrations | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
run: php artisan migrate | |
- name: Execute tests via PHPUnit | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
run: vendor/bin/phpunit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some issue with this approach. The migrations go through successfully, but the tests fail: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution . I have a feeling that the configuration in phpunit xml file overrides these env variables (the database there is :memory:) . Any idea?