Skip to content

Commit c56edf2

Browse files
authored
Merge pull request #7727 from paulbalandan/composer-normalize
chore: Add `composer-normalize` to auto-review testing of composer.json
2 parents add8ad8 + fa8059b commit c56edf2

File tree

5 files changed

+197
-85
lines changed

5 files changed

+197
-85
lines changed

.github/workflows/test-autoreview.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,79 @@ jobs:
2929
php-version: '8.1'
3030
job-id: auto-review-tests
3131
group-name: AutoReview
32+
33+
composer-normalize-tests:
34+
name: Check normalized composer.json
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v3
39+
40+
- name: Setup PHP
41+
uses: shivammathur/setup-php@v2
42+
with:
43+
php-version: '8.1'
44+
45+
- name: Install dependencies
46+
run: composer update
47+
48+
- name: Run on root composer.json
49+
id: normalize-root-composer
50+
if: ${{ always() }}
51+
run: |
52+
echo "ROOT_COMPOSER_RESULT<<RCR" >> $GITHUB_OUTPUT
53+
echo "$(composer normalize)" >> $GITHUB_OUTPUT
54+
echo "RCR" >> $GITHUB_OUTPUT
55+
56+
- name: Run on framework composer.json
57+
id: normalize-framework-composer
58+
if: ${{ always() }}
59+
working-directory: admin/framework
60+
run: |
61+
echo "FRAMEWORK_COMPOSER_RESULT<<FCR" >> $GITHUB_OUTPUT
62+
echo "$(composer normalize)" >> $GITHUB_OUTPUT
63+
echo "FCR" >> $GITHUB_OUTPUT
64+
65+
- name: Run on starter composer.json
66+
id: normalize-starter-composer
67+
if: ${{ always() }}
68+
working-directory: admin/starter
69+
run: |
70+
echo "STARTER_COMPOSER_RESULT<<SCR" >> $GITHUB_OUTPUT
71+
echo "$(composer normalize)" >> $GITHUB_OUTPUT
72+
echo "SCR" >> $GITHUB_OUTPUT
73+
74+
- name: Analyse normalization results
75+
run: |
76+
if [[ '${{ steps.normalize-root-composer.conclusion }}' == 'failure' ]]; then
77+
echo 'Normalization of root composer.json encountered a problem.';
78+
echo 'Please run it locally: `composer normalize`';
79+
exit 1;
80+
fi
81+
82+
if [[ ${{ contains(steps.normalize-root-composer.outputs.ROOT_COMPOSER_RESULT, 'Successfully normalized') }} == true ]]; then
83+
echo 'Root composer.json is not yet normalized.';
84+
exit 1;
85+
fi
86+
87+
if [[ '${{ steps.normalize-framework-composer.conclusion }}' == 'failure' ]]; then
88+
echo 'Normalization of framework composer.json encountered a problem.';
89+
echo 'Please run it locally: `composer normalize -d admin/framework`';
90+
exit 1;
91+
fi
92+
93+
if [[ ${{ contains(steps.normalize-framework-composer.outputs.FRAMEWORK_COMPOSER_RESULT, 'Successfully normalized') }} == true ]]; then
94+
echo 'Framework composer.json is not yet normalized.';
95+
exit 1;
96+
fi
97+
98+
if [[ '${{ steps.normalize-starter-composer.conclusion }}' == 'failure' ]]; then
99+
echo 'Normalization of starter composer.json encountered a problem.';
100+
echo 'Please run it locally: `composer normalize -d admin/starter`';
101+
exit 1;
102+
fi
103+
104+
if [[ ${{ contains(steps.normalize-starter-composer.outputs.STARTER_COMPOSER_RESULT, 'Successfully normalized') }} == true ]]; then
105+
echo 'Starter composer.json is not yet normalized.';
106+
exit 1;
107+
fi

admin/framework/composer.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "codeigniter4/framework",
3-
"type": "project",
43
"description": "The CodeIgniter framework v4",
5-
"homepage": "https://codeigniter.com",
64
"license": "MIT",
5+
"type": "project",
6+
"homepage": "https://codeigniter.com",
7+
"support": {
8+
"forum": "https://forum.codeigniter.com/",
9+
"source": "https://github.com/codeigniter4/CodeIgniter4",
10+
"slack": "https://codeigniterchat.slack.com"
11+
},
712
"require": {
813
"php": "^7.4 || ^8.0",
914
"ext-intl": "*",
@@ -13,39 +18,34 @@
1318
"psr/log": "^1.1"
1419
},
1520
"require-dev": {
16-
"kint-php/kint": "^5.0.4",
1721
"codeigniter/coding-standard": "^1.5",
1822
"fakerphp/faker": "^1.9",
1923
"friendsofphp/php-cs-fixer": "3.13.0",
24+
"kint-php/kint": "^5.0.4",
2025
"mikey179/vfsstream": "^1.6",
2126
"nexusphp/cs-config": "^3.6",
2227
"phpunit/phpunit": "^9.1",
2328
"predis/predis": "^1.1 || ^2.0"
2429
},
2530
"suggest": {
2631
"ext-curl": "If you use CURLRequest class",
27-
"ext-imagick": "If you use Image class ImageMagickHandler",
28-
"ext-gd": "If you use Image class GDHandler",
32+
"ext-dom": "If you use TestResponse",
2933
"ext-exif": "If you run Image class tests",
30-
"ext-simplexml": "If you format XML",
34+
"ext-fileinfo": "Improves mime type detection for files",
35+
"ext-gd": "If you use Image class GDHandler",
36+
"ext-imagick": "If you use Image class ImageMagickHandler",
37+
"ext-libxml": "If you use TestResponse",
38+
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
39+
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
3140
"ext-mysqli": "If you use MySQL",
3241
"ext-oci8": "If you use Oracle Database",
3342
"ext-pgsql": "If you use PostgreSQL",
34-
"ext-sqlsrv": "If you use SQL Server",
35-
"ext-sqlite3": "If you use SQLite3",
36-
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
37-
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
43+
"ext-readline": "Improves CLI::input() usability",
3844
"ext-redis": "If you use Cache class RedisHandler",
39-
"ext-dom": "If you use TestResponse",
40-
"ext-libxml": "If you use TestResponse",
41-
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()",
42-
"ext-fileinfo": "Improves mime type detection for files",
43-
"ext-readline": "Improves CLI::input() usability"
44-
},
45-
"config": {
46-
"optimize-autoloader": true,
47-
"preferred-install": "dist",
48-
"sort-packages": true
45+
"ext-simplexml": "If you format XML",
46+
"ext-sqlite3": "If you use SQLite3",
47+
"ext-sqlsrv": "If you use SQL Server",
48+
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()"
4949
},
5050
"autoload": {
5151
"psr-4": {
@@ -55,12 +55,12 @@
5555
"**/Database/Migrations/**"
5656
]
5757
},
58+
"config": {
59+
"optimize-autoloader": true,
60+
"preferred-install": "dist",
61+
"sort-packages": true
62+
},
5863
"scripts": {
5964
"test": "phpunit"
60-
},
61-
"support": {
62-
"forum": "https://forum.codeigniter.com/",
63-
"source": "https://github.com/codeigniter4/CodeIgniter4",
64-
"slack": "https://codeigniterchat.slack.com"
6565
}
6666
}

admin/starter/composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "codeigniter4/appstarter",
3-
"type": "project",
43
"description": "CodeIgniter4 starter app",
5-
"homepage": "https://codeigniter.com",
64
"license": "MIT",
5+
"type": "project",
6+
"homepage": "https://codeigniter.com",
7+
"support": {
8+
"forum": "https://forum.codeigniter.com/",
9+
"source": "https://github.com/codeigniter4/CodeIgniter4",
10+
"slack": "https://codeigniterchat.slack.com"
11+
},
712
"require": {
813
"php": "^7.4 || ^8.0",
914
"codeigniter4/framework": "^4.0"
@@ -13,11 +18,6 @@
1318
"mikey179/vfsstream": "^1.6",
1419
"phpunit/phpunit": "^9.1"
1520
},
16-
"config": {
17-
"optimize-autoloader": true,
18-
"preferred-install": "dist",
19-
"sort-packages": true
20-
},
2121
"autoload": {
2222
"exclude-from-classmap": [
2323
"**/Database/Migrations/**"
@@ -28,12 +28,12 @@
2828
"Tests\\Support\\": "tests/_support"
2929
}
3030
},
31+
"config": {
32+
"optimize-autoloader": true,
33+
"preferred-install": "dist",
34+
"sort-packages": true
35+
},
3136
"scripts": {
3237
"test": "phpunit"
33-
},
34-
"support": {
35-
"forum": "https://forum.codeigniter.com/",
36-
"source": "https://github.com/codeigniter4/CodeIgniter4",
37-
"slack": "https://codeigniterchat.slack.com"
3838
}
3939
}

composer.json

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "codeigniter4/codeigniter4",
3-
"type": "project",
43
"description": "The CodeIgniter framework v4",
5-
"homepage": "https://codeigniter.com",
64
"license": "MIT",
5+
"type": "project",
6+
"homepage": "https://codeigniter.com",
7+
"support": {
8+
"forum": "https://forum.codeigniter.com/",
9+
"source": "https://github.com/codeigniter4/CodeIgniter4",
10+
"slack": "https://codeigniterchat.slack.com"
11+
},
712
"require": {
813
"php": "^7.4 || ^8.0",
914
"ext-intl": "*",
@@ -13,9 +18,10 @@
1318
"psr/log": "^1.1"
1419
},
1520
"require-dev": {
16-
"kint-php/kint": "^5.0.4",
1721
"codeigniter/coding-standard": "^1.5",
22+
"ergebnis/composer-normalize": "^2.28",
1823
"fakerphp/faker": "^1.9",
24+
"kint-php/kint": "^5.0.4",
1925
"mikey179/vfsstream": "^1.6",
2026
"nexusphp/cs-config": "^3.6",
2127
"nexusphp/tachycardia": "^1.0",
@@ -29,33 +35,23 @@
2935
},
3036
"suggest": {
3137
"ext-curl": "If you use CURLRequest class",
32-
"ext-imagick": "If you use Image class ImageMagickHandler",
33-
"ext-gd": "If you use Image class GDHandler",
38+
"ext-dom": "If you use TestResponse",
3439
"ext-exif": "If you run Image class tests",
35-
"ext-simplexml": "If you format XML",
40+
"ext-fileinfo": "Improves mime type detection for files",
41+
"ext-gd": "If you use Image class GDHandler",
42+
"ext-imagick": "If you use Image class ImageMagickHandler",
43+
"ext-libxml": "If you use TestResponse",
44+
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
45+
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
3646
"ext-mysqli": "If you use MySQL",
3747
"ext-oci8": "If you use Oracle Database",
3848
"ext-pgsql": "If you use PostgreSQL",
39-
"ext-sqlsrv": "If you use SQL Server",
40-
"ext-sqlite3": "If you use SQLite3",
41-
"ext-memcache": "If you use Cache class MemcachedHandler with Memcache",
42-
"ext-memcached": "If you use Cache class MemcachedHandler with Memcached",
49+
"ext-readline": "Improves CLI::input() usability",
4350
"ext-redis": "If you use Cache class RedisHandler",
44-
"ext-dom": "If you use TestResponse",
45-
"ext-libxml": "If you use TestResponse",
46-
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()",
47-
"ext-fileinfo": "Improves mime type detection for files",
48-
"ext-readline": "Improves CLI::input() usability"
49-
},
50-
"config": {
51-
"optimize-autoloader": true,
52-
"preferred-install": "dist",
53-
"sort-packages": true
54-
},
55-
"extra": {
56-
"branch-alias": {
57-
"dev-develop": "4.x-dev"
58-
}
51+
"ext-simplexml": "If you format XML",
52+
"ext-sqlite3": "If you use SQLite3",
53+
"ext-sqlsrv": "If you use SQL Server",
54+
"ext-xdebug": "If you use CIUnitTestCase::assertHeaderEmitted()"
5955
},
6056
"autoload": {
6157
"psr-4": {
@@ -71,6 +67,19 @@
7167
"Utils\\": "utils/"
7268
}
7369
},
70+
"config": {
71+
"allow-plugins": {
72+
"ergebnis/composer-normalize": true
73+
},
74+
"optimize-autoloader": true,
75+
"preferred-install": "dist",
76+
"sort-packages": true
77+
},
78+
"extra": {
79+
"branch-alias": {
80+
"dev-develop": "4.x-dev"
81+
}
82+
},
7483
"scripts": {
7584
"post-update-cmd": [
7685
"CodeIgniter\\ComposerScripts::postUpdate",
@@ -81,8 +90,6 @@
8190
"bash -c \"XDEBUG_MODE=off phpstan analyse\"",
8291
"rector process --dry-run"
8392
],
84-
"sa": "@analyze",
85-
"test": "phpunit",
8693
"cs": [
8794
"Composer\\Config::disableProcessTimeout",
8895
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
@@ -95,17 +102,14 @@
95102
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
96103
"php-cs-fixer fix --ansi --verbose --diff"
97104
],
98-
"style": "@cs-fix"
105+
"sa": "@analyze",
106+
"style": "@cs-fix",
107+
"test": "phpunit"
99108
},
100109
"scripts-descriptions": {
101110
"analyze": "Run static analysis",
102-
"test": "Run unit tests",
103111
"cs": "Check the coding style",
104-
"cs-fix": "Fix the coding style"
105-
},
106-
"support": {
107-
"forum": "https://forum.codeigniter.com/",
108-
"source": "https://github.com/codeigniter4/CodeIgniter4",
109-
"slack": "https://codeigniterchat.slack.com"
112+
"cs-fix": "Fix the coding style",
113+
"test": "Run unit tests"
110114
}
111115
}

0 commit comments

Comments
 (0)