Skip to content

Commit

Permalink
Merge pull request #148 from wintercms/wip/1.2
Browse files Browse the repository at this point in the history
Support Laravel 9 / PHP 8.1
  • Loading branch information
LukeTowers committed Jul 15, 2022
2 parents e764d0f + 6f12f8a commit 74c3bbd
Show file tree
Hide file tree
Showing 1,009 changed files with 48,718 additions and 33,140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install PHP and PHP Code Sniffer
uses: shivammathur/setup-php@v2
with:
php-version: 7.3
php-version: 8.0
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
tools: phpcs

Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ jobs:
node-version: 12

- name: Install Node dependencies
working-directory: ./tests/js
working-directory: ./modules/system/tests/js
run: npm install

- name: Run tests
working-directory: ./tests/js
working-directory: ./modules/system/tests/js
run: npm run test

phpUnitTests:
strategy:
max-parallel: 8
matrix:
operatingSystem: [ubuntu-latest, windows-latest]
phpVersion: ['7.2', '7.3', '7.4', '8.0']
phpVersion: ['8.0', '8.1']
fail-fast: false
runs-on: ${{ matrix.operatingSystem }}
name: ${{ matrix.operatingSystem }} / PHP ${{ matrix.phpVersion }}
Expand Down Expand Up @@ -72,18 +73,25 @@ jobs:
php-version: ${{ matrix.phpVersion }}
extensions: ${{ env.extensions }}

- name: Echo branches
run: echo "${{ github.ref }} | ${{ github.head_ref }} | ${{ github.ref_name }} | ${{ github.base_ref }}"

- name: Switch library dependency (develop)
if: github.ref == 'refs/heads/develop' || github.base_ref == 'develop'
run: php ./.github/workflows/utilities/library-switcher "dev-develop as 1.1"

- name: Switch library dependency (1.0)
if: github.ref == 'refs/heads/1.0' || github.base_ref == '1.0'
if: github.head_ref == '1.0' || github.ref == 'refs/heads/1.0' || github.base_ref == '1.0'
run: php ./.github/workflows/utilities/library-switcher "1.0.x-dev as 1.0"

- name: Switch library dependency (1.1)
if: github.ref == 'refs/heads/1.1' || github.base_ref == '1.1'
if: github.head_ref == '1.1' || github.ref == 'refs/heads/1.1' || github.base_ref == '1.1'
run: php ./.github/workflows/utilities/library-switcher "1.1.x-dev as 1.1"

- name: Switch library dependency (1.2)
if: github.head_ref == 'wip/1.2' || github.ref == 'refs/heads/wip/1.2' || github.base_ref == 'wip/1.2'
run: php ./.github/workflows/utilities/library-switcher "dev-wip/1.2 as 1.2"

- name: Setup dependency cache
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
Expand All @@ -105,10 +113,10 @@ jobs:
run: php artisan package:discover

- name: Setup problem matchers for PHPUnit
if: matrix.phpVersion == '7.4'
if: matrix.phpVersion == '8.1'
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run Linting and Tests
run: |
./vendor/bin/parallel-lint --exclude vendor --exclude storage --exclude tests/fixtures/plugins/testvendor/goto/Plugin.php .
composer lint
./vendor/bin/phpunit
82 changes: 43 additions & 39 deletions .github/workflows/utilities/phpcs-pr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* of changed files. The PHPCS tests are only run against these changed files, to speed up the tests.
*/
if (empty($argv[1])) {
echo 'You must provide a base branch to check this PR against.';
echo "\n";
fwrite(STDERR, 'You must provide a base branch to check this PR against.');
fwrite(STDERR, "\n");
exit(1);
}

Expand All @@ -22,6 +22,13 @@ foreach ($files as &$file) {
}
}

// no changes found in diff, early exit
if (!count($files)) {
fwrite(STDOUT, "\e[0;32mFound no changed files.\e[0m");
fwrite(STDOUT, "\n");
exit(0);
}

// Run all changed files through the PHPCS code sniffer and generate a CSV report
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$lines = array_map(function ($row) {
Expand All @@ -34,50 +41,47 @@ $lines = array_map(function ($row) {
array_shift($lines);

if (!count($lines)) {
echo "\e[0;32mFound no issues with code quality.\e[0m";
echo "\n";
fwrite(STDOUT, "\e[0;32mFound no issues with code quality.\e[0m");
fwrite(STDOUT, "\n");
exit(0);
} else {
// Group errors by file
$files = [];
}

foreach ($lines as $line) {
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]);
// Group errors by file
$files = [];

if (empty($files[$filename])) {
$files[$filename] = [];
}
foreach ($lines as $line) {
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]);

$files[$filename][] = [
'warning' => ($line[3] === 'warning'),
'message' => $line[4],
'line' => $line[1],
];
if (empty($files[$filename])) {
$files[$filename] = [];
}

// Render report
echo "\e[0;31mFound "
. ((count($lines) === 1)
? '1 issue'
: count($lines) . ' issues')
. " with code quality.\e[0m";
echo "\n";
$files[$filename][] = [
'warning' => (($line[3] ?? 'err') === 'warning'),
'message' => $line[4] ?? 'unknown',
'line' => $line[1] ?? '0',
];
}

// Render report
fwrite(STDERR, "\e[0;31mFound "
. ((count($lines) === 1)
? '1 issue'
: count($lines) . ' issues')
. " with code quality.\e[0m");
fwrite(STDERR, "\n");

foreach ($files as $file => $errors) {
echo "\n";
echo "\e[1;37m" . str_replace('"', '', $file) . "\e[0m";
echo "\n\n";
foreach ($files as $file => $errors) {
fwrite(STDERR, "\n");
fwrite(STDERR, "\e[1;37m" . str_replace('"', '', $file) . "\e[0m");
fwrite(STDERR, "\n\n");

foreach ($errors as $error) {
echo "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m";
if ($error['warning'] === false) {
echo "\e[0;31mERR:\e[0m ";
} else {
echo "\e[1;33mWARN:\e[0m ";
}
echo $error['message'];
echo "\n";
}
foreach ($errors as $error) {
fwrite(STDERR, "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m");
fwrite(STDERR, $error['warning'] ? "\e[1;33mWARN:\e[0m " : "\e[0;31mERR:\e[0m ");
fwrite(STDERR, $error['message']);
fwrite(STDERR, "\n");
}
exit(1);
}

exit(1);
82 changes: 43 additions & 39 deletions .github/workflows/utilities/phpcs-push
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* against these changed files, to speed up the tests.
*/
if (empty($argv[1])) {
echo 'You must provide a commit SHA to check.';
echo "\n";
fwrite(STDERR, 'You must provide a commit SHA to check.');
fwrite(STDERR, "\n");
exit(1);
}

Expand All @@ -22,6 +22,13 @@ foreach ($files as &$file) {
}
}

// no changes found in diff, early exit
if (!count($files)) {
fwrite(STDOUT, "\e[0;32mFound no changed files.\e[0m");
fwrite(STDOUT, "\n");
exit(0);
}

// Run all changed files through the PHPCS code sniffer and generate a CSV report
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$lines = array_map(function ($row) {
Expand All @@ -34,50 +41,47 @@ $lines = array_map(function ($row) {
array_shift($lines);

if (!count($lines)) {
echo "\e[0;32mFound no issues with code quality.\e[0m";
echo "\n";
fwrite(STDOUT, "\e[0;32mFound no issues with code quality.\e[0m");
fwrite(STDOUT, "\n");
exit(0);
} else {
// Group errors by file
$files = [];
}

foreach ($lines as $line) {
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]);
// Group errors by file
$files = [];

if (empty($files[$filename])) {
$files[$filename] = [];
}
foreach ($lines as $line) {
$filename = str_replace(dirname(dirname(dirname(__DIR__))), '', $line[0]);

$files[$filename][] = [
'warning' => ($line[3] === 'warning'),
'message' => $line[4],
'line' => $line[1],
];
if (empty($files[$filename])) {
$files[$filename] = [];
}

// Render report
echo "\e[0;31mFound "
. ((count($lines) === 1)
? '1 issue'
: count($lines) . ' issues')
. " with code quality.\e[0m";
echo "\n";
$files[$filename][] = [
'warning' => (($line[3] ?? 'err') === 'warning'),
'message' => $line[4] ?? 'unknown',
'line' => $line[1] ?? '0',
];
}

// Render report
fwrite(STDERR, "\e[0;31mFound "
. ((count($lines) === 1)
? '1 issue'
: count($lines) . ' issues')
. " with code quality.\e[0m");
fwrite(STDERR, "\n");

foreach ($files as $file => $errors) {
echo "\n";
echo "\e[1;37m" . str_replace('"', '', $file) . "\e[0m";
echo "\n\n";
foreach ($files as $file => $errors) {
fwrite(STDERR, "\n");
fwrite(STDERR, "\e[1;37m" . str_replace('"', '', $file) . "\e[0m");
fwrite(STDERR, "\n\n");

foreach ($errors as $error) {
echo "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m";
if ($error['warning'] === false) {
echo "\e[0;31mERR:\e[0m ";
} else {
echo "\e[1;33mWARN:\e[0m ";
}
echo $error['message'];
echo "\n";
}
foreach ($errors as $error) {
fwrite(STDERR, "\e[2m" . str_pad(' L' . $error['line'], 7) . " | \e[0m");
fwrite(STDERR, $error['warning'] ? "\e[1;33mWARN:\e[0m " : "\e[0;31mERR:\e[0m ");
fwrite(STDERR, $error['message']);
fwrite(STDERR, "\n");
}
exit(1);
}
exit(1);

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ package-lock.json
/node_modules

# Ignore generated public directory from `winter:mirror public`
public
public
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"**/modules/*/widgets/*/partials/*.htm": "php",

"**/plugins/*/*/behaviors/*/partials/*.htm": "php",
"**/plugins/*/*/components/*/*.htm": "wintercms-twig",
"**/plugins/*/*/components/**/*.htm": "wintercms-twig",
"**/plugins/*/*/controllers/*/*.htm": "php",
"**/plugins/*/*/formwidgets/*/partials/*.htm": "php",
"**/plugins/*/*/layouts/*.htm": "php",
Expand Down
4 changes: 2 additions & 2 deletions artisan
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
| loading of any of our classes manually. It's great to relax.
|
*/

Expand Down Expand Up @@ -40,7 +40,7 @@ $status = $kernel->handle(
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
Expand Down
33 changes: 12 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,25 @@
"source": "https://github.com/wintercms/winter"
},
"require": {
"php": "^7.2.9|~8.0.0",
"winter/storm": "dev-develop as 1.1.999",
"winter/wn-system-module": "dev-develop as 1.1.999",
"winter/wn-backend-module": "dev-develop as 1.1.999",
"winter/wn-cms-module": "dev-develop as 1.1.999",
"laravel/framework": "~6.0",
"php": "^8.0.2",
"winter/storm": "dev-wip/1.2 as 1.2",
"winter/wn-system-module": "dev-wip/1.2",
"winter/wn-backend-module": "dev-wip/1.2",
"winter/wn-cms-module": "dev-wip/1.2",
"laravel/framework": "^9.1",
"wikimedia/composer-merge-plugin": "~2.0.1"
},
"require-dev": {
"phpunit/phpunit": "^8.4|^9.3.3",
"mockery/mockery": "~1.3.3|^1.4.2",
"fakerphp/faker": "~1.9",
"squizlabs/php_codesniffer": "3.*",
"phpunit/phpunit": "^9.5.8",
"mockery/mockery": "^1.4.4",
"fakerphp/faker": "^1.9.2",
"squizlabs/php_codesniffer": "^3.2",
"php-parallel-lint/php-parallel-lint": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.1.0|^0.2.1"
},
"autoload-dev": {
"classmap": [
"tests/concerns/InteractsWithAuthentication.php",
"tests/fixtures/backend/models/UserFixture.php",
"tests/TestCase.php",
"tests/PluginTestCase.php"
]
},
"scripts": {
"post-create-project-cmd": [
"@php artisan key:generate",
"@php artisan package:discover"
"@php artisan key:generate"
],
"post-update-cmd": [
"@php artisan winter:version",
Expand All @@ -66,7 +57,7 @@
"phpunit --stop-on-failure"
],
"lint": [
"parallel-lint --exclude vendor --exclude storage --exclude tests/fixtures/plugins/testvendor/goto/Plugin.php ."
"parallel-lint --exclude vendor --exclude storage --exclude modules/system/tests/fixtures/plugins/testvendor/goto/Plugin.php ."
],
"sniff": [
"phpcs --colors -nq --report=\"full\" --extensions=\"php\""
Expand Down

0 comments on commit 74c3bbd

Please sign in to comment.