-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (87 loc) · 2.9 KB
/
Copy pathci.yml
File metadata and controls
102 lines (87 loc) · 2.9 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
name: CI
on:
push:
branches: [ master, "upgrade/**" ]
pull_request:
branches: [ master ]
jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3']
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: absensi_testing
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root --password=secret"
--health-interval=10s
--health-timeout=5s
--health-retries=10
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: absensi_testing
DB_USERNAME: root
DB_PASSWORD: secret
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, pdo_mysql, bcmath, gd, zip, intl, exif
coverage: none
tools: composer:v2
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Build frontend assets (Vite)
# Test yang me-render view butuh public/build/manifest.json.
run: |
npm ci
npm run build
- name: Prepare environment
run: |
cp .env.example .env
php artisan key:generate
# phpunit.xml hanya override DB_DATABASE; host/port/user/password diambil
# dari .env — set eksplisit agar cocok dengan MySQL service di atas.
sed -i 's/^DB_HOST=.*/DB_HOST=127.0.0.1/' .env
sed -i 's/^DB_PORT=.*/DB_PORT=3306/' .env
sed -i 's/^DB_DATABASE=.*/DB_DATABASE=absensi_testing/' .env
sed -i 's/^DB_USERNAME=.*/DB_USERNAME=root/' .env
sed -i 's/^DB_PASSWORD=.*/DB_PASSWORD=secret/' .env
- name: Wait for MySQL
run: |
for i in $(seq 1 30); do
if mysqladmin ping -h 127.0.0.1 -u root --password=secret --silent; then
echo "MySQL is up"; break
fi
echo "waiting for mysql... ($i)"; sleep 2
done
- name: Run migrations
run: php artisan migrate --force --database=mysql
env:
DB_DATABASE: absensi_testing
- name: Run PHPUnit
# artisan test OOM di app ini (render menu) — pakai phpunit langsung + flag memory.
run: php -d memory_limit=2G -d xdebug.mode=off vendor/bin/phpunit --no-coverage