shivammathur / cache-extensions

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

Caching not working for specific PHP extension versions #37

Open adri opened 10 months ago

adri commented 10 months ago

Describe the bug When using the cache-extensions action with setup-php, the extensions intl-72.1 and redis-6.0.2 are being installed fresh instead of being retrieved from the cache, despite being listed in the cache configuration.

Any idea what it could be?

Version

Runners

Operating systems Current runner version: '2.311.0' Operating System: Ubuntu 22.04.3 LTS

PHP versions PHP version: 8.2

To Reproduce

Custom action:

name: Setup PHP
inputs:
    php-version:
        description: "The PHP version to install"
        required: true
    extensions:
        description: "The PHP extensions to install"
        required: true
        default: "mbstring,bcmath,intl-72.1,gd,zip,redis-6.0.2,rdkafka"
    tools:
        description: "Additional tools to install"
        required: false
        default: ""
    ini-values:
        description: "Additional ini configuration to use"
        required: false
        default: "opcache.enable_cli=1, opcache.jit=disable, opcache.jit_buffer_size=64M"
outputs:
    php-version:
        description: "The full PHP version (m.m.p) that was installed"
        value: ${{ steps.setup-php.outputs.php-version }}
runs:
    using: "composite"
    steps:
        -   name: Setup cache environment
            id: extcache
            uses: shivammathur/cache-extensions@1.10.0
            with:
                php-version: ${{ inputs.php-version }}
                extensions: ${{ inputs.extensions }}
                key: php-build-v4
        -   name: Restore extension cache
            uses: actions/cache@v3.3.1
            with:
                path: ${{ steps.extcache.outputs.dir }}
                key: ${{ steps.extcache.outputs.key }}
                restore-keys: ${{ steps.extcache.outputs.key }}
        -   name: Setup PHP
            id: setup-php
            uses: shivammathur/setup-php@2.27.1
            with:
                php-version: ${{ inputs.php-version }}
                coverage: none
                extensions: ${{ inputs.extensions }}
                tools: ${{ inputs.tools }}
                ini-values: ${{ inputs.ini-values }}
            env:
                fail-fast: true
                RDKAFKA_LIBS: librdkafka-dev
        -   name: Prepare config
            shell: bash
            run: cp etc/circleci/.env.test .env.test.local
        -   uses: ramsey/composer-install@2.2.0

Usage:

  -   name: Setup PHP
      uses: ./.github/actions/setup-php
      with:
          php-version: ${{ env.PHP_VERSION }}
          tools: composer-require-checker
  1. Setup a workflow with the cache-extensions and setup-php configuration.
  2. Run the workflow once to cache the extensions.
  3. Re-run the workflow to observe if the cached extensions are used.

Expected behavior The intl-72.1 and redis-6.0.2 extensions should be cached and simply enabled on subsequent runs without reinstalling.

Screenshots/Logs

Run shivammathur/cache-extensions@1.10.0
  with:
    php-version: 8.2
    extensions: mbstring,bcmath,intl-72.1,gd,zip,redis-6.0.2,rdkafka
    key: php-build-v4
  env:
    ...
    PHP_VERSION: 8.2
    NODE_VERSION: 20
+/usr/bin/bash /home/runner/work/_actions/shivammathur/cache-extensions/1.10.0/src/scripts/cache.sh data mbstring,bcmath,intl-72.1,gd,zip,redis-6.0.2,rdkafka 8.2 php-build-v4
+/usr/bin/bash /home/runner/work/_actions/shivammathur/cache-extensions/1.10.0/src/scripts/cache.sh dependencies mbstring,bcmath,intl-72.1,gd,zip,redis-6.0.2,rdkafka 8.2
Run actions/cache@v3.3.1
  with:
    path: /usr/lib/php/20220829
    key: Linux-jammy-8.2-f3df2a272fb4179ad2625b05dbfd84fdb3a038ef0a788a5fefc9b7fd0b884b3c-20220831
    restore-keys: Linux-jammy-8.2-f3df2a272fb4179ad2625b05dbfd84fdb3a038ef0a788a5fefc9b7fd0b884b3c-20220831
    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    ...
    PHP_VERSION: 8.2
    NODE_VERSION: 20
Received 7563360 of 7563360 (100.0%), 9.7 MBs/sec
Cache Size: ~7 MB (7563360 B)
/usr/bin/tar -xf /home/runner/work/_temp/2f551bdd-30e8-4d5e-9d97-5c2716933307/cache.tzst -P -C /home/runner/work/cosmos/cosmos --use-compress-program unzstd
+Cache restored successfully
+Cache restored from key: Linux-jammy-8.2-f3df2a272fb4179ad2625b05dbfd84fdb3a038ef0a788a5fefc9b7fd0b884b3c-20220831
==> Setup PHP
✓ PHP Installed PHP 8.2.12

==> Setup Extensions
✓ mbstring Enabled
✓ bcmath Enabled
+✓ intl Installed and enabled with ICU 72.1
✓ gd Enabled
✓ zip Enabled
+✓ redis-6.0.2 Installed and enabled
✓ rdkafka Installed and enabled
adri commented 10 months ago

@shivammathur is this related to https://github.com/shivammathur/cache-extensions/issues/21?

I'm not sure if the syntax redis-6.0.2 is installing that extension from source? I'd expect it to be installed from PECL.

thena-seer-sfg commented 1 month ago

Having the same problem with redis-5.3.7