Skip to content

Commit

Permalink
feature #4 Move to PHP 8.2 (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.
labels: bc-break

Discussion
----------

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | yes
| BC breaks?    | yes
| Deprecations? | no
| Fixed tickets | 
| License       | MIT

Dropped support for PHP 8.1 (8.2 is minimum now), modernized the code base and hardened against cases of misuse.
Secondly, it's now easier to set an expiration for a token.

Commits
-------

b3d85d3 Clean-up old files
92ba66a Modernize readme
42824fc Drop support for PHP 7/8.1
2f9e1af Correct CS
830a1f9 Allow easier expiration handling
79f0ea9 Add upgrade instructions - replaces changelog
8015b98 Fix PHPStan errors
a8a131a Update GitHub workflows
4281795 Update README.md
  • Loading branch information
sstok authored Nov 6, 2023
2 parents 0d25397 + 4281795 commit 82b76ae
Show file tree
Hide file tree
Showing 27 changed files with 729 additions and 613 deletions.
12 changes: 5 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Always use LF
core.autocrlf=lf

/doc export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
CODE_OF_CONDUCT.md export-ignore
.github export-ignore
.php-cs-fixer.dist.php export-ignore
CODE_OF_CONDUCT.md export-ignore
Makefile export-ignore
phpunit.xml.dist export-ignore
phpcs.xml.dist export-ignore
phpstan.neon export-ignore
psalm.xml export-ignore
Makefile export-ignore
phpstan-baseline.neon export-ignore
tests/ export-ignore
189 changes: 134 additions & 55 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,71 +9,149 @@ on:
- main

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

runs-on: 'ubuntu-latest'

strategy:
fail-fast: false
matrix:
php-versions: [ '7.2', '7.3', '7.4', '8.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@v4'

# 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-versions }}
extensions: mbstring, ctype, iconv, bcmath, filter, json
coverage: none
env:
update: true
php-version: '${{ matrix.php-version }}'
coverage: 'none'

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

-
name: 'Cache dependencies'
uses: 'actions/cache@v3'
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'
run: 'composer install --no-progress'

-
name: 'Check the code style'
run: 'make cs'

phpstan:
name: 'PhpStan'

runs-on: 'ubuntu-latest'

strategy:
matrix:
php-version:
- '8.2'

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

-
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 "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
-
name: Install Composer dependencies
name: 'Cache dependencies'
uses: 'actions/cache@v3'
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'
run: 'composer install --no-progress'

-
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@v4'

-
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 "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'

-
name: 'Cache dependencies'
uses: 'actions/cache@v3'
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:
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
COMPOSER_OPTIONS: '${{ matrix.composer-options }}'
SYMFONY_REQUIRE: '${{ matrix.symfony-version }}'
run: |
make install
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
## —— Tests ✅ ———————————————————————————————————————————————————————————
-
name: Run Tests
run: |
make test
# lint:
# name: PHP-QA
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# steps:
# -
# name: Checkout
# 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
# with:
# php-version: '7.4'
# extensions: mbstring, ctype, iconv, bcmath, filter, json
# coverage: none
#
# # —— Composer 🧙‍️ —————————————————————————————————————————————————————————
# -
# name: Install Composer dependencies
# run: |
# make install
#
# -
# name: Run PHP-QA
# run: |
# make check
name: 'Run tests'
run: make phpunit
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
composer.lock
/vendor/
/composer.lock
/phpcs.xml
/var/

phpunit.xml
.phpunit.result.cache
.phpunit.cache/
.phpunit

.php-cs-fixer.cache
27 changes: 27 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

$header = <<<EOF
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
EOF;

/** @var \Symfony\Component\Finder\Finder $finder */
$finder = PhpCsFixer\Finder::create();
$finder
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules(
array_merge(
require __DIR__ . '/vendor/rollerscapes/standards/php-cs-fixer-rules.php',
['header_comment' => ['header' => $header]])
)
->setFinder($finder);

return $config;
8 changes: 0 additions & 8 deletions CHANGELOG.md

This file was deleted.

55 changes: 2 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,4 @@
ifndef BUILD_ENV
BUILD_ENV=php7.2
endif

QA_DOCKER_IMAGE=jakzal/phpqa:1.34.1-php7.4-alpine
QA_DOCKER_COMMAND=docker run --init -t --rm --user "$(shell id -u):$(shell id -g)" --env "COMPOSER_HOME=/composer" --volume /tmp/tmp-phpqa-$(shell id -u):/tmp:delegated --volume "$(shell pwd):/project:delegated" --volume "${HOME}/.composer:/composer:delegated" --workdir /project ${QA_DOCKER_IMAGE}

install: composer-install
dist: composer-validate cs phpstan psalm test
ci: check test
check: composer-validate cs-check phpstan psalm
test: phpunit-coverage

clean:
rm -rf var/

composer-validate: ensure
sh -c "${QA_DOCKER_COMMAND} composer validate"

composer-install: fetch ensure clean
sh -c "${QA_DOCKER_COMMAND} composer upgrade"

composer-install-lowest: fetch ensure clean
sh -c "${QA_DOCKER_COMMAND} composer upgrade --prefer-lowest"

composer-install-dev: fetch ensure clean
rm -f composer.lock
cp composer.json _composer.json
sh -c "${QA_DOCKER_COMMAND} composer config minimum-stability dev"
sh -c "${QA_DOCKER_COMMAND} composer upgrade --no-progress --no-interaction --no-suggest --optimize-autoloader --ansi"
mv _composer.json composer.json

cs:
sh -c "${QA_DOCKER_COMMAND} php vendor/bin/phpcbf"

cs-check:
sh -c "${QA_DOCKER_COMMAND} php vendor/bin/phpcs"

phpstan: ensure
sh -c "${QA_DOCKER_COMMAND} phpstan analyse"

psalm: ensure
sh -c "${QA_DOCKER_COMMAND} psalm --show-info=false"

phpunit-coverage: ensure
sh -c "${QA_DOCKER_COMMAND} phpdbg -qrr vendor/bin/phpunit --verbose --coverage-text --log-junit=var/phpunit.junit.xml --coverage-xml var/coverage-xml/"
include vendor/rollerscapes/standards/Makefile

phpunit:
sh -c "${QA_DOCKER_COMMAND} phpunit --verbose"

ensure:
mkdir -p ${HOME}/.composer /tmp/tmp-phpqa-$(shell id -u)

fetch:
docker pull "${QA_DOCKER_IMAGE}"
./vendor/bin/phpunit
Loading

0 comments on commit 82b76ae

Please sign in to comment.