Skip to content

Commit 03c71bf

Browse files
committed
Adding cypress config settings
1 parent 42a0906 commit 03c71bf

File tree

3 files changed

+48
-82
lines changed

3 files changed

+48
-82
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,24 @@
22

33
name: CI
44

5-
# Controls when the workflow will run
65
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
86
pull_request:
97
branches: [ master, next ]
10-
11-
# Allows you to run this workflow manually from the Actions tab
128
workflow_dispatch:
139
inputs:
1410
custom_tag:
1511
description: 'Custom Docker tag (optional)'
1612
required: false
1713
default: ''
1814

19-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2015
jobs:
21-
# This workflow contains a single job called "build"
2216
install:
23-
# The type of runner that the job will run on
2417
runs-on: ubuntu-20.04
25-
26-
# Steps represent a sequence of tasks that will be executed as part of the job
2718
steps:
28-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2919
- uses: actions/checkout@v3
3020

3121
- name: Github Actions Azure connection fix
3222
run: |
33-
# Workaround for https://github.com/actions/runner-images/issues/675#issuecomment-1381389712
3423
sudo sed -i 's/azure/us/g' /etc/apt/sources.list
3524
3625
- name: Installing Countly
@@ -64,9 +53,9 @@ jobs:
6453
- name: Output Nginx Logs
6554
if: ${{ always() }}
6655
run: sudo cat /var/log/nginx/error.log
56+
6757
lint:
6858
runs-on: ubuntu-latest
69-
7059
services:
7160
mongodb:
7261
image: mongo:6.0
@@ -77,7 +66,6 @@ jobs:
7766
--health-retries 5
7867
ports:
7968
- 27017:27017
80-
8169
container:
8270
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
8371
env:
@@ -121,9 +109,9 @@ jobs:
121109
shell: bash
122110
working-directory: /opt/countly
123111
run: sudo countly task dist-all
112+
124113
test-api-core:
125114
runs-on: ubuntu-latest
126-
127115
services:
128116
mongodb:
129117
image: mongo:6.0
@@ -134,7 +122,6 @@ jobs:
134122
--health-retries 5
135123
ports:
136124
- 27017:27017
137-
138125
container:
139126
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
140127
env:
@@ -168,62 +155,9 @@ jobs:
168155
/sbin/my_init &
169156
node bin/scripts/test.connection.js
170157
npx grunt mochaTest
171-
test-api-plugins:
172-
runs-on: ubuntu-latest
173-
174-
services:
175-
mongodb:
176-
image: mongo:6.0
177-
options: >-
178-
--health-cmd mongosh
179-
--health-interval 10s
180-
--health-timeout 5s
181-
--health-retries 5
182-
ports:
183-
- 27017:27017
184-
185-
container:
186-
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
187-
env:
188-
COUNTLY_CONFIG__MONGODB_HOST: mongodb
189-
COUNTLY_CONFIG_API_PREVENT_JOBS: true
190-
191-
steps:
192-
- uses: actions/checkout@v3
193-
194-
- name: Copy code
195-
shell: bash
196-
run: cp -rf ./* /opt/countly
197-
198-
- name: Prepare files to use correct MongoDB host
199-
shell: bash
200-
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"
201-
202-
- name: Prepare tests
203-
shell: bash
204-
run: bash bin/scripts/countly.prepare.ce.plugins.tests.sh
205-
206-
- name: Configure API
207-
shell: bash
208-
run: "sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js"
209-
210-
- name: Install plugins
211-
shell: bash
212-
run: |
213-
cp plugins/plugins.default.json /opt/countly/plugins/plugins.json
214-
node /opt/countly/bin/scripts/install_plugins.js --force
215158
216-
- name: Run tests
217-
shell: bash
218-
working-directory: /opt/countly
219-
run: |
220-
npm install
221-
/sbin/my_init &
222-
node bin/scripts/test.connection.js
223-
npx grunt mochaTest
224159
ui-test-dashboard:
225160
runs-on: ubuntu-latest
226-
227161
services:
228162
mongodb:
229163
image: mongo:6.0
@@ -234,7 +168,6 @@ jobs:
234168
--health-retries 5
235169
ports:
236170
- 27017:27017
237-
238171
container:
239172
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
240173
env:
@@ -244,6 +177,9 @@ jobs:
244177
steps:
245178
- uses: actions/checkout@v2
246179

180+
- name: Set XDG_RUNTIME_DIR
181+
run: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV
182+
247183
- name: Install Chrome
248184
shell: bash
249185
run: |
@@ -256,10 +192,6 @@ jobs:
256192
shell: bash
257193
run: cp -rf ./* /opt/countly
258194

259-
- name: Prepare files to use correct MongoDB host
260-
shell: bash
261-
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"
262-
263195
- name: Prepare environment
264196
shell: bash
265197
working-directory: /opt/countly
@@ -286,7 +218,7 @@ jobs:
286218
/sbin/my_init &
287219
cd ui-tests
288220
npm install
289-
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
221+
xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" \
290222
npm run cy:run:dashboard --headless --no-sandbox --disable-gpu --disable-dev-shm-usage
291223
292224
- name: Upload UI tests artifacts
@@ -301,7 +233,6 @@ jobs:
301233
302234
ui-test-onboarding:
303235
runs-on: ubuntu-latest
304-
305236
services:
306237
mongodb:
307238
image: mongo:6.0
@@ -312,7 +243,6 @@ jobs:
312243
--health-retries 5
313244
ports:
314245
- 27017:27017
315-
316246
container:
317247
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
318248
env:
@@ -322,6 +252,9 @@ jobs:
322252
steps:
323253
- uses: actions/checkout@v2
324254

255+
- name: Set XDG_RUNTIME_DIR
256+
run: echo "XDG_RUNTIME_DIR=/tmp" >> $GITHUB_ENV
257+
325258
- name: Install Chrome
326259
shell: bash
327260
run: |
@@ -334,10 +267,6 @@ jobs:
334267
shell: bash
335268
run: cp -rf ./* /opt/countly
336269

337-
- name: Prepare files to use correct MongoDB host
338-
shell: bash
339-
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"
340-
341270
- name: Prepare environment
342271
shell: bash
343272
working-directory: /opt/countly
@@ -360,7 +289,7 @@ jobs:
360289
/sbin/my_init &
361290
cd ui-tests
362291
npm install
363-
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
292+
xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" \
364293
npm run cy:run:onboarding --headless --no-sandbox --disable-gpu --disable-dev-shm-usage
365294
366295
- name: Upload UI tests artifacts

ui-tests/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ cypress/hars
33
cypress/videos
44
cypress/screenshots
55
cypress/fixtures/user.json
6-
cypress.config.js

ui-tests/cypress.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { defineConfig } = require("cypress");
2+
3+
const fs = require('fs');
4+
5+
module.exports = defineConfig({
6+
e2e: {
7+
baseUrl: "http://localhost",
8+
defaultCommandTimeout: 30000,
9+
viewportWidth: 2000,
10+
viewportHeight: 1100,
11+
numTestsKeptInMemory: 0, // Keep 0 tests in memory to reduce memory usage
12+
projectId: "000000",
13+
chromeWebSecurity: false,
14+
watchForFileChanges: true,
15+
video: true,
16+
experimentalMemoryManagement: true, // Enable experimental memory management
17+
retries: {
18+
runMode: 2, // Retry failed tests up to 2 times in headless mode
19+
openMode: 0, // No retries in interactive mode
20+
},
21+
setupNodeEvents(on, config) {
22+
on('after:spec', (spec, results) => {
23+
if (results && results.video) {
24+
const failures = results.tests.some((test) =>
25+
test.attempts.some((attempt) => attempt.state === 'failed')
26+
);
27+
if (!failures) {
28+
// delete the video if the spec passed and no tests retried
29+
const videoPath = results.video;
30+
if (fs.existsSync(videoPath)) {
31+
fs.unlinkSync(videoPath);
32+
}
33+
}
34+
}
35+
});
36+
},
37+
},
38+
});

0 commit comments

Comments
 (0)