Skip to content

Commit

Permalink
After freeze into main (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
zemekoule authored Feb 28, 2025
2 parents b48656d + 70e492e commit bae4741
Show file tree
Hide file tree
Showing 679 changed files with 23,791 additions and 10,536 deletions.
9 changes: 6 additions & 3 deletions .ecrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
"^node_modules\/",
"^.git\/",
"^deps\/",
"^log\/",
"^tests-coverage\/",
"^phpstan\/vendor\/",
"^public\/libs\/",
"^public\/block\/index.asset.php",
"^public\/block\/index.js",
"^public\/block\/block.json",
"^public\/js\/live-form-validation-extension.js",
"^languages\/",
"LICENSE$",
"^temp\/",
"^log\/",
"^\\.idea\/",
"^.phpunit.result.cache$",
"\\.DS_Store$",
"\\.phar$"
"\\.phar$",
"\\.phpunit.result.cache$",
"^soap-php-bugfix-dev.wsdl$"
],
"Disable": {
"MaxLineLength": true
Expand Down
13 changes: 13 additions & 0 deletions .github/run-phpcbf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

./vendor/bin/phpcbf
exit_code=$?

# Check if phpcbf made changes (non-zero exit code indicates fixes were made)
if [ $exit_code -ne 0 ]; then
echo "🛑 phpcbf made changes to the code."
exit 1
else
echo "✓ no changes were made by phpcbf."
exit 0
fi
8 changes: 4 additions & 4 deletions .github/run-sniffer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ php --version | head -1
echo "ℹ︎ Composer version:"
composer --version

echo "➤ Installing woocommerce/woocommerce-sniffs:"
composer --no-interaction --quiet --no-dev install
echo "➤ Installing dependencies..."
composer --no-interaction --quiet install

echo "➤ Running sniffer:"
./vendor/bin/phpcs -s | tee /tmp/sniffer.log
./vendor/bin/phpcs -s 2>&1 | tee /tmp/sniffer.log

if grep -q '| ERROR' /tmp/sniffer.log; then
if grep -q 'ERROR' /tmp/sniffer.log; then
echo "🛑 Sniffer found errors, fix them."
exit 1
fi
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/run-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Composer security audit
on:
push:
branches: [ main ]
pull_request:
jobs:
audit:
name: Run composer security audit
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Validate PHP Version
run: php -v

- name: Running composer security audit
shell: bash
run: |
composer install
composer audit
composer install --working-dir=deps-composer
composer audit --working-dir=deps-composer
34 changes: 34 additions & 0 deletions .github/workflows/run-ec-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: editorconfig check

on:
push:
branches: [ main ]
pull_request:

jobs:
editorconfig-check:
runs-on: ubuntu-24.04

strategy:
matrix:
php-version: [ '8.1' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: yes

- name: php version
run: php -v

- name: Install Composer dependencies
run: composer install

- name: Run editorconfig check
run: composer check:ec
35 changes: 35 additions & 0 deletions .github/workflows/run-parallel-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PHP parallel lint

on:
push:
branches: [ main ]
pull_request:

jobs:
php-parallel-lint:
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none

- name: php version
run: php -v

- name: Install php-parallel-lint
run: composer create-project php-parallel-lint/php-parallel-lint ./temp/php-parallel-lint --no-dev

- name: Run PHP parallel lint
run: ./temp/php-parallel-lint/parallel-lint . --exclude ./tests
34 changes: 34 additions & 0 deletions .github/workflows/run-phpcbf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: phpcbf check

on:
push:
branches: [ main ]
pull_request:

jobs:
phpcbf-check:
runs-on: ubuntu-24.04

strategy:
matrix:
php-version: [ '8.1' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: yes

- name: php version
run: php -v

- name: Install Composer dependencies
run: composer install

- name: Run phpcbf
run: bash "${GITHUB_WORKSPACE}/.github/run-phpcbf.sh"
22 changes: 3 additions & 19 deletions .github/workflows/run-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

strategy:
matrix:
php-version: [ '8.1', '8.2', '8.3' ]
php-version: [ '8.1', '8.2', '8.3', '8.4' ]

steps:
- name: Checkout code
Expand All @@ -28,23 +28,7 @@ jobs:
run: php -v

- name: Install Composer dependencies
working-directory: phpstan
run: composer install

- name: Run PHPStan with phpversion 7.2
run: composer run phpstan-72

- name: Run PHPStan with phpversion 7.4
run: composer run phpstan-74

- name: Run PHPStan with phpversion 8.0
run: composer run phpstan-80

- name: Run PHPStan with phpversion 8.1
run: composer run phpstan-81

- name: Run PHPStan with phpversion 8.2
run: composer run phpstan-82

- name: Run PHPStan with phpversion 8.3
run: composer run phpstan-83
- name: Run PHPStan with PHP version 7.2 - 8.3
run: composer run phpstan:all
100 changes: 74 additions & 26 deletions .github/workflows/run-phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,86 @@
name: PHPUnit tests

on:
push:
branches: [ main ]
pull_request:
push:
branches: [ main ]
pull_request:

jobs:
phpunit:
runs-on: ubuntu-24.04
phpunit:
runs-on: ubuntu-24.04

strategy:
matrix:
php-version: [ '8.1' ]
strategy:
matrix:
php-version: [ '8.1' ]

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: yes
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: yes

- name: php version
run: php -v
- name: php version
run: php -v

- name: Install Composer dependencies
run: composer install
- name: Install Composer dependencies
run: composer install

- name: Install Composer dev dependencies
working-directory: phpstan
run: composer install
- name: Run PHPUnit
run: composer run tests-unit

- name: Run PHPUnit
run: composer run tests-unit
- name: Run PHPUnit with code coverage
run: |
composer run tests-coverage
cat tests-coverage/coverage.txt > tests-coverage/coverage-summary.txt
- name: Post coverage report as comment in PR
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const coverageSummary = fs.readFileSync('tests-coverage/coverage-summary.txt', 'utf8');
const commentBody = `
## :bar_chart: Code Coverage Report
\`\`\`
${coverageSummary}
\`\`\`
`;
const { data: comments } = await github.rest.issues.listComments({
...context.repo,
issue_number: context.payload.pull_request.number,
});
const existingComment = comments.find(comment => comment.body.includes(':bar_chart: Code Coverage Report'));
if (existingComment) {
await github.rest.issues.updateComment({
...context.repo,
comment_id: existingComment.id,
body: commentBody,
});
} else {
await github.rest.issues.createComment({
...context.repo,
issue_number: context.payload.pull_request.number,
body: commentBody,
});
}
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: junit-results
path: ./tests-coverage/log/junit.xml

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ./tests-coverage/cobertura.xml
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/.idea/
/vendor
/phpcs/vendor
/phpstan/vendor
/temp/*
!/temp/.gitignore
/log/
**/.DS_Store
/tests-coverage/
/.phpunit.result.cache
/config/config.local.neon
/node_modules/
phpunit.xml
soap-php-bugfix-dev.wsdl
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ This is the official plugin, that allows you to choose pickup points of Packeta

#### Supported versions

- PHP: 7.2 - 8.2
- PHP: 7.2 - 8.4
- WordPress 5.5+
- WooCommerce 4.5+
- WooCommerce 5.1+

#### Functions provided

Expand Down
5 changes: 4 additions & 1 deletion bootstrap-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
* @package Packeta
*/

define( 'WP_DEBUG', false );
if ( ! defined( 'WP_DEBUG' ) ) {
define( 'WP_DEBUG', false );
}

return require __DIR__ . '/bootstrap.php';
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$configurator->setDebugMode( PACKETERY_DEBUG );

Debugger::$logDirectory = PACKETERY_PLUGIN_DIR . '/log';
if ( $configurator->isDebugMode() && false === wp_doing_cron() ) {
if ( $configurator->isDebugMode() && wp_doing_cron() === false ) {
$configurator->enableDebugger( Debugger::$logDirectory );
Debugger::$strictMode = false;
}
Expand Down
Loading

0 comments on commit bae4741

Please sign in to comment.