Updated CI Workflows

This commit is contained in:
Refringe 2024-05-31 20:09:12 -04:00
parent c59615d7ac
commit 21bf4ae55b
Signed by: Refringe
GPG Key ID: 7715B85B4A6306ED
6 changed files with 286 additions and 163 deletions

View File

@ -9,11 +9,11 @@ LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug LOG_LEVEL=debug
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=localhost DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=33306
DB_DATABASE=test DB_DATABASE=test
DB_USERNAME=mysql DB_USERNAME=root
DB_PASSWORD=mysql DB_PASSWORD=
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
FILESYSTEM_DISK=local FILESYSTEM_DISK=local

View File

@ -1,159 +0,0 @@
name: Forge CI
on: push
jobs:
laravel-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: mysql
MYSQL_DATABASE: test
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Cache NPM
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-cache-
- name: Install NPM Packages
run: npm ci
- name: Build Frontend
run: npm run build
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none
- name: Configure Laravel Nova Authentication
shell: bash
env:
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }}
run: |
composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
- name: Get Composer Cache Directory
id: composer-cache
run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ${{ env.composer_cache_dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install -n --prefer-dist
- name: Prepare Laravel Application
run: |
cp .env.ci .env
php artisan key:generate
- name: Set Application Cache Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Run Database Migrations
env:
DB_CONNECTION: mysql
DB_DATABASE: test
DB_PORT: 3306
DB_USERNAME: mysql
DB_PASSWORD: mysql
run: php artisan migrate
- name: Execute Unit and Feature Tests
env:
DB_CONNECTION: mysql
DB_DATABASE: test
DB_PORT: 3306
DB_USERNAME: mysql
DB_PASSWORD: mysql
run: vendor/bin/pest
- name: Upload App Logs
if: failure()
uses: actions/upload-artifact@v2
with:
name: app
path: storage/logs
security-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Security Checker
uses: symfonycorp/security-checker-action@v5
larastan:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none
- name: Configure Laravel Nova Authentication
shell: bash
env:
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }}
run: |
composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
- name: Get Composer Cache Directory
id: composer-cache
run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV
- name: Cache Composer Dependencies
uses: actions/cache@v3
with:
path: ${{ env.composer_cache_dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install -n --no-dev --prefer-dist
- name: Execute Code Static Analysis with Larastan
run: |
composer require --dev larastan/larastan
vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress

67
.github/workflows/larastan.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Laravel Pest Tests
on:
pull_request:
push:
branches:
- main
- develop
jobs:
larastan:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none
- name: Configure Laravel Nova Authentication
shell: bash
env:
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }}
run: |
composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v4
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.ci', '.env');"
- name: Install Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Update Dependencies with latest stable
if: matrix.dependency-stability == 'prefer-stable'
run: composer update --prefer-stable
- name: Execute Code Static Analysis with Larastan
run: |
composer require --dev larastan/larastan
vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress

67
.github/workflows/pint.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Pint Code Style Fixer
on:
pull_request:
push:
jobs:
pint-fixer:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none
- name: Configure Laravel Nova Authentication
shell: bash
env:
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }}
run: |
composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v4
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Install Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Update Dependencies with latest stable
if: matrix.dependency-stability == 'prefer-stable'
run: composer update --prefer-stable
- name: Pint Code Style Fixer
run: vendor/bin/pint fix
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Apply pint code style changes

16
.github/workflows/security.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Security Check
on:
pull_request:
push:
jobs:
security-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Security Checker
uses: symfonycorp/security-checker-action@v5

132
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,132 @@
name: Laravel Pest Tests
on:
pull_request:
push:
branches:
- main
- develop
jobs:
laravel-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.3
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: test
ports:
- 33306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.3']
dependency-stability: ['prefer-stable']
name: P${{ matrix.php-versions }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Cache node_modules Directory
uses: actions/cache@v4
id: node_modules-cache
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install NPM Packages
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build Frontend
run: npm run build
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none
- name: Configure Laravel Nova Authentication
shell: bash
env:
NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }}
NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }}
run: |
composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v4
id: vendor-cache
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.ci', '.env');"
- name: Install Dependencies
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Update Dependencies with latest stable
if: matrix.dependency-stability == 'prefer-stable'
run: composer update --prefer-stable
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Run Migrations
env:
DB_CONNECTION: mysql
DB_DATABASE: test
DB_PORT: 33306
DB_USER: root
run: php artisan migrate
- name: Execute Unit & Feature Tests
env:
DB_CONNECTION: mysql
DB_DATABASE: test
DB_PORT: 33306
DB_USER: root
run: vendor/bin/pest
- name: Upload App Logs
if: failure()
uses: actions/upload-artifact@v2
with:
name: app
path: storage/logs