Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ on:
branches: [ master ]

jobs:
build:
ci:

runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.1', '8.2', '8.3' ]
php-versions: [ '8.3', '8.4' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # To avoid "Shallow clone detected" error in SonarCloud report
fetch-depth: 0

#~ PHP Setup
- name: Setup PHP ${{ matrix.php-versions }}
Expand Down Expand Up @@ -48,30 +48,18 @@ jobs:

#~ CI part
- name: Dependencies
run: make deps
run: make php/deps

- name: Check Code Style
run: make phpcs
run: make php/check

- name: Units Tests
run: make tests
run: make php/tests

- name: Fix unit tests report path
run: |
sed -i 's+'$GITHUB_WORKSPACE'+/github/workspace+g' build/reports/phpunit/clover.xml
sed -i 's+'$GITHUB_WORKSPACE'+/github/workspace+g' build/reports/phpunit/unit.xml

- name: PHP 8.1 Compatibility
run: make php81compatibility

- name: PHP 8.3 Compatibility
run: make php83compatibility

- name: PHP Static Analyze
run: make analyze

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@v2.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: make php/analyze
46 changes: 46 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # To avoid "Shallow clone detected" error in SonarCloud report

#~ PHP Setup
- name: Setup PHP 8.3 # Minimum version
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

#~ Composer Cache
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: make install

- name: Units Tests
run: make php/tests # To generate the coverage report

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5.2.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [7.0.0] - 2025-08-15
[7.0.0]: https://github.com/eureka-framework/component-web/compare/6.0.0...7.0.0
### Added
- Now support PHP 8.4
### Removed
- Drop PHP 8.1 & 8.2 support
### Changed
- Update CI
- Fix from PHPStan
- Improve types in phpdoc


---

## [6.0.0] - 2024-03-12
[6.0.0]: https://github.com/eureka-framework/component-web/compare/5.3.0...6.0.0
### Changed
Expand Down
70 changes: 33 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,84 +1,80 @@
.PHONY: validate install update deps phpcs phpcsf php81compatibility php83compatibility phpstan analyze tests testdox ci clean build/reports/phpunit build/reports/phpcs build/reports/phpstan
.PHONY: validate install update php/deps php/check php/fix php/min-compatibility php/max-compatibility php/phpstan php/analyze php/tests php/test php/testdox ci clean

COMPOSER_BIN := composer
PHP_VERSION_MIN := 8.3
PHP_VERSION_MAX := 8.4
define header =
@if [ -t 1 ]; then printf "\n\e[37m\e[100m \e[104m $(1) \e[0m\n"; else printf "\n### $(1)\n"; fi
endef

#~ Composer dependency
validate:
$(call header,Composer Validation)
@composer validate
@${COMPOSER_BIN} validate

install:
$(call header,Composer Install)
@composer install
@${COMPOSER_BIN} install

update:
$(call header,Composer Update)
@composer update
@composer bump --dev-only
@${COMPOSER_BIN} update
@${COMPOSER_BIN} bump --dev-only

composer.lock: install

#~ Vendor binaries dependencies
vendor/bin/php-cs-fixer:
vendor/bin/phpstan:
vendor/bin/phpunit:
vendor/bin/php-cs-fixer: composer.lock
vendor/bin/phpstan: composer.lock
vendor/bin/phpunit: composer.lock

#~ Report directories dependencies
build/reports/phpunit:
@mkdir -p build/reports/phpunit

build/reports/phpcs:
@mkdir -p build/reports/cs

build/reports/phpstan:
@mkdir -p build/reports/phpstan

#~ main commands
deps: composer.json
php/deps: composer.json
$(call header,Checking Dependencies)
@XDEBUG_MODE=off ./vendor/bin/composer-require-checker check
@XDEBUG_MODE=off ./vendor/bin/composer-dependency-analyser --config ./ci/composer-dependency-analyser.php # for shadow, unused required dependencies and ext-* missing dependencies

phpcs: vendor/bin/php-cs-fixer build/reports/phpcs
php/check: vendor/bin/php-cs-fixer
$(call header,Checking Code Style)
@./vendor/bin/php-cs-fixer check

phpcsf: vendor/bin/php-cs-fixer
@./vendor/bin/php-cs-fixer check -v --diff
php/fix: vendor/bin/php-cs-fixer
$(call header,Fixing Code Style)
@./vendor/bin/php-cs-fixer fix -v

php81compatibility: vendor/bin/phpstan build/reports/phpstan
$(call header,Checking PHP 8.1 compatibility)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --configuration=./ci/php81-compatibility.neon --error-format=table
php/min-compatibility: vendor/bin/phpstan build/reports/phpstan
$(call header,Checking PHP ${PHP_VERSION_MIN} compatibility)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --configuration=./ci/phpmin-compatibility.neon --error-format=table

php83compatibility: vendor/bin/phpstan build/reports/phpstan
$(call header,Checking PHP 8.3 compatibility)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --configuration=./ci/php83-compatibility.neon --error-format=table
php/max-compatibility: vendor/bin/phpstan build/reports/phpstan #ci
$(call header,Checking PHP ${PHP_VERSION_MAX} compatibility)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --configuration=./ci/phpmax-compatibility.neon --error-format=table

phpstan: vendor/bin/phpstan build/reports/phpstan
$(call header,Running Static Analyze)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --error-format=checkstyle > ./build/reports/phpstan/phpstan.xml

analyze: vendor/bin/phpstan build/reports/phpstan
php/analyze: vendor/bin/phpstan build/reports/phpstan #manual & ci
$(call header,Running Static Analyze - Pretty tty format)
@XDEBUG_MODE=off ./vendor/bin/phpstan analyse --error-format=table

tests: vendor/bin/phpunit build/reports/phpunit #ci
php/tests: vendor/bin/phpunit build/reports/phpunit #ci
$(call header,Running Unit Tests)
@rm -rf ./tests/unit/Generated/Entity ./tests/unit/Generated/Infrastructure ./tests/unit/Generated/Repository
@XDEBUG_MODE=coverage php -dzend_extension=xdebug.so ./vendor/bin/phpunit --testsuite=unit --coverage-clover=./build/reports/phpunit/clover.xml --log-junit=./build/reports/phpunit/unit.xml --coverage-php=./build/reports/phpunit/unit.cov --coverage-html=./build/reports/coverage/ --fail-on-warning
@XDEBUG_MODE=coverage php ./vendor/bin/phpunit --testsuite=unit --coverage-clover=./build/reports/phpunit/clover.xml --log-junit=./build/reports/phpunit/unit.xml --coverage-php=./build/reports/phpunit/unit.cov --coverage-html=./build/reports/coverage/ --fail-on-warning

php/test: php/tests

integration: vendor/bin/phpunit build/reports/phpunit #manual
php/integration: vendor/bin/phpunit build/reports/phpunit #manual
$(call header,Running Integration Tests)
@XDEBUG_MODE=coverage php -dzend_extension=xdebug.so ./vendor/bin/phpunit --testsuite=integration --fail-on-warning
@XDEBUG_MODE=coverage php ./vendor/bin/phpunit --testsuite=integration --fail-on-warning

testdox: vendor/bin/phpunit #manual
php/testdox: vendor/bin/phpunit #manual
$(call header,Running Unit Tests (Pretty format))
@XDEBUG_MODE=coverage php -dzend_extension=xdebug.so ./vendor/bin/phpunit --testsuite=unit --fail-on-warning --testdox
@XDEBUG_MODE=coverage php ./vendor/bin/phpunit --testsuite=unit --fail-on-warning --testdox

clean:
$(call header,Cleaning previous build)
$(call header,Cleaning previous build) #manual
@if [ "$(shell ls -A ./build)" ]; then rm -rf ./build/*; fi; echo " done"

ci: clean validate deps install phpcs tests integration php81compatibility php83compatibility analyze
ci: clean validate install php/deps php/check php/tests php/integration php/min-compatibility php/max-compatibility php/analyze
62 changes: 20 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# component-web

[![Current version](https://img.shields.io/packagist/v/eureka/component-web.svg?logo=composer)](https://packagist.org/packages/eureka/component-web)
[![Supported PHP version](https://img.shields.io/static/v1?logo=php&label=PHP&message=8.1%20-%208.3&color=777bb4)](https://packagist.org/packages/eureka/component-web)
[![Supported PHP version](https://img.shields.io/static/v1?logo=php&label=PHP&message=8.3%20-%208.4&color=777bb4)](https://packagist.org/packages/eureka/component-web)
![CI](https://github.com/eureka-framework/component-web/workflows/CI/badge.svg)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=eureka-framework_component-web&metric=alert_status)](https://sonarcloud.io/dashboard?id=eureka-framework_component-web)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=eureka-framework_component-web&metric=coverage)](https://sonarcloud.io/dashboard?id=eureka-framework_component-web)
Expand Down Expand Up @@ -42,65 +42,43 @@ make update

NB: For the components, the `composer.lock` file is not committed.

### Testing & CI (Continuous Integration)
## Testing & CI (Continuous Integration)

#### Tests
You can run unit tests (with coverage) on your side with following command:
You can run tests on your side with following commands:
```bash
make tests
make php/tests # run tests with coverage
make php/test # run tests with coverage
make php/testdox # run tests without coverage reports but with prettified output
```

You can run integration tests (without coverage) on your side with following command:
You also can run code style check or code style fixes with following commands:
```bash
make integration
make php/check # run checks on check style
make php/fix # run check style auto fix
```

For prettier output (but without coverage), you can use the following command:
```bash
make testdox # run tests without coverage reports but with prettified output
```

#### Code Style
You also can run code style check with following commands:
```bash
make phpcs
```

You also can run code style fixes with following commands:
```bash
make phpcsf
```

#### Check for missing explicit dependencies
You can check if any explicit dependency is missing with the following command:
```bash
make deps
```

#### Static Analysis
To perform a static analyze of your code (with phpstan, lvl 9 at default), you can use the following command:
```bash
make analyse
make php/analyze # Same as phpstan but with CLI output as table
```

To ensure you code still compatible with current supported version at Deezer and futures versions of php, you need to
To ensure you code still compatible with current supported version and futures versions of php, you need to
run the following commands (both are required for full support):

Minimal supported version:
```bash
make php81compatibility
make php/min-compatibility # run compatibility check on current minimal version of php we support
make php/max-compatibility # run compatibility check on last version of php we will support in future
```

Maximal supported version:
And the last "helper" commands, you can run before commit and push is:
```bash
make php83compatibility
make ci
```
This command clean the previous reports, install component if needed and run tests (with coverage report),
check the code style and check the php compatibility check, as it would be done in our CI.

#### CI Simulation
And the last "helper" commands, you can run before commit and push, is:
```bash
make ci
```
## Contributing

See the [CONTRIBUTING](CONTRIBUTING.md) file.

## License

Expand Down
11 changes: 11 additions & 0 deletions ci/composer-dependency-analyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

$config = new Configuration();

return $config
->addPathToScan(__DIR__ . '/../src', isDev: false)
->addPathToScan(__DIR__ . '/../tests', isDev: true)
;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:
- ./../vendor/phpstan/phpstan-phpunit/rules.neon

parameters:
phpVersion: 80100
phpVersion: 80400
level: 0
paths:
- ./../src
Expand Down
File renamed without changes.
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"autoload-dev": {
"psr-4": {
"Eureka\\Component\\Web\\Tests\\Unit\\": "./tests/unit"
"Eureka\\Component\\Web\\Tests\\": "./tests"
}
},

Expand All @@ -29,22 +29,20 @@
},

"require": {
"php": "8.1.*||8.2.*||8.3.*",
"php": "8.3.*||8.4.*",
"ext-mbstring": "*",

"psr/http-message": "^1.0||^2.0",
"psr/cache": "^1.0||^2.0||^3.0"
"psr/http-message": "^1.0||^2.0"
},

"require-dev": {
"friendsofphp/php-cs-fixer": "^3.51.0",
"maglnet/composer-require-checker": "^4.7.1",
"phpstan/phpstan": "^1.10.60",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpstan/phpstan-strict-rules": "^1.5.2",
"phpunit/phpcov": "^9.0.2",
"phpunit/phpunit": "^10.5.12",
"symfony/cache": "^6.4.4||^7.0"
"friendsofphp/php-cs-fixer": "^3.86.0",
"phpstan/phpstan": "^2.1.22",
"phpstan/phpstan-phpunit": "^2.0.7",
"phpstan/phpstan-strict-rules": "^2.0.6",
"phpunit/phpcov": "^11.0.1",
"phpunit/phpunit": "^12.3.4",
"shipmonk/composer-dependency-analyser": "^1.8.3"
}

}
Loading