Skip to content

Commit

Permalink
Merge branch 'master' into feature/add_event_achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Feb 1, 2025
2 parents afa7fd1 + 0ece103 commit e3e42e5
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 51 deletions.
115 changes: 83 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,49 @@ concurrency:
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-22.04
name: Check for changes
outputs:
php: ${{ steps.filter.outputs.php }}
node: ${{ steps.filter.outputs.node }}
steps:
- name: Check changed files
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
php:
- '**/*.php'
- 'composer.json'
- 'composer.lock'
- 'phpstan.neon'
- 'pint.json'
node:
- '**/*.js'
- '**/*.ts'
- '**/*.tsx'
- 'package.json'
- 'pnpm-lock.yaml'
- '*eslint*'
- 'tailwind.config.json'
- 'lang/**/*.json'
php-setup:
needs: changes
runs-on: ubuntu-22.04
name: PHP Setup
outputs:
cache-key: ${{ steps.cache-key.outputs.value }}
steps:
- name: Checkout code
if: ${{ needs.changes.outputs.php == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup PHP
if: ${{ needs.changes.outputs.php == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
Expand All @@ -27,10 +58,12 @@ jobs:
coverage: none

- name: Generate a cache key
if: ${{ needs.changes.outputs.php == 'true' }}
id: cache-key
run: echo "value=${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}" >> $GITHUB_OUTPUT

- name: Cache composer packages
if: ${{ needs.changes.outputs.php == 'true' }}
id: composer-cache
uses: actions/cache@v4
with:
Expand All @@ -42,50 +75,34 @@ jobs:
${{ runner.os }}-php-
- name: Install
if: steps.composer-cache.outputs.cache-hit != 'true'
if: ${{ needs.changes.outputs.php == 'true' && steps.composer-cache.outputs.cache-hit != 'true' }}
run: composer install --prefer-dist

node-setup:
needs: changes
runs-on: ubuntu-22.04
name: Node.js Setup
outputs:
cache-key: ${{ steps.cache-key.outputs.value }}
steps:
- name: Checkout code
if: ${{ needs.changes.outputs.node == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install pnpm
if: ${{ needs.changes.outputs.node == 'true' }}
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node 20
if: ${{ needs.changes.outputs.node == 'true' }}
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: Generate cache key
id: cache-key
run: echo "value=${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT

- name: Install
if: steps.node-cache.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile --prefer-offline

- name: Cache node_modules
id: node-cache
uses: actions/cache@v4
with:
path: |
node_modules
.pnpm-store
key: ${{ steps.cache-key.outputs.value }}

php-checks:
needs: php-setup
needs: [changes, php-setup]
runs-on: ubuntu-22.04
name: PHP Checks
strategy:
Expand All @@ -99,18 +116,27 @@ jobs:
- check: test
command: composer paratest -- --processes=$(nproc)
steps:
- name: Check PHP changes
if: ${{ needs.changes.outputs.php != 'true' }}
run: echo "No PHP changes; skipping checks" && exit 0

- name: Checkout code
if: ${{ needs.changes.outputs.php == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup PHP
if: ${{ needs.changes.outputs.php == 'true' }}
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: mbstring, :psr
coverage: none
ini-values: memory_limit=1G

- name: Load composer packages
if: ${{ needs.changes.outputs.php == 'true' }}
uses: actions/cache@v4
with:
path: |
Expand All @@ -119,11 +145,29 @@ jobs:
key: ${{ needs.php-setup.outputs.cache-key }}
restore-keys: |
${{ runner.os }}-php-
- name: Restore PHPStan result cache
if: ${{ needs.changes.outputs.php == 'true' && matrix.check == 'analyse' }}
uses: actions/cache/restore@v4
with:
path: tmp
key: phpstan-result-cache-${{ github.run_id }}
restore-keys: |
phpstan-result-cache-
- name: Run ${{ matrix.check }}
if: ${{ needs.changes.outputs.php == 'true' }}
run: ${{ matrix.command }}

- name: Save PHPStan result cache
if: ${{ needs.changes.outputs.php == 'true' && matrix.check == 'analyse' }}
uses: actions/cache/save@v4
with:
path: tmp
key: phpstan-result-cache-${{ github.run_id }}

node-checks:
needs: node-setup
needs: [changes, node-setup]
runs-on: ubuntu-22.04
name: Node.js Checks
strategy:
Expand All @@ -141,26 +185,33 @@ jobs:
APP_URL: https://raweb.test
LARAVEL_BYPASS_ENV_CHECK: 1
steps:
- name: Check Node changes
if: ${{ needs.changes.outputs.node != 'true' }}
run: echo "No Node changes; skipping checks" && exit 0

- name: Checkout code
if: ${{ needs.changes.outputs.node == 'true' }}
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install pnpm
if: ${{ needs.changes.outputs.node == 'true' }}
uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node 20
if: ${{ needs.changes.outputs.node == 'true' }}
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Restore node_modules
uses: actions/cache@v4
with:
path: |
node_modules
.pnpm-store
key: ${{ needs.node-setup.outputs.cache-key }}

- name: Install dependencies
if: ${{ needs.changes.outputs.node == 'true' }}
run: pnpm install --frozen-lockfile --prefer-offline

- name: Run ${{ matrix.check }}
if: ${{ needs.changes.outputs.node == 'true' }}
run: ${{ matrix.command }}
env: ${{ matrix.env || fromJSON('{}') }}
env: ${{ matrix.env || fromJSON('{}') }}
97 changes: 96 additions & 1 deletion app/Filament/Resources/GameResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,23 @@ public static function table(Table $table): Table
])
->filters([
Tables\Filters\SelectFilter::make('system')
->relationship('system', 'Name'),
->options(function () {
$options = ['active' => 'All Active Systems'];
$systemOptions = System::orderBy('Name')
->pluck('Name', 'ID')
->toArray();

return $options + $systemOptions;
})
->query(function (Builder $query, $data) {
$value = $data['value'] ?? null;

if ($value === 'active') {
$query->whereIn('ConsoleID', System::active()->pluck('ID'));
} elseif ($value) {
$query->where('ConsoleID', $value);
}
}),

Tables\Filters\TernaryFilter::make('achievements_published')
->label('Has core set')
Expand All @@ -498,6 +514,85 @@ public static function table(Table $table): Table
blank: fn (Builder $query): Builder => $query,
),

Tables\Filters\SelectFilter::make('media')
->label('Media')
->placeholder('Select a value')
->options([
'none' => 'Has all media',
'all' => 'Missing all media',
'any' => 'Missing any media',
'badge' => 'Missing badge icon',
'boxart' => 'Missing box art',
'title' => 'Missing title image',
'ingame' => 'Missing in-game image',
])
->query(function (Builder $query, array $data): Builder {
if (empty($data['value'])) {
return $query;
}

$query = $query->whereNotIn('ConsoleID', System::getNonGameSystems());

switch ($data['value']) {
case 'none':
return $query->whereNotNull('ImageIcon')
->where('ImageIcon', '!=', '/Images/000001.png')
->whereNotNull('ImageTitle')
->where('ImageTitle', '!=', '/Images/000002.png')
->whereNotNull('ImageIngame')
->where('ImageIngame', '!=', '/Images/000002.png')
->whereNotNull('ImageBoxArt')
->where('ImageBoxArt', '!=', '/Images/000002.png');
case 'all':
return $query->where(function ($query) {
$query->whereNull('ImageIcon')
->orWhere('ImageIcon', '/Images/000001.png');
})->where(function ($query) {
$query->whereNull('ImageTitle')
->orWhere('ImageTitle', '/Images/000002.png');
})->where(function ($query) {
$query->whereNull('ImageIngame')
->orWhere('ImageIngame', '/Images/000002.png');
})->where(function ($query) {
$query->whereNull('ImageBoxArt')
->orWhere('ImageBoxArt', '/Images/000002.png');
});
case 'any':
return $query->where(function ($query) {
$query->whereNull('ImageIcon')
->orWhere('ImageIcon', '/Images/000001.png')
->orWhereNull('ImageTitle')
->orWhere('ImageTitle', '/Images/000002.png')
->orWhereNull('ImageIngame')
->orWhere('ImageIngame', '/Images/000002.png')
->orWhereNull('ImageBoxArt')
->orWhere('ImageBoxArt', '/Images/000002.png');
});
case 'badge':
return $query->where(function ($query) {
$query->whereNull('ImageIcon')
->orWhere('ImageIcon', '/Images/000001.png');
});
case 'boxart':
return $query->where(function ($query) {
$query->whereNull('ImageBoxArt')
->orWhere('ImageBoxArt', '/Images/000002.png');
});
case 'title':
return $query->where(function ($query) {
$query->whereNull('ImageTitle')
->orWhere('ImageTitle', '/Images/000002.png');
});
case 'ingame':
return $query->where(function ($query) {
$query->whereNull('ImageIngame')
->orWhere('ImageIngame', '/Images/000002.png');
});
default:
return $query;
}
}),

Tables\Filters\TernaryFilter::make('has_dynamic_rp')
->label('Has dynamic rich presence')
->placeholder('Any')
Expand Down
8 changes: 8 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ public function preferredLocale()
return $this->locale;
}

public function resolveSoftDeletableRouteBinding($value, $field = null)
{
return $this->where('display_name', $value)
->orWhere('User', $value)
->withTrashed()
->firstOrFail();
}

public function getRouteKey(): string
{
return !empty($this->display_name) ? $this->display_name : 'User';
Expand Down
23 changes: 23 additions & 0 deletions database/migrations/2025_01_29_000001_update_comments_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
public function up(): void
{
Schema::table('Comment', function (Blueprint $table) {
$table->index(['user_id', 'Submitted']);
});
}

public function down(): void
{
Schema::table('Comment', function (Blueprint $table) {
$table->dropIndex(['user_id', 'Submitted']);
});
}
};
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parameters:
- resources/views
- tests
level: 6
tmpDir: tmp
treatPhpDocTypesAsCertain: false
# TODO figure out why github actions phpstan does not find the same
reportUnmatchedIgnoredErrors: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ describe('Component: CreateAchievementTicketMainRoot', () => {
);

// ACT
await userEvent.type(
screen.getByRole('textbox', { name: /description/i }),
await userEvent.click(screen.getByRole('textbox', { name: /description/i }));
await userEvent.paste(
`
Steps to reproduce:
Played as Waluigi in Party Mode on Shy Guy's board, 10 turns, 3 easy CPUs (Mario, Luigi and Peach) and
Expand Down
Loading

0 comments on commit e3e42e5

Please sign in to comment.