-
Notifications
You must be signed in to change notification settings - Fork 1
257 lines (226 loc) · 8.09 KB
/
e2e.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
name: 'E2E Tests'
on:
push:
branches:
- main
pull_request:
env:
MARIADB_VERSION: 10.5.10
REDIS_VERSION: 6.2.4
MINIO_VERSION: RELEASE.2023-07-21T21-12-44Z
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: index
- name: login
dependencies: [ictsc-rikka]
- name: notices
dependencies: [ictsc-rikka]
- name: profile
dependencies: [ictsc-rikka]
- name: ranking
dependencies: [ictsc-rikka]
- name: signUp
dependencies: [ictsc-rikka]
- name: team_info
dependencies: [ictsc-rikka]
- name: users
dependencies: [ictsc-rikka]
- name: problems/problemId
dependencies: [ictsc-rikka]
- name: problems/index
dependencies: [ictsc-rikka]
- name: scoring/code
dependencies: [ictsc-rikka]
- name: scoring/index
dependencies: [ictsc-rikka]
- name: components/navbar
dependencies: [ictsc-rikka]
steps:
- name: Set Timezone
run: sudo timedatectl set-timezone Asia/Tokyo
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8.6.10
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'pnpm'
cache-dependency-path: frontend/octavio/pnpm-lock.yaml
- name: Install dependencies
working-directory: frontend/octavio
run: pnpm i --frozen-lockfile
- name: Cache font build
id: cache-font
uses: actions/cache@v3
with:
path: frontend/octavio/app/dist/fonts
key: font-${{ hashFiles('frontend/octavio/Dockerfile') }}
- name: Build Font
if: steps.cache-font.outputs.cache-hit != 'true'
working-directory: frontend/octavio
run: pnpm font
- name: Get installed Playwright version
id: playwright-version
working-directory: frontend/octavio
run: echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('@playwright/test/package.json').version)")" >> $GITHUB_OUTPUT
- name: Cache install Playwright
id: cache-playwright
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}
- name: Install Playwright
if: steps.cache-playwright.outputs.cache-hit != 'true'
working-directory: frontend/octavio
run: npx playwright install --with-deps chromium
- name: Set env
working-directory: frontend/octavio
run: |
cat <<EOF > .env.local
NEXT_PUBLIC_API_URL=http://localhost:8080/api
NEXT_PUBLIC_ANSWER_LIMIT=20
NEXT_PUBLIC_SITE_NAME=ICTSC
RULE=## ルール本文
NEXT_PUBLIC_SHORT_RULE=## 短いルール本文
NEXT_PUBLIC_RECREATE_RULE=## 再展開ルール本文
EOF
#
# define start ictsc-rikka steps
#
- name: Checkout ictsc-rikka repository
if: contains(matrix.dependencies, 'ictsc-rikka')
uses: actions/checkout@v3
with:
repository: ictsc/ictsc-rikka
path: ictsc-rikka
# MariaDB cache
- name: Cache a MariaDB Docker image
if: contains(matrix.dependencies, 'ictsc-rikka')
id: cache-mariadb
uses: actions/cache@v3
with:
path: mariadb-image
key: mariadb-${{ env.MARIADB_VERSION }}
- name: Pull and save a MariaDB Docker image
if: contains(matrix.dependencies, 'ictsc-rikka') && steps.cache-mariadb.outputs.cache-hit != 'true'
run: |
docker pull mariadb:${{ env.MARIADB_VERSION }}
docker save mariadb:${{ env.MARIADB_VERSION }} -o mariadb-image
- if: contains(matrix.dependencies, 'ictsc-rikka')
run: docker load -i mariadb-image
# Redis cache
- name: Cache a Redis Docker image
if: contains(matrix.dependencies, 'ictsc-rikka')
id: cache-redis
uses: actions/cache@v3
with:
path: redis-image
key: redis-${{ env.REDIS_VERSION }}
- name: Pull and save a Redis Docker image
if: contains(matrix.dependencies, 'ictsc-rikka') && steps.cache-redis.outputs.cache-hit != 'true'
run: |
docker pull redis:${{ env.REDIS_VERSION }}
docker save redis:${{ env.REDIS_VERSION }} -o redis-image
- if: contains(matrix.dependencies, 'ictsc-rikka')
run: docker load -i redis-image
# Minio cache
- name: Cache a Minio Docker image
if: contains(matrix.dependencies, 'ictsc-rikka')
id: cache-minio
uses: actions/cache@v3
with:
path: minio-image
key: minio-${{ env.MINIO_VERSION }}
- name: Pull and save a Minio Docker image
if: contains(matrix.dependencies, 'ictsc-rikka') && steps.cache-minio.outputs.cache-hit != 'true'
run: |
docker pull minio/minio:${{ env.MINIO_VERSION }}
docker save minio/minio:${{ env.MINIO_VERSION }} -o minio-image
- if: contains(matrix.dependencies, 'ictsc-rikka')
run: docker load -i minio-image
- name: Set env
if: contains(matrix.dependencies, 'ictsc-rikka')
working-directory: ictsc-rikka
run: |
cat <<EOF > cmd/rikka/config.docker.yaml
listen:
address: 0.0.0.0
port: 8080
cors:
origins:
- http://localhost:3000
store:
secure: false
sameSiteStrictMode: lax
domain:
notify:
answer: http://localhost:8080
## answerLimit (value * time.Minute)
contest:
answerLimit: 20
mariadb:
address: mariadb
port: 3306
username: rikka
password: rikka-password
database: rikka
redis:
idleConnectionSize: 10
address: redis
port: 6379
keyPair: secret
seed:
adminUserGroupAndUserSeeder:
userGroupName: admin-group
organization: admin-org
invitationCode: test-invitation-code
userName: admin
userPassword: password
minio:
endPoint: minio:9000
accessKeyID: admin
secretAccessKey: adminadmin
useSSL: false
EOF
- name: Cache Docker Layer
if: contains(matrix.dependencies, 'ictsc-rikka')
uses: jpribyl/[email protected]
# Docker コンテナが起動してから、レスポンスが返ってくるまで待機する
# リトライは10回まで `/` にアクセスしてレスポンスのステータスコードをチェック
# - ステータスコードが `404` の場合は正常終了します
# - ステータスコードが `404` 以外の場合は、5秒間スリープしてリトライします
- name: Run rikka
if: contains(matrix.dependencies, 'ictsc-rikka')
working-directory: ictsc-rikka
run: |
set +e # curlのエラーを無視する
cp scripts/docker-compose.override.yml docker-compose.override.yml
make up
url="http://localhost:8080"
max_attempts=15
sleep_interval=5
for i in $(seq 1 $max_attempts); do
status=$(curl -o /dev/null -s -w '%{http_code}\n' $url)
if [ $status -eq 404 ]; then
echo "Container is ready! Response status code: $status"
exit 0
else
echo "Attempt $i/$max_attempts: Response status code $status"
sleep $sleep_interval
fi
done
exit 1
#
# define end ictsc-rikka steps
#
- name: Run tests
working-directory: frontend/octavio
run: npx playwright test __e2e__/${{ matrix.name }}