Skip to content

Commit

Permalink
Add Composer cache step to GitHub workflow
Browse files Browse the repository at this point in the history
This commit introduces caching for Composer dependencies in the CI workflow using `actions/cache@v4`. It optimizes build times by reusing dependencies across runs, keyed by the `composer.lock` file hash. Removed unused dependency matrix from the PHP job matrix configuration.
  • Loading branch information
Spomky committed Jan 4, 2025
1 parent 5a43790 commit 3473f64
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ jobs:
- "8.2"
- "8.3"
- "8.4"
dependencies:
- "lowest"
- "highest"
runs-on: ${{ matrix.operating-system }}
steps:
- name: "Set up PHP"
Expand All @@ -76,6 +73,14 @@ jobs:
with:
fetch-depth: 0

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
Expand Down Expand Up @@ -111,6 +116,14 @@ jobs:
with:
fetch-depth: 0

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Install dependencies"
uses: "ramsey/composer-install@v3"
with:
Expand Down Expand Up @@ -138,6 +151,14 @@ jobs:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Validate Composer configuration"
run: "composer validate"

Expand Down Expand Up @@ -171,6 +192,14 @@ jobs:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Get tags"
run: git fetch --tags origin

Expand Down Expand Up @@ -207,6 +236,14 @@ jobs:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Fetch Git base reference"
run: "git fetch --depth=1 origin ${GITHUB_BASE_REF}"

Expand All @@ -229,6 +266,14 @@ jobs:
- name: "Checkout code"
uses: "actions/checkout@v4"

- name: "Cache Composer dependencies"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Check exported files"
run: |
EXPECTED="LICENSE,README.md,RELEASES.md,SECURITY.md,composer.json,link,package.json"
Expand Down

0 comments on commit 3473f64

Please sign in to comment.