Skip to content

Commit

Permalink
PHP 8+ only (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoanm committed Apr 1, 2023
1 parent db35271 commit dc9ff3a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 53 deletions.
80 changes: 38 additions & 42 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@ concurrency:
cancel-in-progress: true

env:
# Cache params
CACHE_VERSION: 2022061905 # To be able to create a new cache (YYYYMMDDXX)
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader
CODACY_CACHE_PATH: ~/.cache/codacy
CODACY_BIN: ~/.cache/codacy/codacy.sh


#permissions:
# actions: write # Required to be able to trigger sub CI workflows

jobs:
tests:
name: UTs & FTs - Symfony ${{ matrix.symfony-version }}
Expand All @@ -37,26 +31,27 @@ jobs:
fail-fast: true
max-parallel: 4
matrix:
php-version:
- '8.1' # Latest supported
- '8.0' # First php 8 version
- '7.4' # Latest php 7 version
- '7.3' # Lowest supported
symfony-version:
- '4.4' # Lowest LTS
- '5.4' # Latest LTS
exclude:
# Run all symfony version only on Lowest and Latest php versions, run it only one time for others
- php-version: '8.0'
symfony-version: '4.4'
- php-version: '7.4'
symfony-version: '5.4'
include:
# Bare minimum => Lowest versions allowed by composer config
- symfony-version: '4.4'
php-version: '8.0'
composer-flag: --prefer-lowest
# Up to date versions => Latest versions allowed by composer config
- symfony-version: '5.4'
php-version: '8.2'
# Late symfony migration => Lowest symfony version with latest minor php version allowed by composer config
- symfony-version: '4.4'
php-version: '8.2'
composer-flag: --prefer-lowest
# Late php migration => Latest symfony version with lowest minor php version allowed by composer config
- symfony-version: '5.4'
php-version: '8.0'
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Enable coverage
if: ${{ matrix.php-version == '8.1' }}
if: ${{ matrix.php-version == '8.2' }}
run: |
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV
Expand All @@ -79,9 +74,8 @@ jobs:
~/.composer
./vendor
${{ env.CODACY_CACHE_PATH }}
build/behat-code-coverage-cache
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -93,13 +87,17 @@ jobs:
- name: Build
run: |
composer require -W \
symfony/http-foundation:^${{ matrix.symfony-version }} \
symfony/http-kernel:^${{ matrix.symfony-version }} \
symfony/config:^${{ matrix.symfony-version }} \
symfony/dependency-injection:^${{ matrix.symfony-version }} \
symfony/event-dispatcher:^${{ matrix.symfony-version }} \
symfony/routing:^${{ matrix.symfony-version }} \
SF_VERSION=${{ matrix.symfony-version }}
# Issue with ParamterBag below 4.4.30 => https://github.com/symfony/symfony/commit/3eca446b21607ea1c7a865ece2dd8254c33679cc
test '${{ matrix.symfony-version }}' = '4.4' && test '${{ matrix.php-version }}' = '8.2' && SF_VERSION=4.4.30
composer require -W ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
symfony/http-foundation:^$SF_VERSION \
symfony/http-kernel:^$SF_VERSION \
symfony/config:^$SF_VERSION \
symfony/dependency-injection:^$SF_VERSION \
symfony/event-dispatcher:^$SF_VERSION \
symfony/routing:^$SF_VERSION \
&& composer update ${{ env.COMPOSER_OPTIONS }} ${{ matrix.composer-flag }} \
&& make build
- name: Tests
Expand All @@ -108,7 +106,7 @@ jobs:
# Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false
# And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context
- name: Upload coverages to Codacy
if: ${{ github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server' && env.COVERAGE_TYPE == 'xdebug' }}
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server') && env.COVERAGE_TYPE == 'xdebug' }}
run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial

# See the reports at https://codecov.io/gh/yoanm/symfony-jsonrpc-http-server
Expand Down Expand Up @@ -141,10 +139,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup PHP 8.1
- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: 8.1 # Latest supported
php-version: 8.2 # Latest supported
tools: composer
coverage: none
env:
Expand All @@ -158,7 +156,7 @@ jobs:
path: |
~/.composer
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}
key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}

- name: Build
run: make build
Expand All @@ -173,7 +171,7 @@ jobs:
finalize-codacy-coverage-report:
runs-on: ubuntu-latest
name: Finalize Codacy coverage report
if: ${{ github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server' }}
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/symfony-jsonrpc-http-server' }}
needs: [ tests ]
steps:
- name: Setup cache
Expand All @@ -182,7 +180,7 @@ jobs:
with:
path: |
${{ env.CODACY_CACHE_PATH }}
key: ${{ env.CACHE_VERSION }}-codacy-final
key: codacy-final

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -205,18 +203,15 @@ jobs:
strategy:
fail-fast: false
max-parallel: 4
# Perform tests against:
# - current php dev version with all supported symfony version
# - next Symfony minor version to manage with latest supported php version
matrix:
php-version:
- '8.2' # Current php dev version
- '8.3' # Current php dev version
symfony-version:
- '4.4' # Lowest LTS
- '5.4' # Latest LTS
include:
- symfony-version: '6.0' # Next symfony minor version to manage with latest supported PHP version
php-version: '8.1'
php-version: '8.2'

steps:
- name: Check out code
Expand All @@ -240,7 +235,7 @@ jobs:
~/.composer
./vendor
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}
key: tests-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ hashFiles('composer.json') }}

- name: Build
run: |
Expand All @@ -251,6 +246,7 @@ jobs:
symfony/dependency-injection:^${{ matrix.symfony-version }} \
symfony/event-dispatcher:^${{ matrix.symfony-version }} \
symfony/routing:^${{ matrix.symfony-version }} \
&& composer update ${{ env.COMPOSER_OPTIONS }} \
&& make build
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ build:
COVERAGE_OUTPUT_STYLE: 'clover'
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
php:
version: "8.1"
version: "8.2"
ini:
memory_limit: "-1"
timezone: UTC
Expand Down
1 change: 0 additions & 1 deletion behat.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
default:
extensions:
DVDoug\Behat\CodeCoverage\Extension:
cache: build/behat-code-coverage-cache
filter:
include:
directories:
Expand Down
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"yoanm/symfony-jsonrpc-http-server-doc": "JSON-RPC documentation Bundle"
},
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"psr/container": "^1.0",
"symfony/config": "^4.4 || ^5.4",
"symfony/dependency-injection": "^4.4 || ^5.4",
Expand All @@ -41,16 +41,17 @@
"yoanm/jsonrpc-server-sdk": "^3.0"
},
"require-dev": {
"behat/behat": "~3.0",
"squizlabs/php_codesniffer": "3.*",
"phpunit/phpunit": "^8.0 || ^9.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0",
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
"behat/behat": "^3.9.0",
"dvdoug/behat-code-coverage": "^5.0",
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/php-code-coverage": "^9.2.4",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/framework-bundle": "^4.4 || ^5.4",
"symfony/routing": "^4.4 || ^5.4",
"yoanm/php-unit-extended": "~1.0",
"phpspec/prophecy-phpunit": "^2.0",
"dvdoug/behat-code-coverage": "^5.0"
"yoanm/php-unit-extended": "^2.0"
},
"config": {
"sort-packages": true
Expand Down

0 comments on commit dc9ff3a

Please sign in to comment.