Read the dedicated blogpost: https://hofmannsven.com/2020/github-actions-laravel-nova
Last active
May 30, 2024 19:16
-
-
Save hofmannsven/7ea03ec596d88ede45650037a25d47f7 to your computer and use it in GitHub Desktop.
Notes on working with GitHub Actions and Laravel Nova.
This file contains 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
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 |
This file contains 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: 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 |
This file contains 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
<?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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated this config: