1
+ name : tests
2
+
3
+ on :
4
+ push :
5
+ branches : [ master, next ]
6
+ pull_request :
7
+ branches : [ master ]
8
+
9
+ jobs :
10
+ build :
11
+
12
+ runs-on : ubuntu-latest
13
+
14
+ strategy :
15
+ fail-fast : false
16
+ matrix :
17
+ php-version : [ '8.1', '8.2' ]
18
+ laravel-version : [ '^8.0', '^9.0', '^10.0' ]
19
+ database : [ 'sqlite', 'mysql', 'pgsql' ]
20
+
21
+ name : Tests on PHP ${{ matrix.php-version }} with Laravel ${{ matrix.laravel-version }} and ${{ matrix.database }}
22
+
23
+ services :
24
+ mysql :
25
+ image : mysql:8
26
+ env :
27
+ MYSQL_ALLOW_EMPTY_PASSWORD : yes
28
+ MYSQL_DATABASE : rest
29
+ ports :
30
+ - 3306:3306
31
+ options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
32
+
33
+ pgsql :
34
+ image : postgres:10.8
35
+ env :
36
+ POSTGRES_USER : postgres
37
+ POSTGRES_PASSWORD : postgres
38
+ POSTGRES_DB : rest
39
+ ports :
40
+ - 5432:5432
41
+ options : --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
42
+
43
+ steps :
44
+ - name : Checkout
45
+ uses : actions/checkout@v3
46
+
47
+ - name : Setup PHP
48
+ uses : shivammathur/setup-php@v2
49
+ with :
50
+ php-version : ${{ matrix.php-version }}
51
+ coverage : none
52
+
53
+ - name : Validate composer.json and composer.lock
54
+ run : composer validate
55
+
56
+ - name : Cache Composer packages
57
+ id : composer-cache
58
+ uses : actions/cache@v3
59
+ with :
60
+ path : vendor
61
+ key : ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-${{ hashFiles('**/composer.lock') }}
62
+ restore-keys : |
63
+ ${{ runner.os }}-php-${{ matrix.php-version }}-laravel-${{ matrix.laravel-version }}-
64
+
65
+ - name : Install dependencies
66
+ if : steps.composer-cache.outputs.cache-hit != 'true'
67
+ run : composer update --with "illuminate/contracts=${{ matrix.laravel-version }}" --prefer-dist --no-progress
68
+
69
+ - name : Run test suite with Sqlite
70
+ if : matrix.database == 'sqlite'
71
+ run : vendor/bin/phpunit --debug
72
+ env :
73
+ DB_CONNECTION : sqlite
74
+ DB_DATABASE : ' :memory:'
75
+
76
+ - name : Run test suite with MySQL
77
+ if : matrix.database == 'mysql'
78
+ run : vendor/bin/phpunit --debug
79
+ env :
80
+ DB_CONNECTION : mysql
81
+ DB_PORT : ${{ job.services.mysql.ports[3306] }}
82
+ DB_DATABASE : rest
83
+ DB_USERNAME : root
84
+
85
+ - name : Run test suite with PostgreSQL
86
+ if : matrix.database == 'pgsql'
87
+ run : vendor/bin/phpunit --debug
88
+ env :
89
+ DB_CONNECTION : pgsql
90
+ DB_PORT : ${{ job.services.pgsql.ports[5432] }}
91
+ DB_DATABASE : rest
92
+ DB_USERNAME : postgres
93
+ DB_PASSWORD : postgres
0 commit comments