Skip to content

Commit bae9827

Browse files
author
Greg Bowler
authored
Merge pull request #5 from hkdobrev/cache-dir
Recommend caching COMPOSER_CACHE_DIR over vendor/
2 parents aa32ca5 + 193e240 commit bae9827

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
Caching dependencies for faster builds
5252
--------------------------------------
5353
54-
Github actions supports dependency caching, allowing the `vendor/` directory contents to be cached between workflows, as long as the `composer.lock` file has not changed. This produces much faster builds, as the `composer install` command does not have to be run at all if the cache is valid.
54+
Github actions supports dependency caching, allowing Composer downloads to be cached between workflows, as long as the `composer.lock` file has not changed. This produces much faster builds, as the `composer install` command does not have to download files over the network at all if the cache is valid.
5555

5656
Example workflow (taken from https://github.com/PhpGt/Dom):
5757

@@ -66,6 +66,19 @@ jobs:
6666
6767
steps:
6868
- uses: actions/checkout@v1
69+
70+
- name: Get Composer Cache Directory
71+
id: composer-cache
72+
run: |
73+
echo "::set-output name=dir::$(composer config cache-files-dir)"
74+
75+
- name: Cache Composer Downloads
76+
uses: actions/cache@v1
77+
with:
78+
path: ${{ steps.composer-cache.outputs.dir }}
79+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
80+
restore-keys: |
81+
${{ runner.os }}-composer-
6982
7083
- name: Cache PHP dependencies
7184
uses: actions/cache@v1
@@ -78,7 +91,7 @@ jobs:
7891
...
7992
```
8093

81-
In the example above, the "key" is passed to the Cache action that consists of a hash of the composer.lock file. This means that as long as the contents of composer.lock doesn't change between workflows, the vendor directory will be persisted between workflows.
94+
In the example above, the "key" is passed to the Cache action that consists of a hash of the composer.lock file. This means that as long as the contents of composer.lock doesn't change between workflows, the Composer cache directory will be persisted between workflows.
8295

8396
[php-actions-phpunit]: https://github.com/marketplace/actions/phpunit-php-actions
8497
[php-actions-phpspec]: https://github.com/marketplace/actions/phpspec-php-actions

0 commit comments

Comments
 (0)