-
-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (102 loc) · 3.48 KB
/
tests.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
---
name: Testing
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
env:
DEFAULT_FOLDER: "./laravel"
jobs:
pest:
name: "🧹 Laravel Pest (PHP: ${{ matrix.php-versions }} - Laravel: ${{ matrix.laravel }})"
runs-on: ${{ matrix.operating-system }}
# Service container MySQL
services:
mysql:
image: mysql:8.4
env:
MYSQL_USER: laravel_user
MYSQL_DATABASE: db_test_laravel
MYSQL_ALLOW_EMPTY_PASSWORD: yes
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 5s --health-retries 10
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ["8.2", "8.3"]
laravel: ["11.*"]
include:
- laravel: 11.*
testbench: 9.*
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏗 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: 💻 Show PHP and NPM versions
run: |
npm --version
php --version
- name: 🏗 Install NPM packages
working-directory: ${{env.DEFAULT_FOLDER}}
run: npm ci
- name: 🛠️ Build frontend
working-directory: ${{env.DEFAULT_FOLDER}}
run: npm run build
- name: 🏗 Setup PHP, with composer and extensions
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, bcmath
coverage: pcov
- name: 🛠️ Copy ENV Laravel Configuration for CI
working-directory: ${{env.DEFAULT_FOLDER}}
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: 🏗 Install Laravel Dependencies
working-directory: ${{env.DEFAULT_FOLDER}}
run: |
composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
# - name: Show files in folder
# working-directory: ${{env.DEFAULT_FOLDER}}
# run: ls -lao
- name: 🛠️ Generate key
working-directory: ${{env.DEFAULT_FOLDER}}
run: |
php artisan key:generate
php artisan config:clear
- name: 🛠️ Directory Permissions
working-directory: ${{env.DEFAULT_FOLDER}}
run: chmod -R 777 storage bootstrap/cache
- name: 🚀 Run Migrations
working-directory: ${{env.DEFAULT_FOLDER}}
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USER: laravel_user
run: php artisan migrate
- name: 🚀 Execute tests (Unit and Feature tests) via Pest
working-directory: ${{env.DEFAULT_FOLDER}}
# Set environment
env:
DB_CONNECTION: mysql
DB_DATABASE: db_test_laravel
DB_PORT: ${{ job.services.mysql.ports[3306] }}
DB_USER: laravel_user
run: vendor/bin/pest --coverage --coverage-clover coverage.xml
- name: 🚀 Upload coverage to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./laravel/coverage.xml
flags: pest