-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (186 loc) · 6.37 KB
/
pre-test.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
name: CI-Unit-Test
on:
pull_request:
branches:
- dev
workflow_call:
inputs:
build_id:
required: true
type: number
deploy_target:
required: true
type: string
run-name: Unit/E2E test of ${{ github.ref_name }} by ${{ github.actor }}
jobs:
build:
name: Application Build Test & Set up & Initialize Test Database Server
runs-on: ubuntu-latest
steps:
# Checkout repository codes
- name: Repository Checkout
uses: actions/checkout@v4
# Setup environment for Node.js 18
- name: Node.js version 18 Environment setting
uses: actions/setup-node@v4
with:
node-version: 18
- name: Initialize .ci.env
run: |
touch .ci.env
echo "DATABASE_URL=${{ secrets.DATABASE_URL}}" >> .ci.env
echo "ADMIN_EMAIL=${{secrets.ADMIN_EMAIL}}" >> .ci.env
echo "ADMIN_PW=${{secrets.ADMIN_PW}}" >> .ci.env
echo "JWT_SECRET=${{secrets.JWT_SECRET}}" >> .ci.env
echo "JUDGE_SERVER_ENDPOINT=${{secrets.JUDGE_SERVER_ENDPOINT}}" >> .ci.env
echo "AWS_REGION"=${{secrets.AWS_REGION}}>> .ci.env
echo "AWS_ACCESS_ID=${{secrets.AWS_ACCESS_ID}}" >> .ci.env
echo "AWS_ACCESS_SECRET=${{secrets.AWS_ACCESS_SECRET}}" >> .ci.env
echo "AWS_SQS_QUEUE=${{secrets.AWS_SQS_QUEUE}}" >> .ci.env
echo "AWS_S3_BUCKET=${{secrets.AWS_S3_BUCKET}}" >> .ci.env
- name: Install Node.js Dependencies
run: npm install --force
- name: Install dotenv-cli for CI script
run: npm install -g dotenv-cli
- id: build-phase
name: Check Nest.js Application Build
continue-on-error: true
run: yarn build
# Push Prisma Schema to test DB
- name: Initialize Prisma Client
run: npm run ci:init
# Preserve Artifacts for test
- name: Preserve Artifacts
uses: actions/upload-artifact@v4
with:
name: build-result
path: .
- name: 'Discord Alert - Success'
if: steps.build-phase.outcome == 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
details: 'Build & Setup: Success'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Discord Alert - Failed'
if: steps.build-phase.outcome != 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: error
details: 'Build & Setup: Fail'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Fail check'
if: steps.build-phase.outcome != 'success'
run: exit1
unit-testing:
needs: build
runs-on: ubuntu-latest
steps:
# Setup environment for Node.js 18
- name: Node.js version 18 Environment setting
uses: actions/setup-node@v4
with:
node-version: 18
- name: Mount volume of pre-build
uses: actions/download-artifact@v4
with:
name: build-result
path: .
- name: Grant Permission to artifacts
run: chmod -R 777 .
- name: Install dotenv-cli for CI script
run: npm install -g dotenv-cli
- id: unit-test-phase
name: Run Unit Test
continue-on-error: true
run: npm run ci:unit
- name: 'Discord Alert - Success'
if: steps.unit-test-phase.outcome == 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
details: 'Unit Test Result: Success'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Discord Alert - Failed'
if: steps.unit-test-phase.outcome != 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: error
details: 'Unit Test Result: Fail'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Fail check'
if: steps.unit-test-phase.outcome != 'success'
run: exit1
e2e-testing:
needs: build
runs-on: ubuntu-latest
steps:
- name: Node.js version 18 Environment setting
uses: actions/setup-node@v4
with:
node-version: 18
- name: Mount volume of pre-build
uses: actions/download-artifact@v4
with:
name: build-result
path: .
- name: Grant Permission to artifacts
run: chmod -R 777 .
- name: Install dotenv-cli for CI script
run: npm install -g dotenv-cli
- id: e2e-test-phase
name: Run E2E Test
continue-on-error: true
run: npm run ci:e2e
- name: 'Discord Alert - Success'
if: steps.e2e-test-phase.outcome == 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
details: 'E2E Test Result: Success'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Discord Alert - Fail'
if: steps.e2e-test-phase.outcome != 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: error
details: 'E2E Test Result: Failed'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Fail check'
if: steps.e2e-test-phase.outcome != 'success'
run: exit1
tear-down:
needs: [unit-testing, e2e-testing]
runs-on: ubuntu-latest
steps:
- name: Node.js version 18 Environment setting
uses: actions/setup-node@v4
with:
node-version: 18
- name: Mount volume of pre-build
uses: actions/download-artifact@v4
with:
name: build-result
path: .
- name: Grant Permission to artifacts
run: chmod -R 777 .
- name: Install dotenv-cli for CI script
run: npm install -g dotenv-cli
- id: tear-down-phase
name: Test Database tear-down
continue-on-error: true
run: node node_modules/prisma/build/index.js db push --force-reset
- name: 'Discord Alert - Success'
if: steps.tear-down-phase.outcome == 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: info
details: 'Test DB Tear down: Success'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: 'Discord Alert - Fail'
if: steps.tear-down-phase.outcome != 'success'
uses: rjstone/discord-webhook-notify@v1
with:
severity: error
details: 'Test DB Tear down: Failed'
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}