Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support caching extensions built from source #21

Open
1 task done
alcaeus opened this issue Feb 10, 2021 · 3 comments
Open
1 task done

Support caching extensions built from source #21

alcaeus opened this issue Feb 10, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@alcaeus
Copy link

alcaeus commented Feb 10, 2021

Describe the feature
With shivammathur/setup-php#399, it becomes possible to install an extension from source, e.g. by specifying extensions: mongodb-mongodb/mongo-php-driver@1.9.0. The same works for commit hashes and branches, but this interferes with the caching.

Version

  • I have checked releases and the feature is missing in the latest patch version of v1.

Underlying issue
This workflow caches the installed .so files for extensions and restores them before setup-php is called. setup-php then checks whether the restored version is correct and only installs the extension if there is a mismatch. This is done by running the equivalent of phpversion(<extension>), which can produce incorrect results when building from source. At a minimum, the cache needs to contain the version that was cached. This can take the form of <extension>-<version>, with version being either a version string or a full git hash. I don't think that the repository is needed to be part of this, as the commit hash should not conflict between different repos without actually pointing to the same content.

This process needs to take into account refs that may change, e.g. tags or branch refs. For this reason, whenever an extension is installed from source, the version identifier will always be a commit hash. This is to ensure that if version a.b.c was installed from pecl, this is not considered the same as installing tag a.b.c from a repository.

Describe alternatives

Additional context

Are you willing to submit a PR?
I plan to work on this next but wanted to discuss the approach before getting to work.

@alcaeus alcaeus added the enhancement New feature or request label Feb 10, 2021
@shivammathur
Copy link
Owner

@alcaeus

Currently the verification of versions is not done as when extension version in the input changed the cache got invalidated as a new output cache key was generated.

Now with building from source for the refs like branches and tags, this actions takes a key input which can be used to invalidate the cache. It accepts any string, so one can set it to the version of the extension they are building from source and increment/update that on each release.


This action currently only generates a cache key output along with the extension directory which can be passed to actions/cache action which restores the cache if cache key is matched and puts a step at the end of workflow to cache again if the key is new.

If you would like to add version verification you might have to import action/cache into this action as a dependency like ramsey/composer-install does to control how cache is saved and restored.

@alcaeus
Copy link
Author

alcaeus commented Feb 10, 2021

@shivammathur thanks for the pointers, I'll definitely take a look.

I definitely want to add version checking here as well. At MongoDB, we build against the latest dev version of the driver, which is not pushed to pecl. Since we always want to build against latest, updating commit hashes in our workflow does not make much sense, so the current method of invalidating the cache would not work (as it will always be mongodb-mongodb/mongo-php-driver@master). For now I'm fine with this not being cached at all (I remember you pointing out that the install-from-source logic in setup-php ignores the cache), but if we were to add caching I'd want this to work as expected, even when using ref specifiers that may change between runs.

@Blacksmoke16
Copy link

Any update on this? Would be a really nice win.

It could also be nice to show in the output that an extension was built from source to at least make it clear that one is not cachable at the moment. Not sure if that's possible tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants