From 17c9a1b895cd31b19a71f2a7f451c6ef77ee2f43 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 26 Oct 2025 21:17:11 +0100 Subject: [PATCH] Composite action for downgrading code --- .github/actions/downgrade-code/action.yml | 33 +++++++++++++++++++++++ .github/workflows/lint.yml | 19 +------------ .github/workflows/static-analysis.yml | 24 +---------------- .github/workflows/tests.yml | 27 +------------------ 4 files changed, 36 insertions(+), 67 deletions(-) create mode 100644 .github/actions/downgrade-code/action.yml diff --git a/.github/actions/downgrade-code/action.yml b/.github/actions/downgrade-code/action.yml new file mode 100644 index 0000000000..e09c61b232 --- /dev/null +++ b/.github/actions/downgrade-code/action.yml @@ -0,0 +1,33 @@ +name: 'Downgrade code' +description: 'Downgrade code' +inputs: + php-version: + description: 'Original PHP version' + required: true +runs: + using: "composite" + steps: + + - name: "Change to simple-downgrade PHP version" + if: inputs.php-version == '7.4' || inputs.php-version == '8.0' || inputs.php-version == '8.1' + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "8.4" + + - name: "Transform source code" + if: inputs.php-version == '7.4' || inputs.php-version == '8.0' || inputs.php-version == '8.1' + shell: bash + run: | + composer install --no-interaction --no-progress --working-dir=compiler + ./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ inputs.php-version }} + composer dump + + - name: "Re-store PHP version" + if: inputs.php-version == '7.4' || inputs.php-version == '8.0' || inputs.php-version == '8.1' + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + php-version: "${{ inputs.php-version }}" + ini-file: development + extensions: ds,mbstring diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f9c451b89d..7d7690cfa6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,25 +46,8 @@ jobs: - uses: "ramsey/composer-install@v3" - - name: "Change to simple-downgrade PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "8.4" - - - name: "Transform source code" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - run: | - composer install --no-interaction --no-progress --working-dir=compiler - ./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }} - composer dump - - - name: "Re-store PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" + - uses: ./.github/actions/downgrade-code with: - coverage: "none" php-version: "${{ matrix.php-version }}" - name: "Validate Composer" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ec4fb7ba05..35e28251b1 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -56,31 +56,9 @@ jobs: - uses: "ramsey/composer-install@v3" - - name: "Change to simple-downgrade PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "8.4" - ini-file: development - extensions: mbstring - - - name: "Transform source code" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - shell: bash - run: | - composer install --no-interaction --no-progress --working-dir=compiler - ./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }} - composer dump - - - name: "Re-store PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" + - uses: ./.github/actions/downgrade-code with: - coverage: "none" php-version: "${{ matrix.php-version }}" - ini-file: development - extensions: mbstring - name: "PHPStan" run: "make phpstan" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 976571c5cf..037dd7a68b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -191,34 +191,9 @@ jobs: shell: bash run: "composer require --dev phpunit/phpunit:^9.6 brianium/paratest:^6.5 symfony/console:^5.4 symfony/process:^5.4 --update-with-dependencies --ignore-platform-reqs --working-dir=tests" - - name: "Change to simple-downgrade PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" - with: - coverage: "none" - php-version: "8.4" - tools: pecl - extensions: ds,mbstring - ini-file: development - ini-values: memory_limit=2G - - - name: "Transform source code" - shell: bash - run: | - composer install --no-interaction --no-progress --working-dir=compiler - ./compiler/vendor/bin/simple-downgrade downgrade -c build/downgrade.php ${{ matrix.php-version }} - composer dump - - - name: "Re-store PHP version" - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' || matrix.php-version == '8.1' - uses: "shivammathur/setup-php@v2" + - uses: ./.github/actions/downgrade-code with: - coverage: "none" php-version: "${{ matrix.php-version }}" - tools: pecl - extensions: ds,mbstring - ini-file: development - ini-values: memory_limit=2G - name: "Tests" run: "make tests"