-
Notifications
You must be signed in to change notification settings - Fork 3
168 lines (149 loc) · 5.91 KB
/
Copy pathlaravel.yml
File metadata and controls
168 lines (149 loc) · 5.91 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
name: Laravel
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: idp-test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
hydra:
image: oryd/hydra:v2.3
env:
DSN: "memory"
SECRETS_SYSTEM: "testing-secret-that-is-at-least-32-chars-long"
URLS_SELF_ISSUER: "http://localhost:4444/"
URLS_CONSENT: "http://localhost/auth/consent"
URLS_LOGIN: "http://localhost/auth/login"
URLS_LOGOUT: "http://localhost/auth/logout"
URLS_ERROR: "http://localhost/auth/error"
URLS_POST_LOGOUT_REDIRECT: "http://localhost/auth/choose"
LOG_LEAK_SENSITIVE_VALUES: "true"
DEV: "true"
ports:
- 4444:4444
- 4445:4445
options: >-
--health-cmd "wget --no-verbose --tries=1 --spider http://localhost:4445/health/alive || exit 1"
--health-interval=10s
--health-timeout=5s
--health-retries=5
--health-start-period=10s
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, pdo_mysql
coverage: none
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- 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: Install NPM Dependencies
run: npm ci
- name: Build Assets
run: npm run build
- name: Create .env file
run: |
cp .env.example .env
echo "APP_ENV=testing" >> .env
echo "DB_CONNECTION=mysql" >> .env
echo "DB_HOST=127.0.0.1" >> .env
echo "DB_PORT=3306" >> .env
echo "DB_DATABASE=idp-test" >> .env
echo "DB_USERNAME=root" >> .env
echo "DB_PASSWORD=password" >> .env
echo "CACHE_DRIVER=array" >> .env
echo "QUEUE_CONNECTION=sync" >> .env
echo "SESSION_DRIVER=array" >> .env
echo "MAIL_MAILER=array" >> .env
echo "FILESYSTEM_DRIVER=local" >> .env
echo "AWS_ACCESS_KEY_ID=test" >> .env
echo "AWS_SECRET_ACCESS_KEY=test" >> .env
echo "AWS_DEFAULT_REGION=us-east-1" >> .env
echo "AWS_BUCKET_AVATARS=test-bucket" >> .env
echo "AWS_ENDPOINT=http://localhost:9000" >> .env
echo "HYDRA_ADMIN_URL=http://127.0.0.1:4445/" >> .env
echo "HYDRA_PUBLIC_URL=http://127.0.0.1:4444" >> .env
# Override .env.testing for CI (Docker services use 127.0.0.1)
sed -i 's/DB_HOST=mysql/DB_HOST=127.0.0.1/' .env.testing
sed -i 's/DB_USERNAME=idp/DB_USERNAME=root/' .env.testing
sed -i 's/DB_PASSWORD=idp/DB_PASSWORD=password/' .env.testing
sed -i 's|HYDRA_ADMIN_URL=.*|HYDRA_ADMIN_URL=http://127.0.0.1:4445/|' .env.testing
sed -i 's|HYDRA_PUBLIC_URL=.*|HYDRA_PUBLIC_URL=http://127.0.0.1:4444|' .env.testing
- name: Generate Application Key
run: php artisan key:generate
- name: Set Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Clear Config Cache
run: php artisan config:clear
- name: Execute Tests
run: |
vendor/bin/pest --log-junit reports/junit.xml
echo "### Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
php -r '
$xml = simplexml_load_file("reports/junit.xml");
$suite = $xml->testsuite;
$tests = (int)$suite["tests"];
$failures = (int)$suite["failures"];
$errors = (int)$suite["errors"];
$skipped = (int)$suite["skipped"];
$passed = $tests - $failures - $errors - $skipped;
$time = round((float)$suite["time"], 2);
$icon = ($failures + $errors > 0) ? "❌" : "✅";
echo "| Status | Passed | Failed | Errors | Skipped | Time |\n";
echo "|--------|--------|--------|--------|---------|------|\n";
echo "| $icon | $passed | $failures | $errors | $skipped | {$time}s |\n\n";
echo "#### Test Suites\n\n";
echo "| Suite | Tests | Passed | Failed | Time |\n";
echo "|-------|-------|--------|--------|------|\n";
foreach ($suite->testsuite as $child) {
$name = (string)$child["name"];
$t = (int)$child["tests"];
$f = (int)$child["failures"] + (int)$child["errors"];
$p = $t - $f - (int)$child["skipped"];
$dur = round((float)$child["time"], 2);
$si = $f > 0 ? "❌" : "✅";
echo "| $si $name | $t | $p | $f | {$dur}s |\n";
}
' >> $GITHUB_STEP_SUMMARY
laravel-pint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
coverage: none
- name: Install Composer Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: "Laravel Pint"
run: vendor/bin/pint --test