-
Notifications
You must be signed in to change notification settings - Fork 973
374 lines (314 loc) · 12.4 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches: [ master, next ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
custom_tag:
description: 'Custom Docker tag (optional)'
required: false
default: ''
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
install:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Github Actions Azure connection fix
run: |
# Workaround for https://github.com/actions/runner-images/issues/675#issuecomment-1381389712
sudo sed -i 's/azure/us/g' /etc/apt/sources.list
- name: Installing Countly
shell: bash
run: sudo bash ./bin/countly.install.sh
- name: NodeJS version
shell: bash
run: node --version
- name: NPM version
shell: bash
run: npm --version
- name: Mongo version
shell: bash
run: mongosh --version
- name: Output API Logs
if: ${{ always() }}
run: cat log/countly-api.log
- name: Output Dashboard Logs
if: ${{ always() }}
run: cat log/countly-dashboard.log
- name: Output MongoDB Logs
if: ${{ always() }}
run: sudo cat /var/log/mongodb/mongod.log
- name: Output Nginx Logs
if: ${{ always() }}
run: sudo cat /var/log/nginx/error.log
lint:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:6.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true
steps:
- uses: actions/checkout@v3
- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly
- name: Enable command line
shell: bash
run: sudo bash /opt/countly/bin/scripts/detect.init.sh
- name: ShellCheck
shell: bash
run: |
apt-get update -y
apt-get -y install shellcheck
countly shellcheck
- name: ESLint
shell: bash
run: |
npm install eslint@8.57.0
npx eslint .
- name: NPM install
shell: bash
working-directory: /opt/countly
run: npm install
- name: Enabling plugins
shell: bash
run: cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
- name: DistFiles
shell: bash
working-directory: /opt/countly
run: sudo countly task dist-all
test-api-core:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:6.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true
steps:
- uses: actions/checkout@v3
- name: Prepare tests
shell: bash
run: bash bin/scripts/countly.prepare.ce.tests.sh
- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly
- name: Remove plugin tests
shell: bash
run: rm -rf /opt/countly/test/4.plugins
- name: Configure API
shell: bash
run: "sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js"
- name: Run tests
shell: bash
working-directory: /opt/countly
run: |
npm install
/sbin/my_init &
node bin/scripts/test.connection.js
npx grunt mochaTest
test-api-plugins:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:6.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true
steps:
- uses: actions/checkout@v3
- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly
- name: Prepare files to use correct MongoDB host
shell: bash
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/run.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/run.sh"
- name: Prepare tests
shell: bash
run: bash bin/scripts/countly.prepare.ce.plugins.tests.sh
- name: Configure API
shell: bash
run: "sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js"
- name: Install plugins
shell: bash
run: |
cp plugins/plugins.default.json /opt/countly/plugins/plugins.json
node /opt/countly/bin/scripts/install_plugins.js --force
- name: Run tests
shell: bash
working-directory: /opt/countly
run: |
npm install
/sbin/my_init &
node bin/scripts/test.connection.js
npx grunt mochaTest
ui-test-dashboard:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:6.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true
steps:
- uses: actions/checkout@v2
- name: Install Chrome
shell: bash
run: |
apt update
apt install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/chrome.deb
apt install -y /tmp/chrome.deb
- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly
- name: Prepare files to use correct MongoDB host
shell: bash
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"
- name: Prepare environment
shell: bash
working-directory: /opt/countly
run: |
sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js
cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
npm install
sudo countly task dist-all
bash bin/backup/import_events.sh
bash bin/scripts/countly.prepare.ce.tests.sh
countly add_user '${{ secrets.CYPRESS_USER_EMAIL }}' '${{ secrets.CYPRESS_USER_PASSWORD }}'
mongosh --host mongodb --eval 'db.getSiblingDB("countly").members.updateOne({username: "${{ secrets.CYPRESS_USER_EMAIL }}"}, {$set: {username: "${{ secrets.CYPRESS_USER_USERNAME }}", subscribe_newsletter: true}});'
mongosh --host mongodb --eval 'db.getSiblingDB("countly").plugins.updateOne({_id: "plugins"}, {$set: {"frontend.countly_tracking": true}});'
cd ui-tests
echo '{"username": "${{ secrets.CYPRESS_USER_USERNAME }}","email": "${{ secrets.CYPRESS_USER_EMAIL }}","password": "${{ secrets.CYPRESS_USER_PASSWORD }}"}' > cypress/fixtures/user.json
sed -i 's/00000000-0000-0000-0000-000000000000/${{ secrets.CYPRESS_KEY }}/g' package.json
cp cypress.config.sample.js cypress.config.js
sed -i 's/000000/${{ secrets.CYPRESS_PROJECT_ID }}/g' cypress.config.js
- name: Run UI tests
shell: bash
working-directory: /opt/countly
run: |
/sbin/my_init &
cd ui-tests
npm install
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
npm run cy:run:dashboard --headless --no-sandbox --disable-gpu --disable-dev-shm-usage
- name: Upload UI tests artifacts
if: ${{ failure() }}
shell: bash
working-directory: /opt/countly/ui-tests/cypress
run: |
ARTIFACT_ARCHIVE_NAME="$(date '+%Y%m%d-%H.%M')_${GITHUB_REPOSITORY#*/}_CI#${{ github.run_number }}.tar.gz"
mkdir -p screenshots videos
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"
ui-test-onboarding:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:6.0
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 27017:27017
container:
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
COUNTLY_CONFIG_API_PREVENT_JOBS: true
steps:
- uses: actions/checkout@v2
- name: Install Chrome
shell: bash
run: |
apt update
apt install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/chrome.deb
apt install -y /tmp/chrome.deb
- name: Copy code
shell: bash
run: cp -rf ./* /opt/countly
- name: Prepare files to use correct MongoDB host
shell: bash
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"
- name: Prepare environment
shell: bash
working-directory: /opt/countly
run: |
sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js
cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
npm install
sudo countly task dist-all
bash bin/scripts/countly.prepare.ce.tests.sh
cd ui-tests
echo '{"username": "${{ secrets.CYPRESS_USER_USERNAME }}","email": "${{ secrets.CYPRESS_USER_EMAIL }}","password": "${{ secrets.CYPRESS_USER_PASSWORD }}"}' > cypress/fixtures/user.json
sed -i 's/00000000-0000-0000-0000-000000000000/${{ secrets.CYPRESS_KEY }}/g' package.json
cp cypress.config.sample.js cypress.config.js
sed -i 's/000000/${{ secrets.CYPRESS_PROJECT_ID }}/g' cypress.config.js
- name: Run UI tests
shell: bash
working-directory: /opt/countly
run: |
/sbin/my_init &
cd ui-tests
npm install
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
npm run cy:run:onboarding --headless --no-sandbox --disable-gpu --disable-dev-shm-usage
- name: Upload UI tests artifacts
if: ${{ failure() }}
shell: bash
working-directory: /opt/countly/ui-tests/cypress
run: |
ARTIFACT_ARCHIVE_NAME="$(date '+%Y%m%d-%H.%M')_${GITHUB_REPOSITORY#*/}_CI#${{ github.run_number }}.tar.gz"
mkdir -p screenshots videos
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"