Skip to content

Optimize composer installs #92

Optimize composer installs

Optimize composer installs #92

Workflow file for this run

name: tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
docker:
image: docker:20.10.7
options: --privileged
strategy:
matrix:
php-version: [php81, php82, php83]
steps:
- uses: actions/checkout@v4
- name: Validate composer files
run: composer validate --strict
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ./vendor-${{ matrix.php-version }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies (if needed)
run: |
if [ ! -d ./vendor-${{ matrix.php-version }} ] || [ -z "$(ls -A ./vendor-${{ matrix.php-version }})" ]; then
echo "Dependencies not found or vendor directory is empty. Installing dependencies..."
docker compose run --rm -v ${{ github.workspace }}/vendor-${{ matrix.php-version }}:/app/vendor ${{ matrix.php-version }}composer composer install --prefer-dist
else
echo "Dependencies already installed for ${{ matrix.php-version }}. Skipping composer install."
fi
- name: Run tests
run: docker compose run --rm -v ${{ github.workspace }}/vendor-${{ matrix.php-version }}:/app/vendor ${{ matrix.php-version }} vendor/bin/phpunit