Skip to content

Commit

Permalink
chore: add phpstan static analysis minimum (#4511)
Browse files Browse the repository at this point in the history
  • Loading branch information
lancepioch authored Nov 28, 2022
1 parent 3f7e2a5 commit a1a5275
Show file tree
Hide file tree
Showing 67 changed files with 558 additions and 276 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Docker

on:
push:
Expand All @@ -8,16 +8,16 @@ on:

jobs:
push:
name: Push Image to GitHub Packages
name: Push
runs-on: ubuntu-20.04
# Always run against a tag, even if the commit into the tag has [docker skip]
# within the commit message.
if: "!contains(github.ref, 'develop') || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))"
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Docker Metadata
- name: Docker metadata
uses: docker/metadata-action@v4
id: docker_meta
with:
Expand All @@ -26,10 +26,10 @@ jobs:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Docker Login
- name: Docker login
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand Down
96 changes: 69 additions & 27 deletions .github/workflows/ci.yaml → .github/workflows/laravel.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Laravel

on:
push:
Expand All @@ -11,8 +11,58 @@ on:
- "1.0-develop"

jobs:
analysis:
name: Static Analysis
runs-on: ubuntu-20.04
env:
APP_ENV: testing
APP_DEBUG: "true"
APP_KEY: SomeRandomString3232RandomString
CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: bcmath, cli, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: Analyze
run: vendor/bin/phpstan analyse

lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: bcmath, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
tools: composer:v2
coverage: none

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: PHP CS Fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff

mysql:
name: MySQL
name: Tests (MySQL)
runs-on: ubuntu-20.04
strategy:
fail-fast: false
Expand All @@ -36,20 +86,17 @@ jobs:
APP_TIMEZONE: UTC
APP_URL: http://localhost/
APP_ENVIRONMENT_ONLY: "true"

DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: root

CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync

HASHIDS_SALT: test123
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: root
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Get cache directory
Expand Down Expand Up @@ -78,7 +125,6 @@ jobs:

- name: Unit tests
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
if: ${{ always() }}
env:
DB_HOST: UNIT_NO_DB

Expand All @@ -88,7 +134,7 @@ jobs:
DB_PORT: ${{ job.services.database.ports[3306] }}

postgres:
name: PostgreSQL
name: Tests (PostgreSQL)
runs-on: ubuntu-20.04
if: "!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'ci skip')"
strategy:
Expand All @@ -114,35 +160,32 @@ jobs:
APP_TIMEZONE: UTC
APP_URL: http://localhost/
APP_ENVIRONMENT_ONLY: "true"

DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: postgres
DB_PASSWORD: postgres

CACHE_DRIVER: array
MAIL_MAILER: array
SESSION_DRIVER: array
QUEUE_CONNECTION: sync

HASHIDS_SALT: test123
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_DATABASE: testing
DB_USERNAME: postgres
DB_PASSWORD: postgres
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Get cache directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.php_cs.cache
${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-cache-${{ matrix.php }}-${{ hashFiles('**.composer.lock') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -157,7 +200,6 @@ jobs:

- name: Unit tests
run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit
if: ${{ always() }}
env:
DB_HOST: UNIT_NO_DB

Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/lint.yaml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
name: Release
runs-on: ubuntu-20.04
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: "yarn"
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build:production
run: yarn build

- name: Create release branch and bump version
env:
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Create release archive
run: |
rm -rf node_modules/ test/ codecov.yml CODE_OF_CONDUCT.md CONTRIBUTING.md phpunit.xml Vagrantfile
rm -rf node_modules/ tests/ CODE_OF_CONDUCT.md CONTRIBUTING.md phpstan.neon phpunit.xml
tar -czf panel.tar.gz * .env.example .eslintignore .eslintrc.js
- name: Extract changelog
Expand All @@ -58,7 +58,7 @@ jobs:
echo -e "\n#### SHA256 Checksum\n\n\`\`\`\n$SUM\n\`\`\`\n" >> ./RELEASE_CHANGELOG
echo $SUM > checksum.txt
- name: Create Release
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,47 @@ on:
- "1.0-develop"

jobs:
build-and-test:
name: Build and Test
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Lint
run: yarn run lint

tests:
name: Tests
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
node-version: [16, 18]
node: [16, 18]
steps:
- name: Code Checkout
- name: Code checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
node-version: ${{ matrix.node }}
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build
run: yarn run build

- name: Tests
run: yarn test
run: yarn run test
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class Handler extends ExceptionHandler
final class Handler extends ExceptionHandler
{
/**
* The validation parser in Laravel formats custom rules using the class name
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Controllers/Admin/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Api\KeyCreationService;
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
Expand All @@ -23,8 +22,7 @@ class ApiController extends Controller
public function __construct(
private AlertsMessageBag $alert,
private ApiKeyRepositoryInterface $repository,
private KeyCreationService $keyCreationService,
private ViewFactory $view,
private KeyCreationService $keyCreationService
) {
}

Expand All @@ -33,7 +31,7 @@ public function __construct(
*/
public function index(Request $request): View
{
return $this->view->make('admin.api.index', [
return view('admin.api.index', [
'keys' => $this->repository->getApplicationKeys($request->user()),
]);
}
Expand All @@ -48,7 +46,7 @@ public function create(): View
$resources = AdminAcl::getResourceList();
sort($resources);

return $this->view->make('admin.api.new', [
return view('admin.api.new', [
'resources' => $resources,
'permissions' => [
'r' => AdminAcl::READ,
Expand Down
Loading

0 comments on commit a1a5275

Please sign in to comment.