Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8 support #446

Merged
merged 21 commits into from
Dec 8, 2020
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
172 changes: 132 additions & 40 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,98 @@ on:
types: [ created ]

jobs:
tests:
unit-tests:
runs-on: ubuntu-latest
name: Build and test
name: "Unit-Tests: ${{ matrix.php }} - ${{ matrix.tools }}"
strategy:
fail-fast: false
matrix:
php: [ "7.3", "7.4" ]
composer-version: [ "1" ]
coverage: [ "none" ]
publish-phar: [ false ]
git-fetch-depth: [ 1 ]
php: [ "7.3", "7.4", "8.0" ]
tools: [ "composer:v1", "composer:v2" ]
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: ${{ matrix.tools }}"
coverage: none
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php }}-
composer-${{ runner.os }}-
composer-

- name: Set composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: Run tests
run: make tu

e2e-tests:
runs-on: ubuntu-latest
name: "e2e-Tests: ${{ matrix.e2e }} - ${{ matrix.php }} - ${{ matrix.tools }}"
strategy:
fail-fast: false
matrix:
e2e:
- 'e2e_004'
- 'e2e_005'
- 'e2e_011'
- 'e2e_013'
- 'e2e_014'
- 'e2e_015'
- 'e2e_016'
- 'e2e_017'
- 'e2e_018'
- 'e2e_019'
- 'e2e_020'
- 'e2e_0210'
- 'e2e_0211'
- 'e2e_022'
- 'e2e_023'
- 'e2e_024'
- 'e2e_025'
- 'e2e_026'
- 'e2e_027'
- 'e2e_028'
- 'e2e_029'
- 'e2e_030'
- 'e2e_031'
- 'e2e_032'
php: [ '7.3', '8.0' ]
tools: [ 'composer:v2' ]
include:
- php: "7.3"
composer-version: "1"
coverage: "pcov"
publish-phar: true
git-fetch-depth: 0 # box/composer needs history to determine a recent git version
- php: "7.4"
composer-version: "2"
coverage: "none"
publish-phar: false
git-fetch-depth: 1
- php: '7.3'
e2e: 'check-composer-root-version'
tools: 'composer:v2'

steps:
- uses: actions/checkout@v2
with:
fetch-depth: "${{ matrix.git-fetch-depth }}"
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
php-version: ${{ matrix.php }}
ini-values: "phar.readonly=0"
tools: "composer:v${{ matrix.composer-version }}"
coverage: "${{ matrix.coverage }}"
tools: ${{ matrix.tools }}
coverage: pcov

- name: Get composer cache directory
id: composercache
Expand All @@ -52,8 +109,11 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-cache-
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php }}-
composer-${{ runner.os }}-
composer-

- name: Set composer root version
run: |
Expand All @@ -63,36 +123,68 @@ jobs:
- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: Run check-composer-root-version
run: make check-composer-root-version
- name: Install tree
if: matrix.e2e == 'e2e_032'
run: sudo apt-get install -y tree

- name: Run tests (coverage)
if: matrix.coverage == 'pcov'
run: make tc
- name: Run e2e ${{ matrix.e2e }}
run: make ${{ matrix.e2e }}

- name: install tree
if: matrix.publish-phar == true
run: sudo apt-get install -y tree
build-phar:
runs-on: ubuntu-latest
name: Build PHAR

- name: Run tests (e2e)
if: matrix.publish-phar == true
run: make e2e
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run tests
if: matrix.publish-phar == false
run: make tu
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
ini-values: 'phar.readonly=0'
tools: 'composer:v2'
coverage: 'none'

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

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php }}-
composer-${{ runner.os }}-
composer-

- name: Set composer root version
run: |
source .composer-root-version
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV

- name: Install dependencies
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist

- name: Build PHAR
run: make build

- uses: actions/upload-artifact@v1
name: Publish the PHAR
if: matrix.publish-phar == true
name: Upload the PHAR artifact
with:
name: php-scoper.phar
path: bin/php-scoper.phar

publish-phar:
runs-on: ubuntu-latest
name: Publish the PHAR
needs: tests
needs:
- unit-tests
- e2e-tests
- build-phar
if: github.event_name == 'release'
steps:
- uses: actions/download-artifact@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/fixtures/*/.box_dump/
/fixtures/*/vendor/
/fixtures/set028-symfony/expected-output
/fixtures/set030/composer.lock
/fixtures/set030/expected-output
/fixtures/set031-extension-symbol/expected-output
.phpunit*
Expand Down
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ MAKEFLAGS += --no-builtin-rules

PHPBIN=php
PHPNOGC=php -d zend.enable_gc=0
IS_PHP8=$(shell php -r "echo version_compare(PHP_VERSION, '8.0.0', '>=') ? 'true' : 'false';")

SRC_FILES=$(shell find bin/ src/ -type f)

Expand Down Expand Up @@ -76,7 +77,7 @@ tu: bin/phpunit

.PHONY: tc
tc: ## Run PHPUnit tests with test coverage
tc: bin/phpunit vendor-bin/covers-validator/vendor clover.xml
tc: bin/phpunit clover.xml

.PHONY: tm
tm: ## Run Infection (Mutation Testing)
Expand Down Expand Up @@ -118,6 +119,7 @@ e2e_011: $(PHPSCOPER) fixtures/set011/vendor
e2e_013: # Run end-to-end tests for the fixture set 013 — The init command
e2e_013: $(PHPSCOPER)
rm -rf build/set013
mkdir -p build
cp -R fixtures/set013 build/set013
$(PHPSCOPER) init --working-dir=build/set013 --no-interaction
diff src/scoper.inc.php.tpl build/set013/scoper.inc.php
Expand Down Expand Up @@ -209,16 +211,17 @@ e2e_020: $(PHPSCOPER) fixtures/set020-infection/vendor clover.xml

# We generate the expected output file: we test that the scoping process
# does not alter it
php fixtures/set020-infection/vendor/infection/infection/bin/infection \
--coverage=dist/infection-coverage \
cd fixtures/set020-infection && php vendor/infection/infection/bin/infection \
--coverage=../../dist/infection-coverage \
--skip-initial-tests \
--only-covered \
--no-progress
> build/set020-infection/expected-output
sed 's/Time.*//' build/set020-infection/expected-output > build/set020-infection/expected-output

php build/set020-infection/vendor/infection/infection/bin/infection \
--coverage=dist/infection-coverage \

cd build/set020-infection && php vendor/infection/infection/bin/infection \
--coverage=../../dist/infection-coverage \
--skip-initial-tests \
--only-covered \
--no-progress
Expand Down Expand Up @@ -335,8 +338,9 @@ e2e_026: $(PHPSCOPER) fixtures/set026/vendor

.PHONY: e2e_027
e2e_027: ## Run end-to-end tests for the fixture set 027 — Laravel
ifeq ("$(IS_PHP8)", "true"))
e2e_027: $(PHPSCOPER) fixtures/set027-laravel/vendor
php $(PHPSCOPER) add-prefix \
$(PHPBIN) $(PHPSCOPER) add-prefix \
--working-dir=fixtures/set027-laravel \
--output-dir=../../build/set027-laravel \
--no-config \
Expand All @@ -347,6 +351,10 @@ e2e_027: $(PHPSCOPER) fixtures/set027-laravel/vendor

php build/set027-laravel/artisan -V > build/set027-laravel/output
diff fixtures/set027-laravel/expected-output build/set027-laravel/output
else
e2e_027:
echo "SKIP e2e_027: PHP version not supported"
endif

.PHONY: e2e_028
e2e_028: ## Run end-to-end tests for the fixture set 028 — Symfony
Expand Down Expand Up @@ -598,9 +606,9 @@ bin/php-scoper.phar: bin/php-scoper $(SRC_FILES) vendor scoper.inc.php box.json.
touch -c $@

COVERS_VALIDATOR=$(PHPBIN) vendor-bin/covers-validator/bin/covers-validator
clover.xml: $(SRC_FILES)
clover.xml: $(SRC_FILES) vendor-bin/covers-validator/vendor
$(COVERS_VALIDATOR)
php -d zend.enable_gc=0 $(PHPUNIT) \
$(PHPNOGC) $(PHPUNIT) \
--coverage-html=dist/coverage \
--coverage-text \
--coverage-clover=clover.xml \
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.3",
"php": "^7.3 || ^8.0",
"composer/package-versions-deprecated": "^1.8",
"jetbrains/phpstorm-stubs": "dev-master",
"nikic/php-parser": "^4.0",
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion fixtures/set017-symfony-di/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"symfony/dependency-injection": "^4.1"
"symfony/dependency-injection": "^4.4"
}
}
Loading