-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (124 loc) · 4.48 KB
/
phpunit-test.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
name: Laravel PHPunit test
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
phpunit:
name: "🧹 Laravel PHPUnit (PHP: ${{ matrix.php-versions }} - Laravel: ${{ matrix.laravel }} - ${{ matrix.operating-system}})"
runs-on: ${{ matrix.operating-system }}
# Service container Mysql
services:
mysql:
# Label used to access the service container
image: mysql:latest
env:
MYSQL_USER: laravel_user
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_ROOT_PASSWORD: ${{ secrets.DB_PASSWORD }}
MYSQL_DATABASE: db_test_laravel
## map the "external" 33306 port with the "internal" 3306
ports:
- 33306:3306
# Set health checks to wait until mysql database has started (it takes some seconds to start)
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=3
env:
FOLDER: ./laravel
strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: ['8.0', '8.1']
laravel: [ '8.*', '9.*' ]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '16.x'
- name: Cache node_modules directory
uses: actions/cache@v4
id: node_modules-cache
with:
path: "${{env.FOLDER}}/node_modules"
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
- name: Install NPM packages
working-directory: ${{env.FOLDER}}
if: steps.node_modules-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build frontend
working-directory: ${{env.FOLDER}}
run: npm run development
- name: Setup PHP, with composer and extensions
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, bcmath
coverage: pcov
- name: Get composer cache directory
id: composer-cache
working-directory: ${{env.FOLDER}}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v4
id: actions-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Cache PHP dependencies
uses: actions/cache@v4
id: vendor-cache
with:
path: "${{env.FOLDER}}/vendor"
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- name: Copy ENV Laravel Configuration for CI
working-directory: ${{env.FOLDER}}
run: |
php -r "file_exists('.env') || copy('.env.testing', '.env');"
- name: Install Laravel Dependencies
working-directory: ${{env.FOLDER}}
if: steps.vendor-cache.outputs.cache-hit != 'true'
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Show files in folder
working-directory: ${{env.FOLDER}}
run: ls -lao
- name: Generate key
working-directory: ${{env.FOLDER}}
run: php artisan key:generate
- name: Directory Permissions
working-directory: ${{env.FOLDER}}
run: chmod -R 777 storage bootstrap/cache
- name: Run Migrations
working-directory: ${{env.FOLDER}}
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_USER: laravel_user
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: php artisan migrate
- name: PHP Version
run: php --version
- name: Execute tests (Unit and Feature tests) via PHPUnit
working-directory: ${{env.FOLDER}}
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_USER: laravel_user
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: vendor/bin/phpunit --testdox