Skip to content

Commit

Permalink
Verify
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Aug 7, 2024
1 parent 9511d13 commit 75130dc
Show file tree
Hide file tree
Showing 33 changed files with 1,076 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
20 changes: 20 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/workbench export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: LycheeOrg
28 changes: 28 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon'
- '.github/workflows/phpstan.yml'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: run-tests

on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2]
laravel: [11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
carbon: ^2.63

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.os == 'windows-latest' && '^^^' || '' }}${{ matrix.carbon }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
run: composer run test
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.idea
.phpunit.cache
build
composer.lock
coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules

.php-cs-fixer.cache
sign.sh
test.sig
test
56 changes: 56 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

$finder = array_reduce(
[
__DIR__ . '/src/',
__DIR__ . '/database/',
__DIR__ . '/config/',
__DIR__ . '/resources/',
// __DIR__ . '/routes/',
__DIR__ . '/tests/',
],
function (PhpCsFixer\Finder $finder, $dir) {
return $finder->in($dir);
},
PhpCsFixer\Finder::create()->ignoreUnreadableDirs()
)->notName('*.blade.php');
$rules = [
'@Symfony' => true,
'nullable_type_declaration_for_default_null_value' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'fully_qualified_strict_types' => false,
'backtick_to_shell_exec' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'multiline_comment_opening_closing' => true,
'no_php4_constructor' => true,
'nullable_type_declaration' => false,
'phpdoc_no_empty_return' => false,
'single_blank_line_at_eof' => false,
'yoda_style' => false,
'concat_space' => ['spacing' => 'one'],
'no_superfluous_phpdoc_tags' => false,
'phpdoc_to_comment' => false, // required until https://github.com/phpstan/phpstan/issues/7486 got fixed
'blank_line_between_import_groups' => false, // not PSR-12 compatible, but preserves old behaviour
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => null, // for PSR-12 compatability, this need to be `['class', 'function', 'const']`, but no grouping preserves old behaviour
],
'no_unneeded_control_parentheses' => [
'statements' => ['break', 'clone', 'continue', 'echo_print', 'switch_case', 'yield'],
],
'operator_linebreak' => [
'only_booleans' => true,
'position' => 'end',
],
];
$config = new PhpCsFixer\Config();

$config->setRiskyAllowed(true);
$config->setRules($rules);
$config->setIndent("\t");
$config->setLineEnding("\n");
$config->setFinder($finder);

return $config;
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

All notable changes to `LycheeVerify` will be documented in this file.
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: dist-gen dist-clean dist clean test formatting phpstan

composer:
rm -r vendor 2> /dev/null || true
composer install --prefer-dist --no-dev
php artisan vendor:publish --tag=log-viewer-asset

test:
@if [ -x "vendor/bin/phpunit" ]; then \
./vendor/bin/phpunit --stop-on-failure; \
else \
echo ""; \
echo "Please install phpunit:"; \
echo ""; \
echo " composer install"; \
echo ""; \
fi

formatting:
@rm .php_cs.cache 2> /dev/null || true
@if [ -x "vendor/bin/php-cs-fixer" ]; then \
PHP_CS_FIXER_IGNORE_ENV=1 ./vendor/bin/php-cs-fixer fix -v --config=.php-cs-fixer.php; \
else \
echo ""; \
echo "Please install php-cs-fixer:"; \
echo ""; \
echo " composer install"; \
echo ""; \
fi

phpstan:
vendor/bin/phpstan analyze
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# verify
# Lychee verification

## Testing

```bash
composer test
```



## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

## Credits

- [LycheeOrg](https://github.com/spatie)
66 changes: 66 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "lychee-org/lycheeverify",
"description": "Verification package for Lychee",
"homepage": "https://github.com/LycheeOrg/verify",
"license": "MIT",
"require": {
"php": "^8.2",
"illuminate/contracts": "^10.0||^11.0",
"thecodingmachine/safe": "^2.5"
},
"require-dev": {
"nunomaduro/collision": "^8.3",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.0.0||^8.22.0",
"friendsofphp/php-cs-fixer": "^3.3",
"lychee-org/phpstan-lychee": "^v1.0.1",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpunit/phpunit": "^10.0"
},
"autoload": {
"psr-4": {
"LycheeVerify\\": "src/",
"LycheeVerify\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"LycheeVerify\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-lycheeverify --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
"@php vendor/bin/testbench workbench:build --ansi"
],
"start": [
"Composer\\Config::disableProcessTimeout",
"@composer run build",
"@php vendor/bin/testbench serve"
],
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit"
},
"config": {
"platform": {
"php": "8.2"
},
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"LycheeVerify\\VerifyServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
17 changes: 17 additions & 0 deletions config/verify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use LycheeVerify\Http\Middleware\VerifySupporterStatus;
use LycheeVerify\Validators\ValidateHash;
use LycheeVerify\Validators\ValidateSignature;
use LycheeVerify\Verify;
use LycheeVerify\VerifyServiceProvider;

return [
'validation' => [
ValidateHash::class => 'c34da4a4523e54f303c23cd22eaf252f74ed7965',
ValidateSignature::class => 'a3d4081247b4f56c8aeb7c6b192415700e27acc0',
Verify::class => 'cda79b50522e9189aa928a5f471ebc20a049db76',
VerifySupporterStatus::class => '6358c45ed0414c1e2697e0881238659fa6221bed',
VerifyServiceProvider::class => '927a8f3c811fc82cb8a0ac2667c06e7d292c3633',
],
];
31 changes: 31 additions & 0 deletions database/migrations/create_configs_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

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

return new class() extends Migration {
private const TABLE_NAME = 'configs';

public function up(): void
{
if (Schema::hasTable(self::TABLE_NAME)) {
// Nothing to do. Bye.
return;
}
Schema::create(self::TABLE_NAME, function (Blueprint $table) {
$table->increments('id');
$table->string('key', 50);
$table->string('value', 200)->nullable();
$table->string('cat', 50)->default('Config');
$table->string('type_range')->default('0|1');
$table->boolean('is_secret')->default(false);
$table->string('description')->default('');
});
}

public function down(): void
{
// do nothing
}
};
12 changes: 12 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- vendor/larastan/larastan/extension.neon
- vendor/lychee-org/phpstan-lychee/phpstan.neon

parameters:
treatPhpDocTypesAsCertain: false
paths:
- src
- tests
- database/migrations
- config
ignoreErrors:
Loading

0 comments on commit 75130dc

Please sign in to comment.