Skip to content

Commit 0c9fc22

Browse files
committed
Fix caching in workflows
Signed-off-by: Luís Cobucci <[email protected]>
1 parent eeddd9b commit 0c9fc22

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

.github/workflows/coding-standards.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ jobs:
3131
ini-values: memory_limit=-1
3232
tools: composer:v2, cs2pr
3333

34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
37+
3438
- name: "Cache dependencies"
35-
uses: "actions/[email protected].2"
39+
uses: "actions/[email protected].4"
3640
with:
37-
path: |
38-
~/.composer/cache
39-
vendor
40-
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
43+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
4244

4345
- name: "Install lowest dependencies"
4446
if: ${{ matrix.dependencies == 'lowest' }}

.github/workflows/mutation-tests.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ jobs:
3131
ini-values: memory_limit=-1
3232
tools: composer:v2, cs2pr
3333

34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
37+
3438
- name: "Cache dependencies"
35-
uses: "actions/[email protected].2"
39+
uses: "actions/[email protected].4"
3640
with:
37-
path: |
38-
~/.composer/cache
39-
vendor
40-
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
43+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
4244

4345
- name: "Install lowest dependencies"
4446
if: ${{ matrix.dependencies == 'lowest' }}

.github/workflows/phpunit.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ jobs:
3333
ini-values: memory_limit=-1
3434
tools: composer:v2, cs2pr
3535

36+
- name: Get composer cache directory
37+
id: composer-cache
38+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
39+
3640
- name: "Cache dependencies"
37-
uses: "actions/[email protected].2"
41+
uses: "actions/[email protected].4"
3842
with:
39-
path: |
40-
~/.composer/cache
41-
vendor
42-
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
43-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
43+
path: ${{ steps.composer-cache.outputs.dir }}
44+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
45+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
4446

4547
- name: "Install lowest dependencies"
4648
if: ${{ matrix.dependencies == 'lowest' }}

.github/workflows/static-analysis.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ jobs:
3131
ini-values: memory_limit=-1
3232
tools: composer:v2, cs2pr
3333

34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
37+
3438
- name: "Cache dependencies"
35-
uses: "actions/[email protected].2"
39+
uses: "actions/[email protected].4"
3640
with:
37-
path: |
38-
~/.composer/cache
39-
vendor
40-
key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41-
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}"
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}"
43+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
4244

4345
- name: "Install lowest dependencies"
4446
if: ${{ matrix.dependencies == 'lowest' }}

0 commit comments

Comments
 (0)