-
Notifications
You must be signed in to change notification settings - Fork 976
296 lines (246 loc) · 8.75 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
# 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:
# 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:latest
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
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
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:latest
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
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: |
/sbin/my_init &
npm install
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:latest
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
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: Run tests
shell: bash
working-directory: /opt/countly
run: |
/sbin/my_init &
npm install
node bin/scripts/test.connection.js
npx grunt mochaTest
ui-test:
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:latest
env:
COUNTLY_CONFIG__MONGODB_HOST: mongodb
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/run.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/run.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/run.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 }}"}});'
cd ui-tests
mkdir cypress/fixtures
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
npm run cy:run
- 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"
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos hars
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"
notify:
runs-on: ubuntu-latest
needs: [ install, lint, test-api-core, test-api-plugins ]
steps:
- name: Send slack notification
id: slack
if: always()
uses: slackapi/[email protected]
with:
payload: "{\"url\":\"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\",\"status\":\"${{ job.status }}\"}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}