Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
101 stars 28 forks source link

Cache PHP extension directory #2553

Closed mbrodala closed 8 years ago

mbrodala commented 8 years ago

Is your request:

We are currently installing the PHP extension intl via Pickle as described in #2086. This process takes a bit more than one minute and we'd like to speed this up by skipping the installation if the extension is already present.

This could be achieved with the new cache_dir_list option but that one needs literal paths, thus the currently used $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/no-debug-non-zts-20131226/ cannot be added to that list.

Any idea how to achieve this or if there are other options?

manishas commented 8 years ago

@mbrodala we have a bug at our end for this scenario. The $(phpenv version-name) is not being parsed correctly and hence there is an issue with caching this directory.

@chetantarale is going to work on fixing this.

0x-x0 commented 8 years ago

@mbrodala This has been fixed now. Can you please try and confirm that it works . Also here is a sample project for your reference.

mbrodala commented 8 years ago

@chetantarale Somehow it doesn't work as it seems. I'm using the following ATM:

build:
  cache: true
  cache_dir_list:
    - ...
    - $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/

  ci:
    # Debug before
    - find $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/
    - find $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/ -name intl.so | wc -l
    - >
      if [ $(find $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/ -name intl.so | wc -l) -eq 0 ]; then
        # Install PHP "intl" extension for \Collator class usage
        pickle install --ansi intl
        echo "extension=intl.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
      fi;
    # Debug after
    - find $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/
    - find $HOME/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/ -name intl.so | wc -l
    - ...

The 2nd debug shows the installed intl.so but it's not present on rebuild/next build. Any idea why?

(I'm using this setup since I see no way to figure out the no-debug-non-zts-20131226 part at build time, e.g. via phpenv.)

manishas commented 8 years ago

@mbrodala I looked at the sample project in @chetantarale's comment above and he is caching the following directory -

cache_dir_list:
    -  /root/.phpenv/versions/$(phpenv version-name)/lib/php/extensions/$dirToCache

Can you try it the way it's being done in the sample? Sample yml is - https://github.com/chetantarale/php-intl/blob/master/shippable.yml

mbrodala commented 8 years ago

@manishas Unfortunately not because in this case $dirToCache would be no-debug-non-zts-20131226 which I cannot determine as stated.

0x-x0 commented 8 years ago

@mbrodala Caching would not work if you are running matrix builds.Currently this is a limitation on our end. But for non matrix builds caching should work as expected. We tried reproducing the scenario but couldn't. Here we tried doing something similar what you are doing and looks like its working fine.

mbrodala commented 8 years ago

@chetantarale Are the builds for that project publicly accessible? I'd like to see two subsequent builds with this configuration.

That this won't work for matrix builds limits the change quite a bit but for the majority of our projects this would work since they are not using a matrix.

0x-x0 commented 8 years ago

@mbrodala I tried it with the sample php-intl project. Here is the link for the sample.

mbrodala commented 8 years ago

@chetantarale Hm, and did you flush the caches after the change? It's odd because by now you have basically the same setup as us.

0x-x0 commented 8 years ago

@mbrodala It looks like that particular build of yours failed. And caching will not work if a build fails. We will be working on adding this feature(caching on build failure).

Closing the issue. Please let us know if you have further questions.

mbrodala commented 8 years ago

@chetantarale You are right, that indeed did prevent the caching. I've fixed this error and triggered a few builds and now the caching indeed works as desired. :-)