Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Laravel pint & prettier #50

Merged
merged 5 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/restyled.yml

This file was deleted.

98 changes: 49 additions & 49 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,62 @@ name: Laravel

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
laravel-tests:
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov

- name: Checkout repository
uses: actions/checkout@v3

- 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-progress --prefer-dist

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite

- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit --verbose --coverage-clover coverage.xml

- name: Upload Logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: logs
path: storage/logs

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: tests
verbose: true
fail_ci_if_error: true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: pcov

- name: Checkout repository
uses: actions/checkout@v3

- 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-progress --prefer-dist

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite

- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit --verbose --coverage-clover coverage.xml

- name: Upload Logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: logs
path: storage/logs

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: tests
verbose: true
fail_ci_if_error: true

build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Laravel Pint

on:
workflow_dispatch:
pull_request:
paths:
- '**.php'

permissions:
contents: write

jobs:
laravel-pint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/[email protected]
with:
useComposer: true

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: >
chore: styling

42 changes: 0 additions & 42 deletions .github/workflows/publish.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public
vendor
storage
node_modules
19 changes: 19 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"sortTailwindcssClasses": true,
"sortHtmlAttributes": "code-guide",
"plugins": ["@shufo/prettier-plugin-blade"],
"overrides": [
{
"files": [
"*.blade.php"
],
"options": {
"tabWidth": 4,
"parser": "blade"
}
}
]
}
1 change: 0 additions & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class CreateNewUser implements CreatesNewUsers
/**
* Validate and create a newly registered user.
*
* @param array $input
* @return \App\Models\User
*/
public function create(array $input)
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Fortify/ResetUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ResetUserPassword implements ResetsUserPasswords
* Validate and reset the user's forgotten password.
*
* @param mixed $user
* @param array $input
* @return void
*/
public function reset($user, array $input)
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class UpdateUserPassword implements UpdatesUserPasswords
* Validate and update the user's password.
*
* @param mixed $user
* @param array $input
* @return void
*/
public function update($user, array $input)
Expand Down
2 changes: 0 additions & 2 deletions app/Actions/Fortify/UpdateUserProfileInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
* Validate and update the given user's profile information.
*
* @param mixed $user
* @param array $input
* @return void
*/
public function update($user, array $input)
Expand Down Expand Up @@ -43,7 +42,6 @@ public function update($user, array $input)
* Update the given verified user's profile information.
*
* @param mixed $user
* @param array $input
* @return void
*/
protected function updateVerifiedUser($user, array $input)
Expand Down
6 changes: 0 additions & 6 deletions app/Actions/Socialstream/CreateConnectedAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
use JoelButcher\Socialstream\ConnectedAccount;
use JoelButcher\Socialstream\Contracts\CreatesConnectedAccounts;
use JoelButcher\Socialstream\Socialstream;
use Laravel\Socialite\AbstractUser;
use Laravel\Socialite\Contracts\User as ProviderUser;

class CreateConnectedAccount implements CreatesConnectedAccounts
{
/**
* Create a connected account for a given user.
*
* @param Authenticatable $user
* @param string $provider
* @param ProviderUser $providerUser
* @return ConnectedAccount
*/
public function create(Authenticatable $user, string $provider, ProviderUser $providerUser): ConnectedAccount
{
Expand Down
4 changes: 0 additions & 4 deletions app/Actions/Socialstream/CreateUserFromProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class CreateUserFromProvider implements CreatesUserFromProvider

/**
* Create a new action instance.
*
* @param \JoelButcher\Socialstream\Contracts\CreatesConnectedAccounts $createsConnectedAccounts
*/
public function __construct(CreatesConnectedAccounts $createsConnectedAccounts)
{
Expand All @@ -32,8 +30,6 @@ public function __construct(CreatesConnectedAccounts $createsConnectedAccounts)
/**
* Create a new user from a social provider user.
*
* @param string $provider
* @param \Laravel\Socialite\Contracts\User $providerUser
* @return \App\Models\User
*/
public function create(string $provider, ProviderUser $providerUser)
Expand Down
4 changes: 0 additions & 4 deletions app/Actions/Socialstream/HandleInvalidState.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ class HandleInvalidState implements HandlesInvalidState
{
/**
* Handle an invalid state exception from a Socialite provider.
*
* @param \Laravel\Socialite\Two\InvalidStateException $exception
* @param callable $callback
* @return mixed
*/
public function handle(InvalidStateException $exception, callable $callback = null): mixed
{
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Socialstream/ResolveSocialiteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$user = Socialite::driver($provider)->user();

if (Socialstream::generatesMissingEmails()) {
$user->email = $user->getEmail() ?? ("{$user->id}@{$provider}".config('app.domain'));
$user->email = $user->getEmail() ?? ("{$user->id}@{$provider}" . config('app.domain'));

Check warning on line 22 in app/Actions/Socialstream/ResolveSocialiteUser.php

View check run for this annotation

Codecov / codecov/patch

app/Actions/Socialstream/ResolveSocialiteUser.php#L22

Added line #L22 was not covered by tests
}

return $user;
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Socialstream/SetUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class SetUserPassword implements SetsUserPasswords
* Validate and update the user's password.
*
* @param mixed $user
* @param array $input
* @return void
*/
public function set($user, array $input)
Expand Down
3 changes: 0 additions & 3 deletions app/Actions/Socialstream/UpdateConnectedAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class UpdateConnectedAccount implements UpdatesConnectedAccounts
* Update a given connected account.
*
* @param mixed $user
* @param \JoelButcher\Socialstream\ConnectedAccount $connectedAccount
* @param string $provider
* @param \Laravel\Socialite\Contracts\User $providerUser
* @return \JoelButcher\Socialstream\ConnectedAccount
*/
public function update($user, ConnectedAccount $connectedAccount, string $provider, User $providerUser)
Expand Down
16 changes: 7 additions & 9 deletions app/Casts/Socials.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ class Socials implements CastsAttributes, SerializesCastableAttributes
/**
* Cast the given value.
*
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return array<int, Social>
*
* @throws \Spatie\DataTransferObject\Exceptions\UnknownProperties
*/
public function get($model, $key, $value, $attributes)
Expand All @@ -31,7 +32,7 @@ public function get($model, $key, $value, $attributes)
$socials[] = new Social($social);
}
}

return $socials;
}

Expand All @@ -40,7 +41,7 @@ public function get($model, $key, $value, $attributes)
*
* @param Model $model
* @param string $key
* @param Collection<int, Social>|array<int, Social> $value
* @param Collection<int, Social>|array<int, Social> $value
* @param array $attributes
* @return false|string
*/
Expand All @@ -63,10 +64,7 @@ public function set($model, $key, $value, $attributes)
* Get the serialized representation of the value.
*
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
*/
public function serialize($model, string $key, $value, array $attributes): mixed
{
Expand Down
Loading
Loading