-
Notifications
You must be signed in to change notification settings - Fork 12
236 lines (233 loc) · 8.05 KB
/
ci.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
name: ci
on: push
env:
php_version: "8.2"
node_version: "20.x"
jobs:
frontend-lint:
name: Front-end Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
extensions: bcmath, dom, fileinfo, gd, imagick, mbstring, pgsql, zip
tools: composer, pecl
- name: Get composer cache directory
id: composer-cache
run: |
printf '::set-output name=dir::%s' "$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
- name: Cache frontend dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci --prefer-offline
- name: Run Typescript lint
run: node_modules/.bin/vue-tsc
backend-lint:
name: Back-end Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
extensions: bcmath, dom, fileinfo, gd, imagick, mbstring, pgsql, zip
tools: composer, pecl
- name: Get composer cache directory
id: composer-cache
run: |
printf '::set-output name=dir::%s' "$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: PHP Lint
run: ./vendor/bin/phpstan analyse
frontend-test:
name: Front-end Test
env:
LARAVEL_BYPASS_ENV_CHECK: 1
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
extensions: bcmath, dom, fileinfo, gd, imagick, mbstring, pgsql, zip
tools: composer, pecl
- name: Get composer cache directory
id: composer-cache
run: |
printf '::set-output name=dir::%s' "$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
- name: Cache frontend dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci --prefer-offline
- name: Run Vitest
run: node_modules/.bin/vitest --run
backend-test:
name: Back-end Test
runs-on: ubuntu-latest
env:
BROADCAST_DRIVER: log
CACHE_DRIVER: redis
DB_CONNECTION: pgsql
DB_DATABASE: laravel
DB_HOST: localhost
DB_PASSWORD: password
DB_USERNAME: username
QUEUE_CONNECTION: redis
REDIS_HOST: localhost
SESSION_DRIVER: redis
services:
postgres:
image: postgres:11-alpine
env:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
POSTGRES_DB: laravel
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
redis:
image: redis
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
extensions: bcmath, dom, fileinfo, gd, imagick, mbstring, pgsql, zip
tools: composer, pecl
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
- name: Get composer cache directory
id: composer-cache
run: |
printf '::set-output name=dir::%s' "$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare the application
env:
DB_PORT: ${{ job.services.postgres.ports[5432] }}
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
cp .env.testing .env
rm -f .env.testing
echo "DB_PORT=$DB_PORT" >> $GITHUB_ENV
echo "REDIS_PORT=$REDIS_PORT" >> $GITHUB_ENV
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Cache frontend dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci --prefer-offline
- name: Publish public assets
run: php artisan vendor:publish --tag=public
- name: Build frontend
run: npm run build
- name: Generate app key
run: php artisan key:generate
- name: Clear Config
run: php artisan config:clear
- name: Run Migration
run: php artisan migrate -v
- name: Test with pest
run: vendor/bin/pest
build:
name: Build
needs: ['frontend-lint', 'backend-lint', 'frontend-test', 'backend-test']
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: alkrauss48/simple-slides-laravel
tags: |
type=ref,prefix=dev-,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
file: docker/app/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}