Skip to content

Commit

Permalink
Allow Symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
sstok committed Oct 28, 2023
1 parent f426113 commit e3259f3
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 254 deletions.
193 changes: 128 additions & 65 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Full CI process
name: 'CI'

on:
push:
branches:
Expand All @@ -8,92 +9,154 @@ on:
- main

jobs:
test:
name: PHP ${{ matrix.PHP_VERSION }}
runs-on: ubuntu-18.04
cs-fixer:
name: 'PHP CS Fixer'

runs-on: 'ubuntu-latest'

strategy:
fail-fast: false
matrix:
include:
- PHP_VERSION: '7.3'
SYMFONY_REQUIRE: '^4.4'
- PHP_VERSION: '7.3'
SYMFONY_REQUIRE: '^5.0'
- PHP_VERSION: '7.4'
SYMFONY_REQUIRE: '^5.2'
- PHP_VERSION: '8.0'
- PHP_VERSION: '8.0'
SYMFONY_REQUIRE: '^6.0'
php-version:
- '8.2'

steps:
# —— Setup Github actions 🐙 —————————————————————————————————————————————
# https://github.com/actions/checkout (official)
-
name: Checkout
uses: actions/checkout@v2
name: 'Check out'
uses: 'actions/checkout@v2'

# https://github.com/shivammathur/setup-php (community)
-
name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
name: 'Set up PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: ${{ matrix.PHP_VERSION }}
extensions: mbstring, ctype, iconv, bcmath, filter, json
coverage: none
env:
update: true
php-version: '${{ matrix.php-version }}'
coverage: 'none'

# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
-
name: Install Composer dependencies
env:
SYMFONY_REQUIRE: ${{ matrix.SYMFONY_REQUIRE }}
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
run: |
git config --global author.name Sebastiaan Stok
git config --global author.email [email protected]
git config --global user.name Sebastiaan Stok
git config --global user.email [email protected]
name: 'Get Composer cache directory'
id: 'composer-cache'
run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"'

-
name: 'Cache dependencies'
uses: 'actions/cache@v2'
with:
path: '${{ steps.composer-cache.outputs.cache-dir }}'
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: 'php-${{ matrix.php-version }}-composer-locked-'

rm -f composer.lock
composer config --no-plugins allow-plugins.symfony/flex true
composer global require symfony/flex
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi
-
name: 'Install dependencies'
run: 'composer update --no-progress --prefer-stable'

## —— Tests ✅ ———————————————————————————————————————————————————————————
-
name: Run Tests
run: |
make test
lint:
name: PHP-QA
runs-on: ubuntu-latest
name: 'Check the code style'
run: 'make cs-full'

phpstan:
name: 'PhpStan'

runs-on: 'ubuntu-latest'

strategy:
fail-fast: false
matrix:
php-version:
- '8.2'

steps:
-
name: Checkout
uses: actions/checkout@v2
name: 'Check out'
uses: 'actions/checkout@v2'

-
name: 'Set up PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
coverage: 'none'

-
name: 'Get Composer cache directory'
id: 'composer-cache'
run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"'

# https://github.com/shivammathur/setup-php (community)
-
name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
name: 'Cache dependencies'
uses: 'actions/cache@v2'
with:
php-version: '7.4'
extensions: mbstring, ctype, iconv, bcmath, filter, json
coverage: none
path: '${{ steps.composer-cache.outputs.cache-dir }}'
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: 'php-${{ matrix.php-version }}-composer-locked-'

-
name: 'Install dependencies'
run: 'composer update --no-progress --prefer-stable'

# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
-
name: Install Composer dependencies
name: 'Run PhpStan'
run: 'vendor/bin/phpstan analyze --no-progress'

tests:
name: 'PHPUnit'

runs-on: 'ubuntu-latest'

strategy:
matrix:
include:
-
php-version: '8.2'
composer-options: '--prefer-stable'
symfony-version: '6.3'
-
php-version: '8.2'
composer-options: '--prefer-stable'
symfony-version: '^6.4'

-
php-version: '8.2'
composer-options: '--prefer-stable'
symfony-version: '^7.0'

steps:
-
name: 'Check out'
uses: 'actions/checkout@v2'

-
name: 'Set up PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php-version }}'
coverage: 'none'

-
name: 'Get Composer cache directory'
id: 'composer-cache'
run: 'echo "::set-output name=cache-dir::$(composer config cache-files-dir)"'

-
name: 'Cache dependencies'
uses: 'actions/cache@v2'
with:
path: '${{ steps.composer-cache.outputs.cache-dir }}'
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: 'php-${{ matrix.php-version }}-composer-locked-'

-
name: 'Install dependencies'
env:
COMPOSER_OPTIONS: '${{ matrix.composer-options }}'
SYMFONY_REQUIRE: '${{ matrix.symfony-version }}'
run: |
rm -f composer.lock
composer config --no-plugins allow-plugins.symfony/flex true
composer global require symfony/flex
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer update --no-progress $COMPOSER_OPTIONS
-
name: 'Install PHPUnit'
run: 'vendor/bin/simple-phpunit install'

-
name: Run PHP-QA
name: 'Run tests'
run: |
make cs-full
vendor/bin/simple-phpunit
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
QA_DOCKER_IMAGE=jakzal/phpqa:1.59.1-php7.4-alpine
QA_DOCKER_IMAGE=jakzal/phpqa:1.92.1-php8.2-alpine
QA_DOCKER_COMMAND=docker run --init -t --rm --user "$(shell id -u):$(shell id -g)" --volume /tmp/tmp-phpqa-$(shell id -u):/tmp --volume "$(shell pwd):/project" --workdir /project ${QA_DOCKER_IMAGE}

dist: install cs-full phpstan test-full
lint: install security-check cs-full phpstan
lint: install cs-full phpstan

install:
composer install --no-progress --no-interaction --no-suggest --optimize-autoloader --prefer-dist --ansi

test:
./vendor/bin/phpunit --verbose
vendor/bin/simple-phpunit --verbose

# Linting tools
security-check: ensure
sh -c "${QA_DOCKER_COMMAND} security-checker security:check ./composer.lock"

phpstan: ensure
sh -c "${QA_DOCKER_COMMAND} phpstan analyse --configuration phpstan.neon"
vendor/bin/phpstan analyse

cs: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --diff"

cs-full: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff"
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=no --diff"

cs-full-check: ensure
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=false --diff --dry-run"
sh -c "${QA_DOCKER_COMMAND} php-cs-fixer fix -vvv --using-cache=no --diff --dry-run"

ensure:
mkdir -p ${HOME}/.composer /tmp/tmp-phpqa-$(shell id -u)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RollerworksPasswordStrength Validator
Rollerworks PasswordStrengthValidator
=====================================

This package provides various password strength validators for the [Symfony Validator
Expand All @@ -25,7 +25,7 @@ for you.

## Requirements

You need at least PHP 5.6 or PHP 7.0, mbstring is recommended but not required.
You need at least PHP PHP 8.2 and Symfony 6, mbstring is recommended but not required.

## Basic Usage

Expand Down
2 changes: 2 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ UPGRADE
* The PwnedPassword validator was removed in favor of the Symfon
[NotCompromisedPassword](https://symfony.com/doc/current/reference/constraints/NotCompromisedPassword.html) validator.

* Support for Symfony 4 and 5 was removed, PHP 8.2 and Symfony 6.0 is now the minimum required version.

## Upgrade from 1.6 to 1.7

* The blacklist validator was deprecated in favor of the [PasswordCommonList Validator](https://github.com/rollerworks/password-common-list).
Expand Down
44 changes: 23 additions & 21 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"name": "rollerworks/password-strength-validator",
"description": "Password-strength validator for Symfony",
"keywords": ["password", "validator", "symfony"],
"type": "library",
"license": "MIT",
"type": "library",
"keywords": [
"password",
"validator",
"symfony"
],
"authors": [
{
"name": "Sebastiaan Stok",
Expand All @@ -15,42 +19,40 @@
}
],
"require": {
"php": ">=7.3",
"symfony/deprecation-contracts": "^2.4 || ^3.0",
"php": ">=8.2",
"symfony/config": "^6.0 || ^7.0",
"symfony/polyfill-mbstring": "^1.5.0",
"symfony/translation": "^4.4 || ^5.0 || ^6.0",
"symfony/validator": "^4.4 || ^5.0 || ^6.0"
"symfony/translation": "^6.0 || ^7.0",
"symfony/validator": "^6.0 || ^7.0"
},
"require-dev": {
"phpspec/prophecy": "^1.10.3",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-symfony": "^1.2",
"phpunit/phpunit": "^9.5",
"psr/log": "^1.0 || ^2.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.3 || ^6.0"
"symfony/phpunit-bridge": "^6.0 || ^7.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Rollerworks\\Component\\PasswordStrength\\": "src/"
},
"exclude-from-classmap": ["test/"]
"exclude-from-classmap": [
"test/"
]
},
"autoload-dev": {
"psr-4": {
"Rollerworks\\Component\\PasswordStrength\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-main": "2.0-dev"
}
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
15 changes: 6 additions & 9 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
includes:
- /tools/.composer/vendor-bin/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
level: 5
level: 8
paths:
- ./src
- ./tests

ignoreErrors:
#- '#__construct\(\) does not call parent constructor from .+#'
#- '#Access to an undefined property Symfony\\Component\\Validator\\Constraint\:\:#'
- "#Casting to string something that's already string#"

# Tests
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
#ignoreErrors:
Loading

0 comments on commit e3259f3

Please sign in to comment.