shivammathur / cache-extensions

:package: Cache PHP extensions in GitHub Actions
https://github.com/marketplace/actions/cache-php-extensions
MIT License
50 stars 5 forks source link

Different PHP version and OPCache #44

Closed deguif closed 1 month ago

deguif commented 1 month ago

Describe the bug

I got different PHP version and opcache version when using the cache-extension github action

Output when cache is not active:

PHP 8.3.11 (cli) (built: Aug 30 2024 09:28:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

Output when cache was used:

PHP 8.3.10 (cli) (built: Aug  2 2024 15:31:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

The opcache version differs from the PHP version which leads to weird errors notably when using the token_get_all() function, as some constant don't have the same values.

Version

Runners

Operating systems ubuntu-2404

PHP versions 8.3

To Reproduce

phpunit-functional:
        name: 'PHPUnit (functional)'
        runs-on: 'ubuntu-24.04'
        container:
            image: 'shivammathur/node:2404'
            credentials:
                username: ${{ secrets.DOCKERHUB_USERNAME }}
                password: ${{ secrets.DOCKERHUB_TOKEN }}
        timeout-minutes: 5
        env:
            php_extensions: 'apcu, gd, intl, bcmath, curl, openssl, mbstring, memcached'
            php_cache_key: 'cache-php83-4-apcu-gd-intl-bcmath-curl-openssl-mbstring-memcached'
        steps:
            - name: 'Checkout'
              uses: 'actions/checkout@v4'
            - name: 'Install librairies'
              run: 'sudo apt update && sudo apt install -y jpegoptim'
            - name: 'Setup PHP extensions cache environment'
              id: 'php_extensions_cache'
              uses: 'shivammathur/cache-extensions@v1'
              with:
                  php-version: '8.3'
                  extensions: ${{ env.php_extensions }}
                  key: ${{ env.php_cache_key }}
            - name: 'Cache PHP extensions'
              uses: 'actions/cache@v4'
              with:
                  path: ${{ steps.php_extensions_cache.outputs.dir }}
                  key: ${{ steps.php_extensions_cache.outputs.key }}
                  restore-keys: ${{ steps.php_extensions_cache.outputs.key }}
            - name: 'Setup PHP'
              uses: 'shivammathur/setup-php@v2'
              with:
                  php-version: '8.3'
                  coverage: 'none'
                  extensions: ${{ env.php_extensions }}
                  tools: 'composer'

Expected behavior

Screenshots/Logs

Additional context

Are you willing to submit a PR?

shivammathur commented 1 month ago

@deguif That should not happen, can you share your complete workflow.

deguif commented 1 month ago

@shivammathur thanks for your reply. I added the workflow on the PR description.

shivammathur commented 1 month ago

@deguif Fixed in https://github.com/shivammathur/cache-extensions/commit/ce43ed1e0b31ce17286b8fc4f6ceb0401bb65349

deguif commented 1 month ago

Thanks @shivammathur I just tested with the fix you released, and this works like a charm.