Skip to content

Optimise CI workflows by adding caching for Composer and Playwright #12

Optimise CI workflows by adding caching for Composer and Playwright

Optimise CI workflows by adding caching for Composer and Playwright #12

name: React 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/react-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 `react-starter-kit`
run: composer run react:build
- name: Execute tests
run: php vendor/bin/pest