GitHub Actions and Laravel Nova
Read the dedicated blogpost: https://hofmannsven.com/2020/github-actions-laravel-nova
APP_ENV=ci | |
APP_KEY= | |
APP_DEBUG=true | |
APP_URL=https://localhost | |
LOG_CHANNEL=stack | |
DB_CONNECTION=mysql | |
DB_HOST=127.0.0.1 | |
DB_PORT=33306 | |
DB_DATABASE=database_ci | |
DB_USERNAME=user | |
DB_PASSWORD=secret | |
SESSION_DRIVER=array | |
CACHE_DRIVER=array | |
QUEUE_DRIVER=sync | |
MAIL_DRIVER=log |
Read the dedicated blogpost: https://hofmannsven.com/2020/github-actions-laravel-nova
name: Tests | |
on: [push] | |
jobs: | |
tests: | |
name: Run tests | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_DATABASE: database_ci | |
MYSQL_USER: user | |
MYSQL_PASSWORD: secret | |
MYSQL_ROOT_PASSWORD: secretroot | |
ports: | |
- 33306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Verify MySQL connection | |
run: | | |
mysql --version | |
sudo apt-get install -y mysql-client | |
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uuser -psecret -e "SHOW DATABASES" | |
- name: Cache composer dependencies | |
uses: actions/cache@v1 | |
with: | |
path: vendor | |
key: composer-${{ hashFiles('composer.lock') }} | |
- name: Install dependencies | |
run: | | |
php --version | |
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_PASSWORD }}" | |
composer install -n --prefer-dist | |
- name: Boot Laravel application | |
run: | | |
cp .env.github .env | |
php artisan key:generate | |
php artisan --version | |
- name: Migrate database | |
run: | | |
mysql --version | |
php artisan migrate:fresh --seed | |
- name: Cache yarn dependencies | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: yarn-${{ hashFiles('yarn.lock') }} | |
- name: Run yarn | |
run: | | |
yarn --version | |
yarn && yarn dev | |
- name: Run tests | |
run: | | |
./vendor/bin/phpunit --version | |
./vendor/bin/phpunit | |
- name: Run security checks | |
run: | | |
test -d security-checker || git clone https://github.com/sensiolabs/security-checker.git | |
cd security-checker | |
composer install | |
php security-checker security:check ../composer.lock | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
if: failure() | |
with: | |
name: Logs | |
path: ./storage/logs |
<?xml version="1.0" encoding="UTF-8"?> | |
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | |
backupGlobals="false" | |
backupStaticAttributes="false" | |
bootstrap="vendor/autoload.php" | |
colors="true" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" | |
processIsolation="false" | |
stopOnFailure="false"> | |
<testsuites> | |
<testsuite name="Unit"> | |
<directory suffix="Test.php">./tests/Unit</directory> | |
</testsuite> | |
<testsuite name="Feature"> | |
<directory suffix="Test.php">./tests/Feature</directory> | |
</testsuite> | |
</testsuites> | |
<filter> | |
<whitelist processUncoveredFilesFromWhitelist="true"> | |
<directory suffix=".php">./app</directory> | |
</whitelist> | |
</filter> | |
<php> | |
<server name="APP_ENV" value="testing"/> | |
<server name="BCRYPT_ROUNDS" value="4"/> | |
<server name="CACHE_DRIVER" value="array"/> | |
<server name="DB_CONNECTION" value="sqlite"/> | |
<server name="DB_DATABASE" value=":memory:"/> | |
<server name="MAIL_DRIVER" value="array"/> | |
<server name="QUEUE_CONNECTION" value="sync"/> | |
<server name="SESSION_DRIVER" value="array"/> | |
</php> | |
</phpunit> |
I've updated this config: