-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.65 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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:
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] }}