Skip to content

Commit

Permalink
Merge remote-tracking branch 'lts/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.ddev/commands/web/phpunit
#	.github/workflows/labeler.yml
#	.github/workflows/phpstan.yml
#	.github/workflows/phpunit.yml
#	.github/workflows/sonar.yml
#	.github/workflows/syntax-php.yml
#	.github/workflows/update-copyright.yml
#	.github/workflows/workflow.yml
#	.gitignore
#	.gitpod.yml
#	.php-cs-fixer.dist.php
#	.phpcs.php.xml.dist
#	.phpcs.xml.dist
#	.phpstan.dist.baseline.neon
#	.phpstan.dist.neon
#	app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
#	app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php
#	app/code/core/Mage/Api/Model/Server/Adapter/Jsonrpc.php
#	app/code/core/Mage/Media/Model/File/Image.php
#	composer.json
#	composer.lock
#	dev/gitpod/docker-compose.yml
#	dev/tests/unit/Base/ClassLoadingTest.php
#	dev/tests/unit/Base/XmlFileLoadingTest.php
#	dev/tests/unit/Mage/Core/Helper/StringTest.php
#	lib/Varien/Object.php
#	lib/Varien/Profiler.php
#	phpunit.xml.dist
#	tests/sonar-project.properties
#	tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php
#	tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTestHelper.php
#	tests/unit/Mage/Core/Helper/SecurityTest.php
#	tests/unit/Mage/Uploader/Helper/FileTest.php
#	tests/unit/Varien/Db/Adapter/Pdo/MysqlTest.php
  • Loading branch information
sreichel committed Oct 27, 2024
2 parents 68a5b92 + 94ee1fc commit 1789df1
Show file tree
Hide file tree
Showing 1,493 changed files with 13,173 additions and 12,969 deletions.
19 changes: 19 additions & 0 deletions .ddev/commands/web/localdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

## Description: create local development directory
## Usage: localdev
## Example: ddev localdev <git-url>

if [ ! -d ".localdev/" ]
then
mkdir ".localdev/"
echo "Directory created."
fi

if ! grep -q "./.localdev/*" composer.json; then
php vendor/bin/composer config repositories.local '{"type": "path", "url": "./.localdev/*", "canonical": false}'
echo "Patched composer.json."
fi

cd ".localdev/" || exit
git clone "$@"
2 changes: 1 addition & 1 deletion .ddev/commands/web/magerun
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Example: "ddev magerun"

if [ ! -f vendor/bin/n98-magerun ]; then
read -r -p "n98-magerun is not installed. Do you want to install it? [y/N] " INSTALL_MAGE
read -r -p "n98-magerun is not installed. Do you want to install it? [y/N] " INSTALL_MAGERUN
INSTALL_MAGERUN=${INSTALL_MAGERUN,,} # to lower
if [[ "${INSTALL_MAGERUN}" =~ ^(yes|y) ]]; then
composer require --dev n98/magerun:dev-develop
Expand Down
6 changes: 3 additions & 3 deletions .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

## Description: run PHPSUnit
## Description: run PHPUnit
## Usage: phpunit
## Example: ddev phpunit <path-to-files>
## Example: ddev phpunit

php vendor/bin/phpunit
php vendor/bin/phpunit --no-coverage "$@" --testdox
9 changes: 9 additions & 0 deletions .ddev/commands/web/phpunit-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## Description: run PHPUnit with coverage
## Usage: phpunit-coverage
## Example: ddev phpunit-coverage

enable_xdebug
XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox
disable_xdebug
9 changes: 9 additions & 0 deletions .ddev/commands/web/phpunit-coverage-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## Description: run PHPUnit with local HTML coverage
## Usage: phpunit-coverage-local
## Example: ddev phpunit-coverage-local

enable_xdebug
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox
disable_xdebug
1 change: 0 additions & 1 deletion .ddev/commands/web/rector
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
## Usage: rector
## Example: ddev rector <path-to-files>

cp -n vendor/sreichel/openmage-rector/rector.php rector.php
php vendor/bin/rector process "$@"
7 changes: 4 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/.github export-ignore
/dev export-ignore
/docs export-ignore
/tests export-ignore

/.all-contributorsrc export-ignore
/.gitattributes export-ignore
Expand All @@ -14,9 +15,9 @@
/.phpcs.php.xml.dist export-ignore
/.phpcs.xml.dist export-ignore
/.phpmd.dist.xml export-ignore
/phpstan.dist.baseline.neon export-ignore
/phpstan.dist.issues.neon export-ignore
/phpstan.dist.neon export-ignore
/.phpstan.dist.baseline.neon export-ignore
/.phpstan.dist.neon export-ignore
/rector.php export-ignore

/README.md export-ignore

Expand Down
16 changes: 11 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -887,18 +887,17 @@
'phpstan':
- changed-files:
- any-glob-to-any-file: [
.phpstan*,
phpstan*,
.github/workflows/phpstan.yml
]

'phpunit':
- changed-files:
- any-glob-to-any-file: [
dev/test/*,
dev/phpunit*,
dev/sonar*,
.github/workflows/phpunit.yml,
.github/workflows/sonar.yml
phpunit*,
tests/*,
.github/workflows/phpunit.yml
]

'ddev':
Expand All @@ -907,3 +906,10 @@
.ddev/*,
.ddev/**/*
]

'rector':
- changed-files:
- any-glob-to-any-file: [
rector.php,
.github/workflows/rector.yml
]
10 changes: 5 additions & 5 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ jobs:
**phpcs**
**php-cs-fixer**
**phpstan**
dev/tests/
dev/phpunit*
dev/sonar*
rector.php
tests/
phpunit*
- name: Check if composer files changed
id: changes-composer
Expand Down Expand Up @@ -157,14 +157,14 @@ jobs:
id: changes-phpunit-test
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
count="$(grep -oE "tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count UnitTest test file(s) changed"
echo "phpunit-test=$count" >> $GITHUB_OUTPUT
- name: Check if PHPUnit files changed
id: changes-phpunit
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
count="$(grep -oE "phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPUnit file(s) changed"
echo "phpunit=$count" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:

- name: PHPCodeSniffer
run: php vendor/bin/phpcs -s --report=full --standard=${{ matrix.rules.path }}
continue-on-error: ${{ matrix.rules.path != '.phpcs.xml.dist' }}
continue-on-error: ${{ matrix.rules.path == '.phpcs.ecg.xml.dist' }}
17 changes: 16 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.3']
php-versions: ['7.4', '8.4']

steps:
- name: Setup PHP
Expand All @@ -36,5 +36,20 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: Restore result cache
uses: actions/cache/restore@v3
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}"
restore-keys: |
phpstan-result-cache-
- name: PHPStan Static Analysis
run: XDEBUG_MODE=off php vendor/bin/phpstan.phar analyze

- name: Save result cache
uses: actions/cache/save@v3
if: always()
with:
path: .phpstan.cache
key: "phpstan-result-cache-${{ github.run_id }}"
25 changes: 13 additions & 12 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.3']
mysql-version: ["8.0", "5.7"]
php-versions: ['7.4', '8.3']
mysql-version: ['5.7', '8.0']

services:
mysql:
Expand All @@ -42,6 +42,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: pcov #optional, setup coverage driver
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4

Expand Down Expand Up @@ -93,27 +96,25 @@ jobs:
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
continue-on-error: true
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: output/*.xml
files: tests/logging/*.xml

- name: prepare SonarCloud Scan Data
continue-on-error: true
if: ${{ matrix.php-versions == '7.4' }} && {{ matrix.mysql-version == '5.7' }}
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }}
run: |
head dev/tests/clover.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' dev/tests/junit.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' dev/tests/clover.xml
head ./dev/tests/clover.xml
head tests/coverage/clover.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/logging/junit.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/coverage/clover.xml
head ./tests/coverage/clover.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
continue-on-error: true
if: ${{ matrix.php-versions == '7.4' }} && {{ matrix.mysql-version == '5.7' }} && SONAR_TOKEN
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }} && SONAR_TOKEN
with:
args: >
-Dproject.settings=dev/sonar-project.properties
-Dproject.settings=tests/sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Rector

on:
workflow_call:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
rector:
name: Validation
runs-on: [ubuntu-latest]

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

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

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: Rector
run: php vendor/bin/rector process --dry-run
71 changes: 0 additions & 71 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -1,71 +0,0 @@
name: Sonar

on:
# Run automatically every Monday on midnight.
schedule:
- cron: '0 0 * * 1'
workflow_call:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
unit:
name: Unit Tests on ${{ matrix.php }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 5
matrix:
os: [ubuntu-latest]
php: ['8.1', '8.3']
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring
tools: composer, pecl, phpcs, phpstan, phpunit:9.5
ini-values: pcov.directory=api, post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: pcov #optional, setup coverage driver
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --dev -n --prefer-source --ignore-platform-req=php+

- name: Run Unit Tests
run: phpunit --testsuite=Unit;

- name: prepare SonarCloud Scan Data
continue-on-error: true
if: ${{ matrix.php == '8.3' }}
run: |
echo $PWD
ls -la
head ./dev/tests/reports/clover.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/logs/junit.xml
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' ./dev/tests/reports/clover.xml
head ./dev/tests/reports/clover.xml
ls -la
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
continue-on-error: true
if: ${{ matrix.php == '8.3' }} && SONAR_TOKEN
with:
args: >
-Dproject.settings=tests/sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/syntax-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
php: ['8.1', '8.3']
php: ['7.4', '8.4']

name: PHP Syntax ${{ matrix.php }}

Expand Down
Loading

0 comments on commit 1789df1

Please sign in to comment.