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
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: CI

on:
push:
pull_request:

jobs:
# Modern source: run the unit suite on the supported development range.
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- run: composer install --no-interaction --no-progress
- run: vendor/bin/phpunit

# Build the PHP 7.0 downgrade artifact (Rector needs PHP 8.2+ to run) and
# assert no 7.1+ syntax survives. Upload it for the legacy smoke jobs.
downgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
- run: composer install --no-interaction --no-progress
- run: composer downgrade
- name: Assert no PHP 7.1+ syntax remains in the build
run: |
set -e
fail=0
# Nullable types, void return types, and class-const visibility are
# the 7.1 features Rector's level set can't strip; our custom rules
# must have removed them. (Grep code lines, not docblocks.)
if grep -rnE '(function[^;{]*\)\s*:\s*\??void|\)\s*:\s*\?[A-Za-z_\\]|\([^)]*\?[A-Za-z_\\][^)]*\)\s*[:{])' build/php70/src; then
echo "found nullable/void return syntax"; fail=1
fi
if grep -rnE '^\s*(public|protected|private)\s+const\b' build/php70/src; then
echo "found const visibility"; fail=1
fi
if grep -rnE '\breadonly\s+\$|\breadonly\s+[A-Za-z_\\]+\s+\$' build/php70/src; then
echo "found readonly property"; fail=1
fi
if grep -rnE '\b0o[0-7]+' build/php70/src; then
echo "found 0o octal literal"; fail=1
fi
test "$fail" = 0
- name: Lint the downgraded build
run: find build/php70/src -name '*.php' -print0 | xargs -0 -n1 php -l
- uses: actions/upload-artifact@v4
with:
name: php70-build
path: build/php70/

# Run the downgraded build on legacy PHP, where the released package will
# actually live. No Rector/PHPUnit here — just load the 7.0 tree and dump.
smoke-legacy:
needs: downgrade
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.0', '7.1', '7.2', '7.4', '8.0']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- uses: actions/download-artifact@v4
with:
name: php70-build
path: build/php70/
- run: find build/php70/src -name '*.php' -print0 | xargs -0 -n1 php -l
- run: php tools/smoke.php build/php70/src
114 changes: 114 additions & 0 deletions .github/workflows/reli-cross-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: reli-cross-version

# Cross-version integration, the pure-PHP analogue of ext-rdump's same-named
# workflow: a dump produced by this library on *any* supported PHP (7.0 .. 8.5,
# NTS) must be analysable by current reli (which itself needs PHP 8.4+).
#
# stage 1 (build) : downgrade the modern source to PHP 7.0 once on 8.4
# stage 2 (make-dumps) : load that build on each PHP image and write a dump
# stage 3 (analyze) : set reli up once and analyse every dump
# stage 4 (zts) : assert the NTS-only contract fails cleanly on ZTS
on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: reli-xver-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Downgrade to PHP 7.0 (on 8.4)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
- run: composer install --no-interaction --no-progress
- run: composer downgrade
- uses: actions/upload-artifact@v4
with:
name: php70-build
path: build/php70/
retention-days: 1

make-dumps:
name: Dump on PHP ${{ matrix.php }} (NTS)
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: php70-build
path: build/php70/
- name: Write a dump from the downgraded build (php:${{ matrix.php }}-cli)
run: |
mkdir -p out
docker run --rm \
-e OUT_DUMP=/out/php${{ matrix.php }}-nts.rdump \
-e PMD_SRC=/pmd/build/php70/src \
-v "$PWD":/pmd -v "$PWD/out":/out -w /pmd \
"php:${{ matrix.php }}-cli" \
sh ci/reli-make-dump.sh
# Born 0600 by root in the container; relax so the runner can upload.
sudo chmod 0644 out/*.rdump
- uses: actions/upload-artifact@v4
with:
name: dump-${{ matrix.php }}
path: out/*.rdump
retention-days: 1

analyze:
name: reli (PHP 8.4) analyses every dump
needs: make-dumps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: pmd
- uses: actions/checkout@v4
with:
repository: reliforp/reli-prof
path: reli
- uses: actions/download-artifact@v4
with:
path: dumps
merge-multiple: true
- name: Set up reli once, then analyse every cross-version dump
run: |
ls -l dumps
docker run --rm \
-e IN_DIR=/in \
-v "$PWD/pmd":/pmd -v "$PWD/reli":/reli -v "$PWD/dumps":/in -w /reli \
php:8.4-cli \
sh /pmd/ci/reli-analyze.sh

zts-rejection:
name: ZTS rejected cleanly (PHP ${{ matrix.php }})
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.4']
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: php70-build
path: build/php70/
- name: Assert dump() fails fast on a ZTS build (php:${{ matrix.php }}-zts)
run: |
docker run --rm \
-e PMD_SRC=/pmd/build/php70/src \
-v "$PWD":/pmd -w /pmd \
"php:${{ matrix.php }}-zts" \
sh ci/zts-rejection.sh
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/vendor/
/build/
composer.lock
*.rdump
*.rmem
.phpunit.result.cache
.phpunit.cache/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) sji <sji@sj-i.dev>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading