From 3473f6490b82c9cb11af1ac4ceb03b799ad9951c Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sat, 4 Jan 2025 10:47:49 +0100 Subject: [PATCH] Add Composer cache step to GitHub workflow 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. --- .github/workflows/integrate.yml | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index cba23e4a..d4a2c8d2 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -58,9 +58,6 @@ jobs: - "8.2" - "8.3" - "8.4" - dependencies: - - "lowest" - - "highest" runs-on: ${{ matrix.operating-system }} steps: - name: "Set up PHP" @@ -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: @@ -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: @@ -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" @@ -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 @@ -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}" @@ -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"