From d21f166c97d2ff320354d9c4192cd71d4aab3c14 Mon Sep 17 00:00:00 2001 From: Coen Jacobs Date: Sun, 8 Sep 2024 15:23:41 +0200 Subject: [PATCH] Setup shared cache for Composer dependencies --- .github/workflows/main.yml | 53 +++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c364b8c8..430e1f7b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Lint, analyse and test +name: Lint, test and analyse on: push: @@ -9,30 +9,63 @@ on: - master jobs: + install_dependencies: + runs-on: ubuntu-latest + name: Install dependencies + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: docker compose run --rm builder composer install + - name: Cache installed dependencies + id: cache-composer-dependencies + uses: actions/cache/save@v4 + with: + path: | + ./vendor/ + ./composer.lock + key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} linting: + needs: install_dependencies runs-on: ubuntu-latest name: Linting steps: - - uses: actions/checkout@v3 - - name: Setup dependencies - run: docker compose run --rm builder composer install + - uses: actions/cache/restore@v4 + name: Restore cached dependencies + with: + path: | + ./vendor/ + ./composer.lock + key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} + - uses: actions/checkout@v4 - name: Run linting run: docker compose run --rm builder composer test:lint testing: + needs: install_dependencies runs-on: ubuntu-latest name: Testing steps: - - uses: actions/checkout@v3 - - name: Setup dependencies - run: docker compose run --rm builder composer install + - uses: actions/cache/restore@v4 + name: Restore cached dependencies + with: + path: | + ./vendor/ + ./composer.lock + key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} + - uses: actions/checkout@v4 - name: Run testing run: docker compose run --rm builder composer test:phpunit analysis: + needs: install_dependencies runs-on: ubuntu-latest name: Analysis steps: - - uses: actions/checkout@v3 - - name: Setup dependencies - run: docker compose run --rm builder composer install + - uses: actions/cache/restore@v4 + name: Restore cached dependencies + with: + path: | + ./vendor/ + ./composer.lock + key: ${{ runner.os }}-build-composer-dependencies-${{ github.sha }} + - uses: actions/checkout@v4 - name: Run analysis run: docker compose run --rm builder composer test:phpstan