-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (93 loc) · 3.15 KB
/
codecoverage.yml
File metadata and controls
101 lines (93 loc) · 3.15 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
name: Code Coverage
on: [ pull_request ]
jobs:
run:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: engine_test
MYSQL_USER: engine
MYSQL_PASSWORD: secret
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=5s
--health-timeout=5s
--health-retries=10
mysql_secondary:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: engine_test_port
MYSQL_USER: engine
MYSQL_PASSWORD: secret
ports:
- 3307:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=5s
--health-timeout=5s
--health-retries=10
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up php 8.5
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
ini-values: zend.assertions=1
- name: Install dependencies
run: composer self-update && composer install && composer dump-autoload
- name: Start MySQL socket container
run: |
mkdir -p /tmp/mysql_socket
chmod 777 /tmp/mysql_socket
docker run -d \
--name mysql_socket \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=engine_test_socket \
-e MYSQL_USER=engine \
-e MYSQL_PASSWORD=secret \
-v /tmp/mysql_socket:/var/run/mysqld \
mysql:8.4
for i in $(seq 1 30); do
docker exec mysql_socket mysqladmin ping -u root -psecret -h 127.0.0.1 --silent 2>/dev/null && break
sleep 2
done
for i in $(seq 1 10); do
[ -S /tmp/mysql_socket/mysqld.sock ] && break
sleep 1
done
[ -S /tmp/mysql_socket/mysqld.sock ] || { echo "ERROR: socket file not found"; docker logs mysql_socket; exit 1; }
docker exec mysql_socket mysql -u root -psecret -h 127.0.0.1 -e "
CREATE USER IF NOT EXISTS 'engine'@'localhost' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON \`engine_test_socket\`.* TO 'engine'@'localhost';
FLUSH PRIVILEGES;
"
- name: Run tests and collect coverage
run: vendor/bin/phpunit --coverage-clover coverage.xml --log-junit junit.xml
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: engine_test
DB_USERNAME: engine
DB_PASSWORD: secret
DB_PORT_SECONDARY: 3307
DB_DATABASE_SECONDARY: engine_test_port
DB_SOCKET: /tmp/mysql_socket/mysqld.sock
DB_DATABASE_SOCKET: engine_test_socket
- name: Upload coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v6
with:
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}