Skip to content

add a workflow for tests #1

add a workflow for tests

add a workflow for tests #1

Workflow file for this run

name: Setup environment and execute tests for a Laravel project
on:
workflow_call:
inputs:
PHP_VERSIONS:
description: A comma separated list of PHP versions to be used when executing the tests.
required: true
type: string
LARAVEL_VERSIONS:
description: A comma separated list of Laravel versions to be used when executing the tests.
required: true
type: string
MYSQL_DATABASE:
description: The name of the MySQL database.
required: true
type: string
TEST_COMMANDS:
description: The commands which execute the tests.
required: false
type: string
default: |
php artisan migrate:fresh --env=ci
php artisan test --env=ci --no-coverage
jobs:
execute-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: ${{ inputs.MYSQL_DATABASE }}
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:

Check failure on line 40 in .github/workflows/tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/tests.yml

Invalid workflow file

You have an error in your yaml syntax on line 40
php: [ ${{ inputs.PHP_VERSIONS }} ]
laravel: [ ${{ inputs.LARAVEL_VERSIONS }} ]
dependency-version: [ prefer-stable ]
name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} (${{ matrix.dependency-version }})
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
- name: Get composer cache directory
id: get-cache-dir
run: echo "directory=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.get-cache-dir.outputs.directory }}
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
restore-keys: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update --dev --no-progress
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: ${{ inputs.TEST_COMMANDS }}
env:
DB_PORT: ${{ job.services.mysql.ports[3306] }}