Skip to content

Commit

Permalink
Minor changes in prevision for Livewire. (#2026)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Sep 23, 2023
1 parent 4c4745f commit 7111f65
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/.env.mariadb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=Lychee
APP_URL=https://localhost
APP_ENV=testing
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.env.postgresql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=Lychee
APP_URL=https://localhost
APP_ENV=testing
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.env.sqlite
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP_NAME=Lychee
APP_URL=https://localhost
APP_ENV=testing
APP_ENV=dev
APP_KEY=SomeRandomString
APP_DEBUG=true

Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
access_token: ${{ github.token }}

php_syntax_errors:
name: 1️⃣ PHP - Syntax errors
name: 1️⃣ PHP 8.1 - Syntax errors
runs-on: ubuntu-latest
needs:
- kill_previous
Expand All @@ -50,15 +50,15 @@ jobs:
run: vendor/bin/parallel-lint --exclude .git --exclude vendor .

code_style_errors:
name: 2️⃣ PHP - Code Style errors
name: 2️⃣ PHP 8.1 - Code Style errors
runs-on: ubuntu-latest
needs:
- php_syntax_errors
steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest
php-version: 8.1

- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
run: vendor/bin/phpstan analyze

tests:
name: 2️⃣ PHP ${{ matrix.php-version }} - ${{ matrix.sql-versions }}
name: 2️⃣ PHP ${{ matrix.php-version }} - ${{ matrix.sql-versions }} -- ${{ matrix.test-suite }}
needs:
- php_syntax_errors
runs-on: ubuntu-latest
Expand All @@ -104,6 +104,8 @@ jobs:
- mariadb
- postgresql
- sqlite
test-suite:
- Feature
# Service containers to run with `container-job`
services:
# Label used to access the service container
Expand Down Expand Up @@ -162,11 +164,11 @@ jobs:
php artisan optimize
php artisan migrate
- name: Apply tests
run: XDEBUG_MODE=coverage vendor/bin/phpunit
- name: Apply tests ${{ matrix.test-suite }}
run: XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite ${{ matrix.test-suite }}

- name: Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

- name: Make sure we can go backward
run: php artisan migrate:rollback
Expand All @@ -180,7 +182,6 @@ jobs:
matrix:
php-version:
- 8.1
- 8.2
sql-versions:
- mariadb
- postgresql
Expand Down
35 changes: 25 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
/node_modules
# We don't care about those
node_modules
build/*

# Those are personal
public/dist/user.css
public/dist/custom.js

# Pictures we do not commit
public/uploads/**

# Storage stuff: useless
/storage/*.key
/storage/clockwork/

# Those are generated
/vendor

# IDE & Cache stuff
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.env.*

aliases

Lychee/*
.phpunit*
_ide*

.php_cs.cache
.php-cs-fixer.cache

*.log
clover.xml
*.swp
Expand All @@ -37,6 +38,20 @@ installed.log
storage/bootstrap/cache/*
storage/image-jobs/*

# used by Vite
public/hot

sync/*

# Local DB for easy deployment
backup.sql
reset.sh
*-bck

# Make sure we don't commit secrets
.env
.env.*

aliases

# Building stuff for releaseses
Lychee/*
27 changes: 2 additions & 25 deletions app/Actions/Diagnostics/Pipes/Checks/IniSettingsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function handle(array &$data, \Closure $next): array
// Load settings
$settings = Configs::get();

if ($this->convert_size(ini_get('upload_max_filesize')) < $this->convert_size('30M')) {
if (Helpers::convertSize(ini_get('upload_max_filesize')) < Helpers::convertSize(('30M'))) {
$data[] = 'Warning: You may experience problems when uploading a photo of large size. Take a look in the FAQ for details.';
}
if ($this->convert_size(ini_get('post_max_size')) < $this->convert_size('100M')) {
if (Helpers::convertSize(ini_get('post_max_size')) < Helpers::convertSize(('100M'))) {
$data[] = 'Warning: You may experience problems when uploading a photo of large size. Take a look in the FAQ for details.';
}
$max_execution_time = intval(ini_get('max_execution_time'));
Expand Down Expand Up @@ -93,27 +93,4 @@ public function handle(array &$data, \Closure $next): array

return $next($data);
}

/**
* Return true if the upload_max_filesize is bellow what we want.
*/
private function convert_size(string $size): int
{
$size = trim($size);
$last = strtolower($size[strlen($size) - 1]);
$size = intval($size);

switch ($last) {
case 'g':
$size *= 1024;
// no break
case 'm':
$size *= 1024;
// no break
case 'k':
$size *= 1024;
}

return $size;
}
}
1 change: 1 addition & 0 deletions app/Actions/Photo/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function do(EloquentCollection $photos, ?Album $album): BaseCollection
foreach ($photos as $photo) {
$duplicate = $photo->replicate();
$duplicate->album_id = $album?->id;
$duplicate->setRelation('album', $album);
if ($album !== null) {
$duplicate->owner_id = $album->owner_id;
}
Expand Down
61 changes: 23 additions & 38 deletions app/Assets/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@

class Helpers
{
private int $numTab = 0;

/**
* Initialize the Facade.
*/
public function __construct()
{
$this->numTab = 0;
}

/**
* Add UnixTimeStamp to file path suffix.
*
Expand Down Expand Up @@ -153,34 +143,6 @@ public function gcd(int $a, int $b): int
return ($a % $b) !== 0 ? $this->gcd($b, $a % $b) : $b;
}

/**
* Return incrementing numbers.
*/
public function data_index(): int
{
$this->numTab++;

return $this->numTab;
}

/**
* Reset and return incrementing numbers.
*/
public function data_index_r(): int
{
$this->numTab = 1;

return $this->numTab;
}

/**
* Reset the incrementing number.
*/
public function data_index_set(int $idx = 0): void
{
$this->numTab = $idx;
}

/**
* From https://www.php.net/manual/en/function.disk-total-space.php.
*
Expand Down Expand Up @@ -232,4 +194,27 @@ public function secondsToHMS(int|float $d): string
. ($m > 0 ? $m . 'm' : '')
. ($s > 0 || ($h === 0 && $m === 0) ? $s . 's' : '');
}

/**
* Return true if the upload_max_filesize is bellow what we want.
*/
public function convertSize(string $size): int
{
$size = trim($size);
$last = strtolower($size[strlen($size) - 1]);
$size = intval($size);

switch ($last) {
case 'g':
$size *= 1024;
// no break
case 'm':
$size *= 1024;
// no break
case 'k':
$size *= 1024;
}

return $size;
}
}
4 changes: 1 addition & 3 deletions app/Facades/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
* @method static bool hasPermissions(string $path)
* @method static bool hasFullPermissions(string $path)
* @method static int gcd(int $a, int $b)
* @method static int data_index()
* @method static int data_index_r()
* @method static void data_index_set(int $idx = 0)
* @method static bool isExecAvailable()
* @method static string secondsToHMS(int|float $d)
* @method static int convertSize(string $size)
*/
class Helpers extends Facade
{
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Resources/Collections/AlbumForestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
class AlbumForestResource extends JsonResource
{
public function __construct(
private Collection $albums,
private ?Collection $sharedAlbums = null
public Collection $albums,
public ?Collection $sharedAlbums = null
) {
// Laravel applies a shortcut when this value === null but not when it is something else.
parent::__construct('must_not_be_null');
Expand Down
1 change: 1 addition & 0 deletions app/Policies/PhotoPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PhotoPolicy extends BasePolicy
public const CAN_EDIT = 'canEdit';
public const CAN_EDIT_ID = 'canEditById';
public const CAN_ACCESS_FULL_PHOTO = 'canAccessFullPhoto';
public const CAN_DELETE_BY_ID = 'canDeleteById';

/**
* @throws FrameworkException
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Traits/CatchFailures.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function assertStatus(TestResponse $response, int $expectedStatusCode)
dump($exception);
}
// We remove 204 as it does not have content
if (!in_array($response->getStatusCode(), [204, $expectedStatusCode], true)) {
if (!in_array($response->getStatusCode(), [204, 302, $expectedStatusCode], true)) {
$exception = $response->json();
$this->trimException($exception);
dump($exception);
Expand Down

0 comments on commit 7111f65

Please sign in to comment.