Skip to content

Commit

Permalink
Merge branch 'main' into fix-swatch-product-list-stock-status
Browse files Browse the repository at this point in the history
  • Loading branch information
empiricompany authored Sep 22, 2024
2 parents 715fa52 + 75cd467 commit b0f564a
Show file tree
Hide file tree
Showing 1,548 changed files with 7,179 additions and 4,883 deletions.
7 changes: 7 additions & 0 deletions .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

## Description: run PHPUnit
## Usage: phpunit
## Example: ddev 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
15 changes: 10 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,9 @@
'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 @@ -908,3 +906,10 @@
.ddev/*,
.ddev/**/*
]

'rector':
- changed-files:
- any-glob-to-any-file: [
rector.php,
.github/workflows/rector.yml
]
22 changes: 5 additions & 17 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ on:
phpunit:
description: "Count changed PhpUnit files"
value: ${{ jobs.check.outputs.phpunit }}
sonar:
description: "Count changed Sonar files"
value: ${{ jobs.check.outputs.sonar }}
# Allow manually triggering the workflow.
workflow_dispatch:

Expand All @@ -54,7 +51,6 @@ jobs:
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
sonar: ${{ steps.changes-sonar.outputs.sonar }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -87,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 @@ -161,22 +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
- name: Check if Sonar files changed
id: changes-sonar
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "dev/sonar*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Sonar file(s) changed"
echo "sonar=$count" >> $GITHUB_OUTPUT
100 changes: 80 additions & 20 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,39 @@ on:

jobs:
unit-tests:
runs-on: [ubuntu-latest]
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.3']
mysql-version: ['5.7', '8.0']

services:
mysql:
image: mysql:${{ matrix.mysql-version }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v4
- name: Validate mysql service
run: |
echo "Checking mysql service"
sudo apt-get install -y mysql-client
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
repository: OpenMage/Testfield
path: ./
php-version: ${{ matrix.php-versions }}
coverage: pcov #optional, setup coverage driver
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Validate composer
run: composer validate
- uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
Expand All @@ -33,24 +56,61 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-reqs

- name: Checkout OpenMage repo
uses: actions/checkout@v4
with:
path: openmage
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: Install OpenMage dependencies
working-directory: ./openmage
run: composer install --prefer-dist --no-progress --ignore-platform-reqs --no-dev
- name: Install OpenMage
run: |
php -f install.php -- \
--license_agreement_accepted 'yes' \
--locale 'en_US' \
--timezone 'America/New_York' \
--db_host '127.0.0.1' \
--db_name 'db' \
--db_user 'root' \
--db_pass 'root' \
--db_prefix '' \
--url 'http://openmage.local' \
--use_rewrites 'yes' \
--use_secure 'yes' \
--secure_base_url 'http://openmage.local' \
--use_secure_admin 'yes' \
--admin_username 'admin' \
--admin_lastname 'Administrator' \
--admin_firstname 'OpenMage' \
--admin_email 'admin@example.com' \
--admin_password 'veryl0ngpassw0rd' \
--session_save 'files' \
--admin_frontname 'admin' \
--backend_frontname 'admin' \
--default_currency 'USD' \
--enable_charts 'yes' \
--skip_url_validation 'yes'
- name: run phpUnit
run: bash ./run_unit_tests.sh
- name: Run phpUnit
run: php -f vendor/bin/phpunit

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2.7
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
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }}
run: |
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
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 }}
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

This file was deleted.

Loading

0 comments on commit b0f564a

Please sign in to comment.