Optimise CI workflows by adding caching for Composer and Playwright #20
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Livewire Starter Kit Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
env: | |
APP_BASE_PATH: ${{ github.workspace }}/vendor/laravel/livewire-starter-kit | |
strategy: | |
fail-fast: true | |
matrix: | |
php: [8.3, 8.4] | |
name: PHP ${{ matrix.php }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: 'package-lock.json' | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite | |
coverage: none | |
tools: composer:v2 | |
- name: Cache Composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.composer/cache | |
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }} | |
restore-keys: composer-${{ runner.os }}-${{ matrix.php }} | |
- name: Install Composer dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader | |
- name: Install Node dependencies | |
run: npm ci | |
- name: Cache Playwright browsers | |
uses: actions/cache@v4 | |
id: playwright-cache | |
with: | |
path: ~/.cache/ms-playwright | |
key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} | |
- name: Install Playwright browsers | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
- name: Build `livewire-starter-kit` | |
run: composer run livewire:build | |
- name: Execute tests | |
run: php vendor/bin/pest |