-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (77 loc) · 2.91 KB
/
symfony.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Symfony
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
symfony-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test_db_test
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
ports:
- 3306:3306
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, pdo, pdo_mysql, ctype, iconv, gd
ini-values: post_max_size=256M, upload_max_filesize=256M, max_execution_time=300
coverage: none
- name: Checkout Repository
uses: actions/checkout@v4
- name: Copy .env if not exists
run: php -r "file_exists('.env') || copy('.env.SAMPLE', '.env');"
- name: Copy .env.test.local if not exists
run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --ansi
- name: Wait for MySQL to be ready
run: until mysqladmin ping -h127.0.0.1 -uroot -proot --silent; do sleep 1; done
- name: Create Test Database
run: php bin/console doctrine:database:create --if-not-exists --env=test
env:
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db'
- name: Run Database Migrations
run: php bin/console doctrine:migrations:migrate --no-interaction --env=test
env:
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db'
- name: Create directories if they do not exist
run: |
mkdir -p var public/uploads public/uploads/categories public/uploads/products public/uploads/settings
- name: Set Permissions
run: |
chmod -R 775 var public/uploads
- name: Run PHPUnit Tests
run: vendor/bin/phpunit --testdox --colors=always --log-junit junit.xml --coverage-text --coverage-clover=coverage.xml
env:
DATABASE_URL: 'mysql://test_user:test_password@127.0.0.1:3306/test_db'
- name: Upload JUnit Test Report
uses: actions/upload-artifact@v4
with:
name: junit-test-report
path: junit.xml