Skip to content

Commit

Permalink
Migrate to PHP 8.1 as default version (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage authored Dec 9, 2021
1 parent 018ae65 commit df4cd11
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 97 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/phpunit.xml export-ignore
/rector.73.php export-ignore
/rector.74.php export-ignore
/rector.80.php export-ignore
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
- name: Checkout Code
uses: actions/checkout@v2
with:
Expand Down
95 changes: 52 additions & 43 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
workflow_dispatch:

jobs:
build:
release_latest:
name: Release latest PHP version
runs-on: ubuntu-latest
steps:
- name: Extract Version Name
Expand All @@ -24,67 +25,75 @@ jobs:
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: php tests/check-version.php $VERSION
- name: Create PHP 8 release tag
- name: Create latest release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}80
- name: Push PHP 8 release tag
run: git tag v${VERSION}81
- name: Push latest release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}80

- name: Install Dependencies
run: composer install
- name: Transpile 7.3
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.73.php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.3"/'' composer.json'
- name: Commit PHP 7.3 version
run: |
git config user.email noreply@github.com && \
git config user.name "GitHub Actions" && \
git checkout -b tmp-php-7.3-release && \
git add . -v && \
git commit -m "Transpile to PHP 7.3" && \
git push origin tmp-php-7.3-release
- name: Create PHP 7.3 release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}73
- name: Push PHP 7.3 release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}73
- name: Delete temporary branch
run: git push origin --delete tmp-php-7.3-release

run: git push origin v${VERSION}81
release_older:
name: Release older PHP version
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0']
steps:
- name: Extract Version Name
id: extract_name
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\/release-/, '');
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
run: composer install
- name: Transpile 7.4
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.74.php src
- name: Transpile ${{ matrix.version }}
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.$(echo ${{ matrix.version }} | sed -e 's/\.//').php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.4"/'' composer.json'
- name: Commit PHP 7.4 version
run: 'sed -i -e ''s/"php": "\^8.1"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Commit PHP ${{ matrix.version }} version
run: |
git config user.email noreply@github.com && \
git config user.name "GitHub Actions" && \
git checkout -b tmp-php-7.4-release && \
git checkout -b tmp-php-${{ matrix.version }}-release && \
git add . -v && \
git commit -m "Transpile to PHP 7.4" && \
git push origin tmp-php-7.4-release
- name: Create PHP 7.4 release tag
git commit -m "Transpile to PHP ${{ matrix.version }}" && \
git push origin tmp-php-${{ matrix.version }}-release
- name: Create PHP ${{ matrix.version }} release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}74
- name: Push PHP 7.4 release tag
run: git tag v${VERSION}$(echo ${{ matrix.version }} | sed -e 's/\.//')
- name: Push PHP ${{ matrix.version }} release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}74
run: git push origin v${VERSION}$(echo ${{ matrix.version }} | sed -e 's/\.//')
- name: Delete temporary branch
run: git push origin --delete tmp-php-7.4-release
run: git push origin --delete tmp-php-${{ matrix.version }}-release

delete_tag:
name: Delete original tag
runs-on: ubuntu-latest
needs:
- release_latest
- release_older
steps:
- name: Extract Version Name
id: extract_name
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\/release-/, '');
- name: Checkout Code
uses: actions/checkout@v2
- name: Delete original tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/tests-8.x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests (8.x)
on:
repository_dispatch:
types:
- trigger-8x-tests

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: php-${{ matrix.version }}
submodules: true
- name: Install Dependencies
run: composer install
- name: Run tests
run: composer phpunit
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests (8.x)
name: Tests (8.1)
on:
push:
branches:
Expand All @@ -14,7 +14,7 @@ jobs:
PHP_CS_FIXER_IGNORE_ENV: 1
strategy:
matrix:
version: ['8.0', '8.1']
version: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0', '8.1']
version: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0', '8.1']
version: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
70 changes: 22 additions & 48 deletions .github/workflows/transpile.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,53 @@
name: Transpile to 7.x
name: Transpile to older versions
on:
push:
branches:
- master
workflow_dispatch:

jobs:
transpile_73:
name: Transpile to PHP 7.3
transpile:
name: Transpile to older versions of PHP
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: master
- name: Install Dependencies
run: composer install
- name: Transpile to 7.3
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.73.php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.3"/'' composer.json'
- name: Update README
run: sed -i '1s/^/# This branch is auto generated\n/' README.md
- name: Commit PHP 7.3 version
uses: actions-x/commit@v2
with:
files: .
branch: php-7.3
name: GitHub Actions
email: noreply@github.com
message: Transpiled to PHP 7.3
force: true
transpile_74:
name: Transpile to PHP 7.4
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: master
- name: Install Dependencies
run: composer install
- name: Transpile to 7.4
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.74.php src
- name: Transpile to ${{ matrix.version }}
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.$(echo ${{ matrix.version }} | sed -e 's/\.//').php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.4"/'' composer.json'
run: 'sed -i -e ''s/"php": "\^8.1"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Update README
run: sed -i '1s/^/# This branch is auto generated\n/' README.md
- name: Commit PHP 7.4 version
uses: actions-x/commit@v2
- name: Commit PHP ${{ matrix.version }} version
uses: actions-x/commit@v3
with:
files: .
branch: php-7.4
branch: php-${{ matrix.version }}
name: GitHub Actions
email: noreply@github.com
message: Transpiled to PHP 7.4
message: Transpiled to PHP ${{ matrix.version }}
force: true
trigger_7x_tests:
name: Trigger 7.x tests
trigger_tests:
name: Trigger tests
runs-on: ubuntu-latest
needs:
- transpile_73
- transpile_74
- transpile
strategy:
matrix:
version: [7x, 8x]
steps:
- name: Trigger 7.x tests
- name: Trigger ${{ matrix.version }} tests
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_TOKEN }}
event-type: trigger-7x-tests
event-type: trigger-${{ matrix.version }}-tests
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Tests](https://github.com/Unleash/unleash-client-php/actions/workflows/tests.yaml/badge.svg)](https://github.com/Unleash/unleash-client-php/actions/workflows/tests.yaml)
[![Tests (8.x)](https://github.com/Unleash/unleash-client-php/actions/workflows/tests-8.x.yaml/badge.svg)](https://github.com/Unleash/unleash-client-php/actions/workflows/tests-8.x.yaml)
[![Tests (7.x)](https://github.com/Unleash/unleash-client-php/actions/workflows/tests-7.x.yaml/badge.svg)](https://github.com/Unleash/unleash-client-php/actions/workflows/tests-7.x.yaml)
[![Coverage Status](https://img.shields.io/coveralls/github/Unleash/unleash-client-php?label=Code%20Coverage)](https://coveralls.io/github/Unleash/unleash-client-php?branch=master)
[![Download](https://img.shields.io/packagist/dt/unleash/client.svg)](https://packagist.org/packages/unleash/client)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"minimum-stability": "stable",
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
Expand Down
1 change: 1 addition & 0 deletions rector.73.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(DowngradeSetList::PHP_81);
$containerConfigurator->import(DowngradeSetList::PHP_80);
$containerConfigurator->import(DowngradeSetList::PHP_74);
};
1 change: 1 addition & 0 deletions rector.74.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(DowngradeSetList::PHP_81);
$containerConfigurator->import(DowngradeSetList::PHP_80);
};
8 changes: 8 additions & 0 deletions rector.80.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use Rector\Set\ValueObject\DowngradeSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(DowngradeSetList::PHP_81);
};

0 comments on commit df4cd11

Please sign in to comment.