-
-
Notifications
You must be signed in to change notification settings - Fork 4
214 lines (187 loc) · 6.67 KB
/
main.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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Code Quality
on:
# schedule: # scheduled to run at 23.00 on Saturday (UTC), means 6.00 on Monday (WIB)
# - cron: '0 23 * * 6'
push:
branches: [main]
# paths: ['.github/**.yml', '**.php', '**.js', '**.ts', '**.vue']
pull_request:
branches: [main]
# paths: ['.github/**.yml', '**.php', '**.js', '**.ts', '**.vue']
jobs:
prepare:
name: Prepare
uses: projek-xyz/actions/.github/workflows/configure.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
build:
name: Build
needs: prepare
uses: projek-xyz/actions/.github/workflows/build.yml@main
secrets:
ACCESS_TOKEN: ${{ secrets.PAT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
with:
branch: ${{ needs.prepare.outputs.target-branch }}
composer-cache: ${{ needs.prepare.outputs.composer-cache }}
composer-cache-key: ${{ needs.prepare.outputs.composer-cache-key }}
sentry-project: ${{ vars.SENTRY_PROJECT }}
units:
name: Unit Test on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: [prepare, build]
env:
APP_ENV: ${{ vars.APP_ENV }}
APP_URL: ${{ vars.APP_URL }}
DB_DATABASE: ${{ github.repository_owner }}
DB_USERNAME: ${{ github.repository_owner }}
DB_PASSWORD: secret
services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: ${{ env.DB_DATABASE }}
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd=pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=3
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, dom, gd, imagick, intl, libxml, mbstring, pcntl, pdo, pdo_pgsql, zip
ini-values: error_reporting=E_ALL
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Prepare Composer Cache
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: ${{ needs.prepare.outputs.composer-cache-key }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ needs.prepare.outputs.composer-cache-key }}-composer-
- name: Install dependencies
run: |
cp .github/.env.example .env
composer update --prefer-dist --no-interaction --no-progress --ansi
php artisan key:generate
- name: Download assets
id: download
uses: actions/download-artifact@v4
with:
name: build-${{ needs.build.outputs.target-env }}
path: public
- name: Run unit tests
run: php artisan test --ansi --coverage
- name: Generate reports for CodeClimate
id: reports
if: needs.prepare.outputs.has-codeclimate == '1'
env:
CODECLIMATE_REPORT: tests/reports/codeclimate.${{ matrix.php }}.json
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
CC_TEST_REPORTER_URL: ${{ vars.CC_TEST_REPORTER_URL }}
run: |
curl -LSs $CC_TEST_REPORTER_URL > ./cc-test-reporter && chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t clover -o $CODECLIMATE_REPORT tests/reports/clover.xml
- name: Upload tests reports
if: needs.prepare.outputs.has-codeclimate == '1'
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.php }}
path: tests/reports/codeclimate.${{ matrix.php }}.json
e2e:
name: Integration Test on BrowserStack
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
needs: [prepare, build]
env:
APP_ENV: ${{ vars.APP_ENV }}
APP_URL: ${{ vars.APP_URL }}
DB_DATABASE: ${{ github.repository_owner }}
DB_USERNAME: ${{ github.repository_owner }}
DB_PASSWORD: secret
DEBUGBAR_ENABLED: false
DUSK_HEADLESS_DISABLED: true
services:
postgresql:
image: postgres:14
env:
POSTGRES_DB: ${{ env.DB_DATABASE }}
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd=pg_isready
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: curl, dom, gd, igbinary, imagick, intl, libxml, mbstring, pcntl, pdo, pdo_pgsql, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Prepare Composer Cache
uses: actions/cache@v4
with:
path: ${{ needs.prepare.outputs.composer-cache }}
key: ${{ needs.prepare.outputs.composer-cache-key }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ needs.prepare.outputs.composer-cache-key }}-composer-
- name: Install dependencies
run: |
cp .github/.env.example .env
composer update --prefer-dist --no-interaction --no-progress --ansi
php artisan key:generate
- name: Download assets
id: download
uses: actions/download-artifact@v4
with:
name: build-${{ needs.build.outputs.target-env }}
path: public
- name: Start dev server
run: php artisan serve > /dev/null 2>&1 &
- name: Run e2e tests
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
run: |
php artisan dusk:browserstack-local
php artisan dusk --ansi
- name: Upload e2e tests logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-logs
path: |
tests/Browser/console
tests/Browser/screenshots
reports:
name: Report Test Coverages
if: needs.prepare.outputs.should-reports == '1'
uses: projek-xyz/actions/.github/workflows/report.yml@main
needs: [prepare, units]
with:
has-codeclimate: ${{ needs.prepare.outputs.has-codeclimate == '1' }}
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}