Skip to content

Commit 7993345

Browse files
committed
ci: added tmate and updated profiles
1 parent b463b21 commit 7993345

File tree

5 files changed

+74
-82
lines changed

5 files changed

+74
-82
lines changed

.github/workflows/run_tests.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@ on:
77
paths:
88
- "demo/**"
99
workflow_dispatch:
10+
inputs:
11+
debug_enabled:
12+
type: boolean
13+
required: false
14+
default: false
15+
debug_detached:
16+
type: boolean
17+
required: false
18+
default: false
19+
TEST_ENV:
20+
description: 'Select Test Environment'
21+
type: choice
22+
default: test
23+
options:
24+
- test
25+
- dev
1026

1127
env:
1228
PROJECT_DIR: demo
1329
APP_DIR: todo-app
1430
REPORTS_DIR: reports
1531
RFW_RESULTS_DIR: robotframework-results
32+
TEST_ENV: test
1633

1734
jobs:
1835
setup-and-test:
@@ -41,11 +58,26 @@ jobs:
4158

4259
- name: Install Hatch
4360
run: pipx install hatch
61+
62+
# Enable tmate debugging of manually-triggered workflows if the input option was provided
63+
- name: Setup tmate session
64+
uses: mxschmitt/action-tmate@v3
65+
with:
66+
detached: ${{ inputs.debug_detached }}
67+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
68+
timeout-minutes: 10
69+
70+
- name: Start Webapps
71+
run: hatch run start-webapps
4472

4573
- name: Run Test Cases
46-
run: hatch run run-tests-ci
74+
run: hatch run robotcode -p ci -p ${{ env.TEST_ENV }} robot -d ${{ env.REPORTS_DIR }}
4775
working-directory: ${{ env.PROJECT_DIR }}
4876

77+
- name: Stop Webapps
78+
run: hatch run stop-webapps
79+
if: always()
80+
4981
- name: Upload Test Results
5082
if: always()
5183
uses: actions/upload-artifact@v4

demo/pyproject.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,13 @@ post-install-commands = [
6060
]
6161

6262
[tool.hatch.envs.default.scripts]
63-
robot = "hatch run robotcode -p default robot {args:tests}"
64-
robot-ci = "hatch run robotcode -p ci-test robot --outputdir=reports {args:tests}"
65-
init-something = "hatch run scripts/init-something.py"
66-
run-tests = ["start-webapps", "robot", "stop-webapps"]
67-
run-tests-ci = ["start-webapps", "robot-ci", "stop-webapps"]
68-
pm2-status = ["hatch run pm2 status"]
63+
init-something = "scripts/init-something.py"
6964
start-todo-app-test = [
70-
'hatch run pm2 start "VITE_ENVIRONMENT=Test npm run dev --prefix todo-app" --name Test',
65+
'pm2 start "VITE_ENVIRONMENT=Test npm run dev --prefix todo-app" --name Test',
7166
]
7267
start-todo-app-dev = [
73-
'hatch run pm2 start "VITE_ENVIRONMENT=Development npm run dev --prefix todo-app" --name Dev',
68+
'pm2 start "VITE_ENVIRONMENT=Development npm run dev --prefix todo-app" --name Dev',
7469
]
7570
start-webapps = ["start-todo-app-test", "start-todo-app-dev"]
76-
stop-webapps = ["hatch run pm2 delete all", "pm2 status"]
71+
stop-webapps = ["pm2 delete all", "pm2 status"]
7772
analyze = ["./scripts/robotcode_analyze.sh"]

demo/robot.toml

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,45 @@
1-
paths = ["."]
1+
default-profiles = ["default"]
2+
paths = ["tests"]
23
name = "My RobotCode Example Tests"
34

45
[metadata]
56
"ci run" = { expr = "environ.get('CI', 'unknown')" }
67
"architecture" = { expr = "platform.architecture()" }
78
"python-version" = { expr = "platform.python_version()" }
89

9-
[profiles.webkit.variables]
10+
[profiles.webkit.extend-variables]
1011
BROWSER = "webkit"
1112

12-
[profiles.firefox.variables]
13+
[profiles.firefox.extend-variables]
1314
BROWSER = "firefox"
1415

15-
[profiles.chromium.variables]
16+
[profiles.chromium.extend-variables]
1617
BROWSER = "chromium"
1718

18-
[profiles.test-env.extend-variables]
19-
PORT = "3000"
20-
21-
[profiles.dev-env.extend-variables]
22-
PORT = "3001"
23-
2419
[profiles.headless.extend-variables]
2520
HEADLESS = "True"
2621

2722
[profiles.headfull.extend-variables]
2823
HEADLESS = "False"
2924

30-
[profiles.webkit]
31-
hidden = true
32-
33-
[profiles.firefox]
34-
hidden = true
35-
36-
[profiles.chromium]
37-
hidden = true
38-
39-
[profiles.test-env]
40-
hidden = true
41-
42-
[profiles.dev-env]
43-
hidden = true
44-
45-
[profiles.headless]
46-
hidden = true
47-
48-
[profiles.headfull]
49-
hidden = true
50-
51-
[profiles.default]
52-
description = "default profile for all tests on local machine"
53-
inherits = ["chromium", "headfull"]
54-
55-
[profiles.regression]
56-
description = "headfull regression tests"
57-
inherits = ["test-env", "headfull"]
58-
includes = ["regression"]
59-
60-
[profiles.test]
61-
description = "headfull run on test env with firefox"
62-
inherits = ["test-env", "firefox", "headfull"]
63-
64-
[profiles.dev]
65-
description = "headfull run on dev env with chrome"
66-
inherits = ["dev-env", "chromium", "headfull"]
25+
[profiles.test.extend-variables]
26+
PORT = "3000"
27+
APP_TITLE = "Test: Todo App"
28+
APP_HEADER = "Test Environment"
29+
APP_COLOR = "bg-red-400"
6730

68-
[profiles.dev.variables]
31+
[profiles.dev.extend-variables]
6932
PORT = "3001"
7033
APP_TITLE = "Development: Todo App"
7134
APP_HEADER = "Development Environment"
7235
APP_COLOR = "bg-blue-400"
7336

74-
[profiles.ci-test]
75-
description = "ci run on test env"
76-
enabled = { if = 'environ.get("CI") == "true"' }
77-
inherits = ["webkit", "test-env", "headless"]
78-
79-
[profiles.ci-dev]
80-
description = "ci run on dev env"
81-
enabled = { if = 'environ.get("CI") == "true"' }
82-
inherits = ["firefox", "dev-env", "headless"]
83-
84-
[profiles.ci-dev.variables]
85-
PORT = "3001"
86-
APP_TITLE = "Development: Todo App"
87-
APP_HEADER = "Development Environment"
88-
APP_COLOR = "bg-blue-400"
37+
[profiles.regression]
38+
description = "run only regression tests"
39+
includes = ["regression"]
8940

90-
[profiles.ci-no-regression]
41+
[profiles.ci]
9142
description = "ci run on test env"
92-
hidden = { if = 'environ.get("CI") != "true"' }
93-
inherits = ["test-env", "firefox", "headless"]
94-
excludes = ["regression"]
43+
enabled = { if = 'environ.get("CI") == "true"' }
44+
inherits = ["headless"]
45+
precedence = 1000

demo/tests/02_web_app/__init__.robot

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,20 @@
22
Documentation Initializes browser test environment
33
44
Resource demo/config/common.resource
5+
Library Process
56
Library Browser
67

7-
Suite Setup New Browser ${BROWSER} ${HEADLESS}
8-
Suite Teardown Close Browser
8+
Suite Setup Init Webapps And Browser
9+
Suite Teardown Stop Webapps And Close Browser
10+
11+
12+
*** Keywords ***
13+
Init Webapps And Browser
14+
[Documentation] Start Webapps and open browser
15+
Run Process hatch run start-webapps
16+
New Browser ${BROWSER} ${HEADLESS}
17+
18+
Stop Webapps And Close Browser
19+
[Documentation] Stop Webapps and close browser
20+
Run Process hatch run stop-webapps
21+
Close Browser

demo/tests/__init__.robot

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*** Settings ***
2-
Metadata USERNAME %{USER=None}
3-
Metadata PLATFORM SYSTEM ${{platform.system()}}
4-
Metadata PLATFORM VERSION ${{platform.version()}}
2+
Documentation Metadata for Test Suite
3+
Metadata USERNAME %{USER=None}
4+
Metadata PLATFORM SYSTEM ${{platform.system()}}
5+
Metadata PLATFORM VERSION ${{platform.version()}}

0 commit comments

Comments
 (0)