Skip to content

Commit ff818db

Browse files
authored
Merge branch 'main' into patch-17
2 parents d832611 + 4ddd7fb commit ff818db

File tree

1,554 files changed

+7863
-4908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,554 files changed

+7863
-4908
lines changed

.ddev/commands/web/localdev

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
## Description: create local development directory
4+
## Usage: localdev
5+
## Example: ddev localdev <git-url>
6+
7+
if [ ! -d ".localdev/" ]
8+
then
9+
mkdir ".localdev/"
10+
echo "Directory created."
11+
fi
12+
13+
if ! grep -q "./.localdev/*" composer.json; then
14+
php vendor/bin/composer config repositories.local '{"type": "path", "url": "./.localdev/*", "canonical": false}'
15+
echo "Patched composer.json."
16+
fi
17+
18+
cd ".localdev/" || exit
19+
git clone "$@"

.ddev/commands/web/phpunit

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
## Description: run PHPUnit
4+
## Usage: phpunit
5+
## Example: ddev phpunit
6+
7+
php vendor/bin/phpunit --no-coverage "$@" --testdox

.ddev/commands/web/phpunit-coverage

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
## Description: run PHPUnit with coverage
4+
## Usage: phpunit-coverage
5+
## Example: ddev phpunit-coverage
6+
7+
enable_xdebug
8+
XDEBUG_MODE=coverage php vendor/bin/phpunit --testdox
9+
disable_xdebug
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
## Description: run PHPUnit with local HTML coverage
4+
## Usage: phpunit-coverage-local
5+
## Example: ddev phpunit-coverage-local
6+
7+
enable_xdebug
8+
XDEBUG_MODE=coverage php vendor/bin/phpunit --coverage-html build/coverage --testdox
9+
disable_xdebug

.ddev/commands/web/rector

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
## Usage: rector
55
## Example: ddev rector <path-to-files>
66

7-
cp -n vendor/sreichel/openmage-rector/rector.php rector.php
87
php vendor/bin/rector process "$@"

.gitattributes

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.github export-ignore
44
/dev export-ignore
55
/docs export-ignore
6+
/tests export-ignore
67

78
/.all-contributorsrc export-ignore
89
/.gitattributes export-ignore
@@ -14,9 +15,9 @@
1415
/.phpcs.php.xml.dist export-ignore
1516
/.phpcs.xml.dist export-ignore
1617
/.phpmd.dist.xml export-ignore
17-
/phpstan.dist.baseline.neon export-ignore
18-
/phpstan.dist.issues.neon export-ignore
19-
/phpstan.dist.neon export-ignore
18+
/.phpstan.dist.baseline.neon export-ignore
19+
/.phpstan.dist.neon export-ignore
20+
/rector.php export-ignore
2021

2122
/README.md export-ignore
2223

.github/labeler.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,9 @@
895895
'phpunit':
896896
- changed-files:
897897
- any-glob-to-any-file: [
898-
dev/test/*,
899-
dev/phpunit*,
900-
dev/sonar*,
901-
.github/workflows/phpunit.yml,
902-
.github/workflows/sonar.yml
898+
phpunit*,
899+
tests/*,
900+
.github/workflows/phpunit.yml
903901
]
904902

905903
'ddev':
@@ -908,3 +906,10 @@
908906
.ddev/*,
909907
.ddev/**/*
910908
]
909+
910+
'rector':
911+
- changed-files:
912+
- any-glob-to-any-file: [
913+
rector.php,
914+
.github/workflows/rector.yml
915+
]

.github/workflows/check-files.yml

+5-17
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ on:
3333
phpunit:
3434
description: "Count changed PhpUnit files"
3535
value: ${{ jobs.check.outputs.phpunit }}
36-
sonar:
37-
description: "Count changed Sonar files"
38-
value: ${{ jobs.check.outputs.sonar }}
3936
# Allow manually triggering the workflow.
4037
workflow_dispatch:
4138

@@ -54,7 +51,6 @@ jobs:
5451
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
5552
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
5653
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
57-
sonar: ${{ steps.changes-sonar.outputs.sonar }}
5854

5955
steps:
6056
- name: Checkout code
@@ -87,9 +83,9 @@ jobs:
8783
**phpcs**
8884
**php-cs-fixer**
8985
**phpstan**
90-
dev/tests/
91-
dev/phpunit*
92-
dev/sonar*
86+
rector.php
87+
tests/
88+
phpunit*
9389
9490
- name: Check if composer files changed
9591
id: changes-composer
@@ -161,22 +157,14 @@ jobs:
161157
id: changes-phpunit-test
162158
if: steps.changed-files-specific.outputs.any_modified == 'true'
163159
run: |
164-
count="$(grep -oE "dev/tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
160+
count="$(grep -oE "tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
165161
echo "$count UnitTest test file(s) changed"
166162
echo "phpunit-test=$count" >> $GITHUB_OUTPUT
167163
168164
- name: Check if PHPUnit files changed
169165
id: changes-phpunit
170166
if: steps.changed-files-specific.outputs.any_modified == 'true'
171167
run: |
172-
count="$(grep -oE "dev/phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
168+
count="$(grep -oE "phpunit*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
173169
echo "$count PHPUnit file(s) changed"
174170
echo "phpunit=$count" >> $GITHUB_OUTPUT
175-
176-
- name: Check if Sonar files changed
177-
id: changes-sonar
178-
if: steps.changed-files-specific.outputs.any_modified == 'true'
179-
run: |
180-
count="$(grep -oE "dev/sonar*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
181-
echo "$count Sonar file(s) changed"
182-
echo "sonar=$count" >> $GITHUB_OUTPUT

.github/workflows/phpunit.yml

+80-20
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,39 @@ on:
1010

1111
jobs:
1212
unit-tests:
13-
runs-on: [ubuntu-latest]
13+
runs-on: ${{ matrix.operating-system }}
14+
strategy:
15+
matrix:
16+
operating-system: [ubuntu-latest]
17+
php-versions: ['7.4', '8.3']
18+
mysql-version: ['5.7', '8.0']
19+
20+
services:
21+
mysql:
22+
image: mysql:${{ matrix.mysql-version }}
23+
env:
24+
MYSQL_ROOT_PASSWORD: root
25+
MYSQL_DATABASE: db
26+
ports:
27+
- 3306:3306
28+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
1429

1530
steps:
16-
- uses: actions/checkout@v4
31+
- name: Validate mysql service
32+
run: |
33+
echo "Checking mysql service"
34+
sudo apt-get install -y mysql-client
35+
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES"
36+
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
1739
with:
18-
repository: OpenMage/Testfield
19-
path: ./
40+
php-version: ${{ matrix.php-versions }}
41+
coverage: pcov #optional, setup coverage driver
42+
env:
43+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2044

21-
- name: Validate composer
22-
run: composer validate
45+
- uses: actions/checkout@v4
2346

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

3558
- name: Install dependencies
36-
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
37-
38-
- name: Checkout OpenMage repo
39-
uses: actions/checkout@v4
40-
with:
41-
path: openmage
59+
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
4260

43-
- name: Install OpenMage dependencies
44-
working-directory: ./openmage
45-
run: composer install --prefer-dist --no-progress --ignore-platform-reqs --no-dev
61+
- name: Install OpenMage
62+
run: |
63+
php -f install.php -- \
64+
--license_agreement_accepted 'yes' \
65+
--locale 'en_US' \
66+
--timezone 'America/New_York' \
67+
--db_host '127.0.0.1' \
68+
--db_name 'db' \
69+
--db_user 'root' \
70+
--db_pass 'root' \
71+
--db_prefix '' \
72+
--url 'http://openmage.local' \
73+
--use_rewrites 'yes' \
74+
--use_secure 'yes' \
75+
--secure_base_url 'http://openmage.local' \
76+
--use_secure_admin 'yes' \
77+
--admin_username 'admin' \
78+
--admin_lastname 'Administrator' \
79+
--admin_firstname 'OpenMage' \
80+
--admin_email '[email protected]' \
81+
--admin_password 'veryl0ngpassw0rd' \
82+
--session_save 'files' \
83+
--admin_frontname 'admin' \
84+
--backend_frontname 'admin' \
85+
--default_currency 'USD' \
86+
--enable_charts 'yes' \
87+
--skip_url_validation 'yes'
4688
47-
- name: run phpUnit
48-
run: bash ./run_unit_tests.sh
89+
- name: Run phpUnit
90+
run: php -f vendor/bin/phpunit
4991

5092
- name: Publish Unit Test Results
51-
uses: EnricoMi/publish-unit-test-result-action@v2.7
93+
uses: EnricoMi/publish-unit-test-result-action@v2
5294
if: always()
53-
continue-on-error: true
5495
with:
5596
github_token: ${{ secrets.GITHUB_TOKEN }}
56-
files: output/*.xml
97+
files: tests/logging/*.xml
98+
99+
- name: prepare SonarCloud Scan Data
100+
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }}
101+
run: |
102+
head tests/coverage/clover.xml
103+
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/logging/junit.xml
104+
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/coverage/clover.xml
105+
head ./tests/coverage/clover.xml
106+
107+
- name: SonarCloud Scan
108+
uses: SonarSource/sonarcloud-github-action@master
109+
continue-on-error: true
110+
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }} && SONAR_TOKEN
111+
with:
112+
args: >
113+
-Dproject.settings=tests/sonar-project.properties
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
116+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/rector.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Rector
2+
3+
on:
4+
workflow_call:
5+
# Allow manually triggering the workflow.
6+
workflow_dispatch:
7+
8+
jobs:
9+
rector:
10+
name: Validation
11+
runs-on: [ubuntu-latest]
12+
13+
steps:
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: 7.4
18+
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Get composer cache directory
23+
id: composer-cache
24+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
25+
26+
- name: Cache dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
33+
- name: Install dependencies
34+
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
35+
36+
- name: Rector
37+
run: php vendor/bin/rector process --dry-run

.github/workflows/sonar.yml

-71
This file was deleted.

0 commit comments

Comments
 (0)