-
-
Notifications
You must be signed in to change notification settings - Fork 71
178 lines (154 loc) · 5.38 KB
/
Copy pathphp.yml
File metadata and controls
178 lines (154 loc) · 5.38 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
postgres:
image: postgres
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: password
POSTGRES_DB: testbench
ports:
- 5432:5432
mongodb:
image: mongo:7.0
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: testbench
ports:
- 27017:27017
redis:
image: redis
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Setup PHP with MongoDB extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mongodb
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Check coding style via ECS
run: vendor/bin/ecs check
- name: Run static analysis via PHPStan
run: vendor/bin/phpstan analyse src tests
- name: Create databases
run: |
touch testbench.sqlite
mysql -e 'CREATE DATABASE testbench' -h127.0.0.1 -uroot -ppassword -P ${{ job.services.mysql.ports[3306] }}
# - name: Run test suite (MySQL)
# run: vendor/bin/phpunit --testdox --testsuite feature
# env:
# APP_KEY: base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI=
# DB_CONNECTION: mysql
# DB_DATABASE: testbench
# DB_HOST: 127.0.0.1
# DB_PORT: 3306
# DB_USERNAME: root
# DB_PASSWORD: password
# QUEUE_CONNECTION: redis
# QUEUE_FAILED_DRIVER: "null"
# REDIS_HOST: 127.0.0.1
# REDIS_PASSWORD:
# REDIS_PORT: 6379
# - name: Run test suite (PostgreSQL)
# run: vendor/bin/phpunit --testdox --testsuite feature
# env:
# APP_KEY: base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI=
# DB_CONNECTION: pgsql
# DB_DATABASE: testbench
# DB_HOST: 127.0.0.1
# DB_PORT: 5432
# DB_USERNAME: root
# DB_PASSWORD: password
# QUEUE_CONNECTION: redis
# QUEUE_FAILED_DRIVER: "null"
# REDIS_HOST: 127.0.0.1
# REDIS_PASSWORD:
# REDIS_PORT: 6379
- name: Check MongoDB connection
run: |
timeout 10 bash -c 'until nc -z 127.0.0.1 27017; do sleep 1; done' || (echo "MongoDB not reachable" && exit 1)
echo "MongoDB is up and running"
- name: Test MongoDB connectivity
run: |
php -r "try { \$manager = new MongoDB\Driver\Manager('mongodb://root:password@127.0.0.1:27017/?authSource=admin'); \$command = new MongoDB\Driver\Command(['ping' => 1]); \$manager->executeCommand('admin', \$command); echo 'MongoDB connection successful\n'; } catch (Exception \$e) { echo 'MongoDB connection failed: ' . \$e->getMessage() . '\n'; exit(1); }"
- name: Monitor Laravel log in background
run: |
mkdir -p vendor/orchestra/testbench-core/laravel/storage/logs
touch vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
tail -f vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log &
echo $! > /tmp/tail_pid
- name: Run test suite (MongoDB)
timeout-minutes: 2
run: vendor/bin/phpunit --testdox --testsuite feature --debug --stop-on-error --stop-on-failure || true
env:
APP_KEY: base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI=
DB_CONNECTION: mongodb
DB_DATABASE: testbench
DB_HOST: 127.0.0.1
DB_PORT: 27017
DB_USERNAME: root
DB_PASSWORD: password
DB_AUTHENTICATION_DATABASE: admin
QUEUE_CONNECTION: redis
QUEUE_FAILED_DRIVER: "null"
REDIS_HOST: 127.0.0.1
REDIS_PASSWORD:
REDIS_PORT: 6379
- name: Stop log monitor and print full log
if: always()
run: |
if [ -f /tmp/tail_pid ]; then
kill $(cat /tmp/tail_pid) || true
fi
echo "===== FULL LARAVEL LOG ====="
if [ -f vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log ]; then
cat vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
else
echo "No laravel.log found"
fi
- name: Upload laravel.log if tests fail
if: always()
uses: actions/upload-artifact@v4
with:
name: laravel-log
path: vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log
- name: Code Coverage
run: |
vendor/bin/phpunit --testdox --coverage-clover=coverage.clover --testsuite unit
vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
env:
APP_KEY: base64:i3g6f+dV8FfsIkcxqd7gbiPn2oXk5r00sTmdD6V5utI=
DB_CONNECTION: sqlite
DB_DATABASE: testbench.sqlite
QUEUE_CONNECTION: sync
XDEBUG_MODE: coverage