Skip to content

Commit cbbba62

Browse files
authored
feat: make cache key consistent (and configurable) (#38)
1 parent 841670a commit cbbba62

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

.github/workflows/integration-README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ A Github Workflow that runs the Integration Tests of a Magento Package
66

77
See the [integration.yaml](./integration.yaml)
88

9-
| Input | Description | Required | Default |
10-
| ------------------ | ------------------------------------------------------------- | -------- | ----------------------------- |
11-
| matrix | JSON string of [version matrix for Magento](./#matrix-format) | true | NULL |
12-
| fail-fast | Same as Github's [fail-fast](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast) | false | true |
13-
| package_name | The name of the package | true | NULL |
14-
| source_folder | The source folder of the package | false | $GITHUB_WORKSPACE |
15-
| magento_directory | The folder where Magento will be installed | false | ../magento2 |
16-
| magento_repository | Where to install Magento from | false | https://mirror.mage-os.org/ |
17-
| test_command | The integration test command to run | false | "../../../vendor/bin/phpunit" |
9+
| Input | Description | Required | Default |
10+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------- |
11+
| matrix | JSON string of [version matrix for Magento](./#matrix-format) | true | NULL |
12+
| fail-fast | Same as Github's [fail-fast](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast) | false | true |
13+
| package_name | The name of the package | true | NULL |
14+
| source_folder | The source folder of the package | false | $GITHUB_WORKSPACE |
15+
| magento_directory | The folder where Magento will be installed | false | ../magento2 |
16+
| magento_repository | Where to install Magento from | false | https://mirror.mage-os.org/ |
17+
| test_command | The integration test command to run | false | "../../../vendor/bin/phpunit" |
18+
| composer_cache_key | A key to version the composer cache. Can be incremented if you need to bust the cache. | false | "" |
1819

1920
## Secrets
2021
| Input | Description | Required | Default |
2122
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
22-
| composer_auth | JSON string of [composer credentials]([#./matrix-format](https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html)) | false | NULL |
23+
| composer_auth | JSON string of [composer credentials]([#./matrix-format](https://devdocs.magento.com/guides/v2.4/install-gde/prereq/connect-auth.html)) | false | NULL |
2324

2425
### Matrix Format
2526

.github/workflows/integration.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ on:
4141
default: ../../../vendor/bin/phpunit
4242
description: "The integration test command to run"
4343

44+
composer_cache_key:
45+
type: string
46+
required: false
47+
default: ''
48+
description: A key to version the composer cache. Can be incremented if you need to bust the cache.
49+
4450
secrets:
4551
composer_auth:
4652
required: false
@@ -117,7 +123,7 @@ jobs:
117123
- name: "Cache Composer Packages"
118124
uses: actions/cache@v3
119125
with:
120-
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ matrix.composer }} | ${{ matrix.php }} | ${{ matrix.magento }}'
126+
key: "composer | v4 | ${{ inputs.composer_cache_key }} | ${{ hashFiles('composer.lock') }} | ${{ matrix.os }} | ${{ matrix.composer }} | ${{ matrix.php }} | ${{ matrix.magento }}"
121127
path: ${{ steps.composer-cache.outputs.dir }}
122128

123129
- run: composer config repositories.local path ${{ inputs.source_folder }}

installation-test/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ inputs:
4141
required: true
4242
default: "https://mirror.mage-os.org/"
4343
description: "Where to install Magento from"
44+
45+
composer_cache_key:
46+
required: false
47+
default: ''
48+
description: A key to version the composer cache. Can be incremented if you need to bust the cache.
4449

4550
composer_auth:
4651
required: false
@@ -74,7 +79,7 @@ runs:
7479
- name: "Cache Composer Packages"
7580
uses: actions/cache@v3
7681
with:
77-
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}'
82+
key: "composer | v4 | ${{ inputs.composer_cache_key }} | ${{ hashFiles('composer.lock') }} | ${{ runner.os }} | ${{ inputs.composer_version }} | ${{ inputs.php_version }} | ${{ inputs.magento_version }}"
7883
path: ${{ steps.composer-cache.outputs.dir }}
7984

8085
- run: composer config repositories.local path ${{ inputs.source_folder }}

unit-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ runs:
3939
- name: "Cache Composer Packages"
4040
uses: actions/cache@v3
4141
with:
42-
key: 'composer | v3 | "$(Agent.OS)" | composer.lock | ${{ inputs.php_version }}'
42+
key: "composer | v3 | ${{ hashFiles('composer.lock') }} | ${{ runner.os }} | ${{ inputs.php_version }}"
4343
path: ${{ steps.composer-cache.outputs.dir }}
4444

4545
- run: composer install

0 commit comments

Comments
 (0)