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

Update cache key for composer dependencies #9637

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/e2e/env-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
uses: actions/cache@v4
with:
path: ./vendor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line hasn't been changed in this PR, but should we take the advantage to update the path value from this workflow to ~/.cache/composer/ to match the others? This is the only one using vendor, and I've read that caching the global composer cache is considered a good practice, and seems to be more efficient in terms of space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alopezari On E2E tests env setup action we cache the vendor directory because we're caching the installed dependencies where as rest of the workflows cache the package files downloaded by composer but they need run composer install.

The cache handling for E2E setup prevents running composer install and restores the whole vendor directory, but rest of the workflows are not configured this way. We can look at unifying this as another task. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good!

key: ${{ runner.os }}-vendor-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}

# Cache node dependencies
- name: Cache node dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:
uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}

- name: "Set up PHP"
uses: ./.github/actions/setup-php
2 changes: 1 addition & 1 deletion .github/workflows/check-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- name: "Set up PHP"
uses: ./.github/actions/setup-php
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
Expand All @@ -54,7 +54,7 @@ jobs:
coverage: none
# run CI checks
- run: bash bin/run-ci-tests.bash

generate-wc-compat-beta-matrix:
name: "Generate the matrix for compatibility-woocommerce-beta dynamically"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/i18n-weekly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
- uses: actions/cache@v4
with:
path: ~/.npm/
Expand All @@ -33,7 +33,7 @@ jobs:
run: |
npm ci
npm run build

if [[ ! -f woocommerce-payments.zip ]]; then
echo "Failed to create release zip"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/js-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
- uses: actions/cache@v4
with:
path: ~/.npm/
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/php-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- name: "Set up PHP"
uses: ./.github/actions/setup-php
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand Down
5 changes: 5 additions & 0 deletions changelog/gh-actions-e2e-optimize-composer-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Updates gh actions cache-key for composer dependencies.


Loading