Skip to content

Commit

Permalink
QA tool: add composer-normalize (#39)
Browse files Browse the repository at this point in the history
fixes #29
  • Loading branch information
jkowalleck authored Jan 4, 2022
1 parent cb7bf19 commit 98918ba
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 65 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ updates:
prefix: 'tools'
include: 'scope'
open-pull-requests-limit: 999
- directory: '/tools/composer-normalize'
package-ecosystem: 'composer'
schedule:
interval: 'weekly'
day: 'saturday'
allow:
- dependency-type: 'all'
versioning-strategy: 'auto'
labels: [ 'dependencies', 'tools' ]
commit-message:
## prefix maximum string length of 15
prefix: 'tools'
include: 'scope'
open-pull-requests-limit: 999

- package-ecosystem: 'github-actions'
directory: '/'
Expand Down
60 changes: 48 additions & 12 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
# this means: at 23:42 on Fridays
- cron: '42 23 * * 5'

env:
PHP_VERSION_LATEST: "8.1"

jobs:
tests:
name: ${{ matrix.name }}
Expand Down Expand Up @@ -63,7 +66,7 @@ jobs:
--no-interaction
- name: Install dependencies
run: >
composer update
composer install
--prefer-dist
--no-interaction
--no-progress
Expand Down Expand Up @@ -117,14 +120,14 @@ jobs:
- name: Install psalm
run: >
composer install
-dtools/psalm
--prefer-dist
--no-interaction
--no-progress
--no-suggest
working-directory: tools/psalm
- name: Install dependencies
run: >
composer update
composer install
--no-dev
--prefer-dist
--no-interaction
Expand Down Expand Up @@ -157,20 +160,20 @@ jobs:
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: ${{ env.PHP_VERSION_LATEST }}
tools: composer
coverage: none
- name: Install PHP-CS-Fixer
run: >
composer install
-dtools/php-cs-fixer
--prefer-dist
--no-interaction
--no-progress
--no-suggest
working-directory: tools/php-cs-fixer
- name: Install dependencies
run: >
composer update
composer install
--no-dev
--prefer-dist
--no-interaction
Expand All @@ -197,20 +200,20 @@ jobs:
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: ${{ env.PHP_VERSION_LATEST }}
tools: composer
coverage: none
- name: Install composer-require-checker
run: >
composer install
-dtools/composer-require-checker
--prefer-dist
--no-interaction
--no-progress
--no-suggest
working-directory: tools/composer-require-checker
- name: Install dependencies
run: >
composer update
composer install
--no-dev
--prefer-dist
--no-interaction
Expand All @@ -232,20 +235,20 @@ jobs:
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
php-version: ${{ env.PHP_VERSION_LATEST }}
tools: composer
coverage: none
- name: Install composer-require-checker
run: >
composer install
-dtools/composer-unused
--prefer-dist
--no-interaction
--no-progress
--no-suggest
working-directory: tools/composer-unused
- name: Install dependencies
run: >
composer update
composer install
--no-dev
--prefer-dist
--no-interaction
Expand All @@ -256,3 +259,36 @@ jobs:
php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused
--no-progress
--no-interaction
composer-normalize:
name: Composer normalize
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
# see https://github.com/actions/checkout
uses: actions/checkout@v2
- name: Setup PHP
# see https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_LATEST }}
tools: composer
coverage: none
- name: Install composer-normalize
run: >
composer install
--prefer-dist
--no-interaction
--no-progress
--no-suggest
working-directory: tools/composer-normalize
- name: Run composer-normalize tests
run: >
composer -dtools/composer-normalize
normalize
--dry-run
--diff
--no-check-lock
--no-update-lock
--no-interaction
$PWD/composer.json
59 changes: 40 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"name": "package-url/packageurl-php",
"description": "A parser and builder based on the package url spec.",
"readme": "README.md",
"keywords": ["package-url", "package", "url", "packageurl" ,"purl"],
"license": "MIT",
"homepage": "https://github.com/package-url/packageurl-php",
"support": {
"issues": "https://github.com/package-url/packageurl-php/issues"
},
"keywords": [
"package-url",
"package",
"url",
"packageurl",
"purl"
],
"readme": "README.md",
"authors": [
{
"name": "Jan Kowalleck",
"role": "Developer"
}
],
"config": {
"preferred-install": "dist",
"sort-packages": true
"homepage": "https://github.com/package-url/packageurl-php",
"support": {
"issues": "https://github.com/package-url/packageurl-php/issues"
},
"prefer-stable": true,
"require": {
"php": "^7.3 || ^8.0"
},
Expand All @@ -27,6 +28,7 @@
"phpunit/phpunit": "9.5.11",
"roave/security-advisories": "dev-latest"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"PackageUrl\\": "src"
Expand All @@ -37,37 +39,56 @@
"PackageUrl\\Tests\\": "tests"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"composer-normalize": {
"indent-size": 4,
"indent-style": "space"
}
},
"scripts": {
"cs-fix": "@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --diff",
"dev-setup": [
"@composer update -dtools/composer-normalize",
"@composer update -dtools/composer-require-checker",
"@composer update -dtools/composer-unused",
"@composer update -dtools/php-cs-fixer",
"@composer update -dtools/psalm",
"@composer update"
],
"test:composer-require-checker": "@php tools/composer-require-checker/vendor/maglnet/composer-require-checker/bin/composer-require-checker",
"test:composer-unused": "@php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused",
"test:cs-fixer": "@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff",
"test:psalm": "@php tools/psalm/vendor/vimeo/psalm/psalm" ,
"test:phpunit": "phpunit",
"normalize": "@composer -dtools/composer-normalize normalize --diff $PWD/composer.json",
"test": [
"@composer validate",
"@test:psalm",
"@test:phpunit",
"@test:cs-fixer",
"@test:composer-require-checker",
"@test:composer-unused"
"@test:composer-unused",
"@test:composer-normalize"
],
"cs-fix": "@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --diff"
"test:composer-normalize": "@composer -dtools/composer-normalize normalize --dry-run --diff $PWD/composer.json",
"test:composer-require-checker": "@php tools/composer-require-checker/vendor/maglnet/composer-require-checker/bin/composer-require-checker",
"test:composer-unused": "@php tools/composer-unused/vendor/icanhazstring/composer-unused/bin/composer-unused",
"test:cs-fixer": "@php tools/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff",
"test:phpunit": "phpunit",
"test:psalm": "@php tools/psalm/vendor/vimeo/psalm/psalm"
},
"scripts-descriptions": {
"cs-fix": "Fix files according to coding standards.",
"dev-setup": "Install dev-requirements and tools",
"normalize": "Normalize composer.json",
"test": "Run all tests!",
"test:composer-normalize": "Test if composer.json was normalized.",
"test:composer-require-checker": "Test compoer requirements with composer-require-checker.",
"test:composer-unused": "Test compoer requirements with composer-unused.",
"test:cs-fixer": "Test coding standards with PHP-CS-fixer.",
"test:psalm": "Run static code analysis with Psalm.",
"test:phpunit": "Run tests with PHPUnit.",
"cs-fix": "Fix files according to coding standards."
"test:psalm": "Run static code analysis with Psalm."
}
}
3 changes: 3 additions & 0 deletions tools/composer-normalize/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!/.gitignore
!/composer.json
17 changes: 17 additions & 0 deletions tools/composer-normalize/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "tools/composer-normalize",
"description": "composer-normalize",
"type": "metapackage",
"require-dev": {
"ergebnis/composer-normalize": "2.20",
"roave/security-advisories": "dev-latest"
},
"prefer-stable": true,
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"preferred-install": "dist",
"sort-packages": true
}
}
12 changes: 5 additions & 7 deletions tools/composer-require-checker/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"name": "tools/composer-require-checker",
"description": "composer-require-checker",
"type": "metapackage",
"require-dev": {
"maglnet/composer-require-checker": "3.8.0",
"roave/security-advisories": "dev-latest"
},
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"prefer-stable": true,
"require": {
"maglnet/composer-require-checker": "3.8.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
}
}
18 changes: 8 additions & 10 deletions tools/composer-unused/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"name": "tools/composer-unused",
"description": "composer-unused",
"type": "metapackage",
"require-dev": {
"icanhazstring/composer-unused": "0.7.12",
"roave/security-advisories": "dev-latest"
},
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"icanhazstring/composer-unused": true
}
},
"prefer-stable": true,
"require": {
"icanhazstring/composer-unused": "0.7.12"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
},
"preferred-install": "dist",
"sort-packages": true
}
}
12 changes: 5 additions & 7 deletions tools/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"name": "tools/php-cs-fixer",
"description": "php-cs-fixer",
"type": "metapackage",
"require-dev": {
"friendsofphp/php-cs-fixer": "3.4.0",
"roave/security-advisories": "dev-latest"
},
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"prefer-stable": true,
"require": {
"friendsofphp/php-cs-fixer": "3.4.0"
},
"require-dev": {
"roave/security-advisories": "dev-latest"
}
}
18 changes: 8 additions & 10 deletions tools/psalm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"name": "tools/psalm",
"description": "psalm and plugins",
"type": "metapackage",
"require-dev": {
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "4.17.0"
},
"prefer-stable": true,
"config": {
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": false
}
},
"prefer-stable": true,
"require": {
"roave/security-advisories": "dev-latest"
},
"require-dev": {
"vimeo/psalm": "4.17.0"
},
"preferred-install": "dist",
"sort-packages": true
}
}

0 comments on commit 98918ba

Please sign in to comment.