-
-
Notifications
You must be signed in to change notification settings - Fork 3
295 lines (248 loc) · 8.19 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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]
types: [opened, synchronize, reopened]
paths: ['.github/**.yml', '**.php', '**.js', '**.ts', '**.vue']
env:
APP_NAME: Creasi Skeleton
APP_ENV: testing
APP_URL: http://127.0.0.1:8000
APP_KEY: ${{ secrets.APP_KEY }}
# AWS_ENDPOINT: 'https://is3.cloudhost.id'
# AWS_DEFAULT_REGION: 'ap-southeast-3'
# AWS_BUCKET: creasi-staging
DB_DATABASE: creasico
DB_USERNAME: creasico
DB_PASSWORD: secret
MAIL_FROM_ADDRESS: devtest@creasi.dev
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
name: Build
env:
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 16.x
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install
- name: Build assets
run: pnpm build
- name: Store assets
uses: actions/upload-artifact@v3
with:
name: public
path: public/build
units:
runs-on: ubuntu-latest
name: Unit Test with PHP ${{ matrix.php }}
needs: build
env:
TELESCOPE_ENABLED: false
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@v3
- 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
tools: composer:v2
coverage: xdebug
- name: Download assets
id: download
uses: actions/download-artifact@v3
with:
name: public
path: public/build
- name: Get Composer cache directory
id: composer-cache
run: |
echo "GIT_BRANCH=$(echo ${GIT_BRANCH##*/} | tr / -)" >> $GITHUB_ENV
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
command: composer update --prefer-dist --no-interaction --no-progress
- name: Run unit tests
run: php artisan test --coverage
e2e:
runs-on: ubuntu-latest
name: Integration Test on BrowserStack
needs: units
env:
DUSK_HEADLESS_DISABLED: true
TELESCOPE_ENABLED: false
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@v3
- 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
- name: Download assets
id: download
uses: actions/download-artifact@v3
with:
name: public
path: public/build
- name: Get Composer cache directory
id: composer-cache
run: |
echo "GIT_BRANCH=$(echo ${GIT_BRANCH##*/} | tr / -)" >> $GITHUB_ENV
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
command: composer update --prefer-dist --no-interaction --no-progress
- name: Setup BrowserStack env # Invokes the setup-env action
uses: browserstack/github-actions/setup-env@master
with:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- name: Start BrowserStack local tunnel
uses: browserstack/github-actions/setup-local@master
with:
local-testing: start
local-logging-level: all-logs
local-identifier: random
- name: Start dev server
run: php artisan serve > /dev/null 2>&1 &
- name: Run e2e tests
run: php artisan dusk
- name: Upload e2e tests logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: e2e-logs
path: |
tests/Browser/console
tests/Browser/screenshots
- name: Stop BrowserStack local tunnel
uses: browserstack/github-actions/setup-local@master
with:
local-testing: stop
deploy:
runs-on: ubuntu-latest
name: Deploy
needs: e2e
if: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
environment:
name: staging
url: https://skeleton.creasi.dev
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: curl, intl, libxml, mbstring, pcntl, ssh2, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none
- name: Get Composer cache directory
id: composer-cache
run: |
echo "GIT_BRANCH=$(echo ${GIT_BRANCH##*/} | tr / -)" >> $GITHUB_ENV
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-
restore-keys: ${{ runner.os }}-composer-
- name: Prepare
run: |
[[ ! -d $HOME/.ssh ]] && mkdir $HOME/.ssh
echo "${{ secrets.STAGING_SERVER_RSAKEY }}" >> $HOME/.ssh/id_rsa
echo "${{ secrets.STAGING_SERVER_SSH_CONFIG }}" >> $HOME/.ssh/config
chmod 600 $HOME/.ssh/* && ls -al $HOME/.ssh/
git config user.name "Creasi.HQ" && git config user.email "dev@creasi.co"
- name: Install dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
command: composer update --prefer-dist --no-interaction --no-progress
- name: Download assets
id: download
uses: actions/download-artifact@v3
with:
name: public
path: public/build
- name: Deploy repo
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 3
command: |
composer dep deploy:unlock
composer dep deploy