forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 12
241 lines (235 loc) · 9.45 KB
/
ci-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
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
name: "Flujo CI-Test"
run-name: "Flujo CI - Test"
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
ANGULAR_CLI_VERSION: 13
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: npm install -g @angular/cli@$ANGULAR_CLI_VERSION
- name: "Instalar dependencias"
run: |
npm install --ignore-scripts
cd frontend
npm install --ignore-scripts --legacy-peer-deps
- name: "Lint"
run: npm run lint
- name: "Lint configuraciones personalizadas"
run: >
npm run lint:config -- -f ./config/7ms.yml &&
npm run lint:config -- -f ./config/addo.yml &&
npm run lint:config -- -f ./config/bodgeit.yml &&
npm run lint:config -- -f ./config/ctf.yml &&
npm run lint:config -- -f ./config/default.yml &&
npm run lint:config -- -f ./config/fbctf.yml &&
npm run lint:config -- -f ./config/juicebox.yml &&
npm run lint:config -- -f ./config/mozilla.yml &&
npm run lint:config -- -f ./config/oss.yml &&
npm run lint:config -- -f ./config/quiet.yml &&
npm run lint:config -- -f ./config/tutorial.yml &&
npm run lint:config -- -f ./config/unsafe.yml
test:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: npm install -g @angular/cli@$ANGULAR_CLI_VERSION
- name: "Instalar dependencias"
run: |
npm install
- name: "Ejecutar test unitarios"
uses: nick-invision/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd #v2: 2.8.3 reintenta comando en caso de falla
with:
timeout_minutes: 15
max_attempts: 3
command: npm test
- name: "Copiar información de test coverage pruebas unitarias"
run: |
cp build/reports/coverage/frontend-tests/lcov.info frontend-lcov.info
cp build/reports/coverage/server-tests/lcov.info server-lcov.info
- name: "Subir información de test coverage pruebas unitarias"
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3: v3.1.2
with:
name: unit-test-lcov
path: |
frontend-lcov.info
server-lcov.info
test-api:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: npm install -g @angular/cli@$ANGULAR_CLI_VERSION
- name: "Instalar dependencias"
run: |
npm install
- name: "Ejecutar test de integración"
uses: nick-invision/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd #v2: 2.8.3 reintenta comando en caso de falla
with:
timeout_minutes: 5
max_attempts: 3
command: |
export NODE_ENV=test
npm run frisby
shell: bash
- name: "Copiar información de test coverage pruebas integración"
run: cp build/reports/coverage/api-tests/lcov.info api-lcov.info
- name: "Subir información de test coverages pruebas integración"
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce #v3: v3.1.2
with:
name: api-test-lcov
path: |
api-lcov.info
reporte-coverage:
needs: [test, test-api]
runs-on: ubuntu-latest
if: github.repository == 'juice-shop/juice-shop' && github.event_name == 'push'
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Descargar información de test coverage pruebas unitarias"
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3: v3.0.2
with:
name: unit-test-lcov
- name: "Descargar información de test coverage pruebas integración"
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a #v3: v3.0.2
with:
name: api-test-lcov
- name: "Publish coverage to Codeclimate"
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
sed -i s/SF:/SF:frontend\\//g frontend-lcov.info
./cc-test-reporter format-coverage -t lcov -o codeclimate.frontend.json frontend-lcov.info
./cc-test-reporter format-coverage -t lcov -o codeclimate.server.json server-lcov.info
./cc-test-reporter format-coverage -t lcov -o codeclimate.api.json api-lcov.info
./cc-test-reporter sum-coverage codeclimate.*.json -p 3
./cc-test-reporter upload-coverage
shell: bash
test-personalizado:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: npm install -g @angular/cli@$ANGULAR_CLI_VERSION
- name: "Instalar aplicación"
run: npm install
- name: "Ejecutar tests para cada configuración personalizada"
uses: nick-invision/retry@943e742917ac94714d2f408a0e8320f2d1fcafcd #v2: 2.8.3
with:
timeout_minutes: 10
max_attempts: 3
command: >
NODE_ENV=7ms npm run test:server &&
NODE_ENV=addo npm run test:server &&
NODE_ENV=bodgeit npm run test:server &&
NODE_ENV=ctf npm run test:server &&
NODE_ENV=fbctf npm run test:server &&
NODE_ENV=juicebox npm run test:server &&
NODE_ENV=mozilla npm run test:server &&
NODE_ENV=oss npm run test:server &&
NODE_ENV=quiet npm run test:server &&
NODE_ENV=tutorial npm run test:server &&
NODE_ENV=unsafe npm run test:server
e2e:
if: github.repository == 'juice-shop/juice-shop' && github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
browser: [chrome, firefox]
fail-fast: false
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: npm install -g @angular/cli@$ANGULAR_CLI_VERSION
- name: "Instalar aplicación"
run: npm install
- name: "Ejecutar tests end-to-end"
uses: cypress-io/github-action@96268482322bc63c76561c602a84be842c527dbc #v5.5.1
with:
install: false
browser: ${{ matrix.browser }}
start: npm start
wait-on: http://localhost:3000
record: true
group: ${{ matrix.browser }} @ ${{ matrix.os }}
env:
SOLUTIONS_WEBHOOK: ${{ secrets.E2E_SOLUTIONS_WEBHOOK }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test-humo:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Configurar Node 18"
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c #v3: v3.6.0
with:
node-version: 18
- name: "Instalar CLI de Angular"
run: |
npm install -g @angular/cli@$ANGULAR_CLI_VERSION
npm install -g grunt-cli
- name: "Configurar opciones de empaquetar para Grunt"
run: |
echo "PCKG_OS_NAME=linux" >> $GITHUB_ENV
echo "PCKG_NODE_VERSION=14" >> $GITHUB_ENV
echo "PCKG_CPU_ARCH=x64" >> $GITHUB_ENV
- name: "Empacar aplicación"
run: |
npm install --production
npm install -g grunt-cli
npm run package:ci
- name: "Desempacar aplicación"
run: |
cd dist
tar -zxf juice-shop-*.tgz
- name: "Ejecutar test de humo"
run: |
cd dist/juice-shop_*
npm start &
cd ../..
chmod +x test/smoke/smoke-test.sh
test/smoke/smoke-test.sh http://localhost:3000
test-docker:
runs-on: ubuntu-latest
steps:
- name: "Checkout repositorio"
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f #v3: v3.4.0
- name: "Ejecutar test de humo en Docker"
run: docker-compose -f docker-compose.test.yml up --exit-code-from sut