Skip to content

Commit 09464f1

Browse files
🧪 CI
🧪 ci order upd 🧪 CI
1 parent 0f26e99 commit 09464f1

5 files changed

Lines changed: 109 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,56 @@ jobs:
4242
path: jacoco.xml
4343
if-no-files-found: error
4444

45+
playwright-tests:
46+
runs-on: ubuntu-latest
47+
needs: unit-tests
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Node.js
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: '20'
56+
57+
- name: Install Playwright dependencies
58+
working-directory: ./others/playwright
59+
run: npm ci
60+
61+
- name: Install Playwright browsers
62+
working-directory: ./others/playwright
63+
run: npx playwright install
64+
65+
- name: Wait for app to be ready
66+
run: |
67+
APP_URL="https://gitlab-simfeatures.${{ secrets.PORTAINER_URL }}/ui"
68+
for i in $(seq 1 30); do
69+
if curl -sf -o /dev/null "$APP_URL"; then
70+
echo "App is ready"
71+
break
72+
fi
73+
echo "Waiting for app... ($i/30)"
74+
sleep 10
75+
done
76+
curl -sf -o /dev/null "$APP_URL" || (echo "App failed to become ready" && exit 1)
77+
78+
- name: Run Playwright tests
79+
working-directory: ./others/playwright
80+
env:
81+
CI: true
82+
BASE_URL: "https://gitlab-simfeatures.${{ secrets.PORTAINER_URL }}/ui"
83+
USER_NAME: playwright
84+
PASSWORD: ${{ secrets.PLAYWRIGHT_PASSWORD }}
85+
run: npx playwright test --project=firefox
86+
87+
- name: Upload Playwright report
88+
uses: actions/upload-artifact@v4
89+
if: failure()
90+
with:
91+
name: playwright-report
92+
path: others/playwright/playwright-report/
93+
retention-days: 7
94+
4595
sonarcloud-check:
4696
runs-on: ubuntu-latest
4797
needs: unit-tests

.gitlab-ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,35 @@ deploy-test:
1414
- ./others/cicd/simci portainer-stack-delete gitlab-simfeatures $PORTAINER_URL
1515
- ./others/cicd/simci portainer-stack-deploy -f ./others/cicd/portainer-stack.yml gitlab-simfeatures $PORTAINER_URL
1616

17+
playwright-tests:
18+
stage: test
19+
needs: [deploy-test]
20+
image: mcr.microsoft.com/playwright:v1.56.1-jammy
21+
variables:
22+
BASE_URL: "https://gitlab-simfeatures.${PORTAINER_URL}/ui"
23+
USER_NAME: playwright
24+
PASSWORD: "${PLAYWRIGHT_PASSWORD}"
25+
before_script:
26+
- cd others/playwright
27+
- npm ci
28+
script:
29+
- |
30+
for i in $(seq 1 30); do
31+
if curl -sf -o /dev/null "$BASE_URL"; then
32+
echo "App is ready"
33+
break
34+
fi
35+
echo "Waiting for app... ($i/30)"
36+
sleep 10
37+
done
38+
curl -sf -o /dev/null "$BASE_URL" || (echo "App failed to become ready" && exit 1)
39+
- npx playwright test --project=chromium
40+
artifacts:
41+
when: on_failure
42+
paths:
43+
- others/playwright/playwright-report/
44+
expire_in: 7 days
45+
1746
unit-tests:
1847
stage: test
1948
script:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"row_module_id__mdl_name": "SimFeatures",
3+
"dt_name": "PlaywrightUser",
4+
"dt_file": {
5+
"path": "others/playwright/playwright_user.xml",
6+
"mime": "text/xml",
7+
"name": "playwright_user.xml"
8+
},
9+
"dt_desc": "Creates the playwright user with FT_ADMIN responsibility for Playwright E2E tests.",
10+
"dt_exportdate_from": null,
11+
"dt_exportdate_to": null,
12+
"dt_export_format": "xml",
13+
"dt_export_zip": false
14+
}

others/playwright/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"version": "1.0.0",
44
"description": "",
55
"main": "index.js",
6-
"scripts": {},
6+
"scripts": {
7+
"test": "playwright test"
8+
},
79
"keywords": [],
810
"author": "",
911
"license": "ISC",

others/playwright/playwright.config.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ export default defineConfig({
2222
fullyParallel: true,
2323
/* Fail the build on CI if you accidentally left test.only in the source code. */
2424
forbidOnly: !!process.env.CI,
25-
/* Retry on CI only */
26-
retries: process.env.CI ? 2 : 0,
25+
/* Retry on CI only (1 retry = 2 attempts max) */
26+
retries: process.env.CI ? 1 : 0,
2727
/* Opt out of parallel tests on CI. */
2828
workers: process.env.CI ? 1 : undefined,
2929
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
30-
reporter: 'html',
30+
reporter: [
31+
['list'],
32+
['html'],
33+
],
3134
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3235
use: {
3336
/* Base URL to use in actions like `await page.goto('')`. */
@@ -36,17 +39,17 @@ export default defineConfig({
3639
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
3740
trace: 'on-first-retry',
3841

39-
/* Increase timeouts for web instances with higher latency */
40-
actionTimeout: 30000, // 30 seconds for actions (default is 5s)
41-
navigationTimeout: 30000, // 30 seconds for navigation (default is 30s)
42+
/* Timeouts for web instances */
43+
actionTimeout: 15000, // 15 seconds for actions
44+
navigationTimeout: 15000, // 15 seconds for navigation
4245
},
43-
46+
4447
/* Global test timeout */
45-
timeout: 60000, // 60 seconds per test (default is 30s)
46-
48+
timeout: 30000, // 30 seconds per test
49+
4750
/* Expect timeout for assertions */
4851
expect: {
49-
timeout: 10000, // 10 seconds for assertions (default is 5s)
52+
timeout: 5000, // 5 seconds for assertions
5053
},
5154

5255
/* Configure projects for major browsers */

0 commit comments

Comments
 (0)