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

Examples are misleading - Need update #131

Closed
drupol opened this issue Dec 26, 2019 · 7 comments
Closed

Examples are misleading - Need update #131

drupol opened this issue Dec 26, 2019 · 7 comments
Labels
invalid The issue is not valid

Comments

@drupol
Copy link

drupol commented Dec 26, 2019

Hello,

I'm using your Github actions in my repositories.
I followed the examples files to enable the dependencies cache to speed up my builds and it failed.

Let's take this example: https://github.com/shivammathur/setup-php/blob/master/examples/slim-framework.yml

We can see that it's trying to get the hash of the file composer.lock which is only there AFTER doing composer install.

I would update the examples accordingly and add the composer install step before the Cache composer dependencies step. For all the examples.

In case of an already existing composer.lock in the repository, it doesn't change a thing.

@drupol drupol changed the title Examples are wrong Examples are misleading - Need update Dec 26, 2019
@shivammathur
Copy link
Owner

It is assuming that you have a composer.lock in your repository, most projects commit composer.lock. In case you do not do the same, use composer.json as key to cache dependencies.

key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}

@shivammathur
Copy link
Owner

@drupol To give more clarity on this, the cache steps have to be before the composer install as the same step restores the cache and adds a steps at the end of the workflow to save the cache for future runs. Therefore you cannot use a file that is generated in the composer install step. So the examples are correct. I will try to make this more clear in the documentation in next release.

Let me know if you have any questions.

@shivammathur shivammathur added the invalid The issue is not valid label Dec 27, 2019
@drupol
Copy link
Author

drupol commented Dec 27, 2019

Hi,

Most of the libraries are not shipping composer.lock, examples:

Slim: https://github.com/slimphp/Slim
Lumen: https://github.com/laravel/lumen
Symfony: https://github.com/symfony/symfony (+ all the other components)
...

So, the examples files are wrong because they would not work as they are for those projects.

I will do the changes you advised me and use composer.json file instead of composer.lock.

@shivammathur
Copy link
Owner

shivammathur commented Dec 27, 2019

Yes, currently all the examples are written for skeleton apps of frameworks, not libraries or frameworks themselves.

When you are using a framework like symfony for creating a web store it makes sense to commit your composer.lock so that when you deploy on the server it use same dependencies and works. If you are creating a library/framework itself and decide not to commit you composer.lock as you would support a range of versions of your dependencies you can choose composer.json.

Will make this more clear in the examples and documentation in the next release.

@drupol
Copy link
Author

drupol commented Dec 27, 2019

Thanks mate!

@shivammathur
Copy link
Owner

Updated examples and documentation in #133

@drupol
Copy link
Author

drupol commented Dec 31, 2019

It's perfect 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid The issue is not valid
Projects
None yet
Development

No branches or pull requests

2 participants