Improve Github Actions and add Laravel Pint check

This commit is contained in:
Jonny Barnes 2022-07-09 10:56:03 +01:00
parent f763532199
commit 21deb53727
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
3 changed files with 106 additions and 49 deletions

68
.github/workflows/phpunit.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: PHP Unit
on:
pull_request:
jobs:
phpunit:
runs-on: ubuntu-latest
name: PHPUnit test suite
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: jbukdev_testing
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node and dependencies
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm ci
- name: Setup PHP with pecl extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: phpredis,imagick
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.github', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install --quiet --no-ansi --no-interaction --no-progress
- name: Generate Key
run: php artisan key:generate
- name: Setup Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Setup Database
run: php artisan migrate
- name: Execute PHPUnit Tests
run: vendor/bin/phpunit

38
.github/workflows/pint.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: Laravel Pint
on:
pull_request:
jobs:
pint:
runs-on: ubuntu-latest
name: Laravel Pint
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP with pecl extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install --quiet --no-ansi --no-interaction --no-progress
- name: Check Files with Laravel Pint
run: vendor/bin/pint --test

View file

@ -1,49 +0,0 @@
name: Run Tests
on:
pull_request:
jobs:
phpunit:
runs-on: ubuntu-20.04
name: PHPUnit test suite
services:
postgres:
image: postgres:13.4
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: jbukdev_testing
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- name: Install npm dependencies
run: npm install
- name: Setup PHP with pecl extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: phpcs
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.github', '.env');"
- name: Install dependencies
run: composer install --quiet --no-ansi --no-interaction --no-progress
- name: Generate key
run: php artisan key:generate
- name: Setup directory permissions
run: chmod -R 777 storage bootstrap/cache
- name: Setup test database
run: php artisan migrate
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit
- name: Run phpcs
run: phpcs