Skip to content

Commit e3ae865

Browse files
committed
Merge remote-tracking branch 'origin/solution'
2 parents cc1ac24 + 4a0dbda commit e3ae865

File tree

3 files changed

+326
-10
lines changed

3 files changed

+326
-10
lines changed

README.md

Lines changed: 211 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
[![Robotframework Report](https://img.shields.io/badge/Robotframework%20Report-00C0B5)](https://robotcodedev.github.io/rbcn25-mastering-robotcode/public/reports/report.html)
55
[![Robotframework Log](https://img.shields.io/badge/Robotframework%20Log-00C0B5)](https://robotcodedev.github.io/rbcn25-mastering-robotcode/public/reports/log.html)
66

7-
How to master RobotCode Extension and Command Line Tools in real-life Robot Framework projects.
7+
How to master **RobotCode Extension** and Command Line Tools in real-life Robot Framework projects.
8+
9+
![Robotcode Logo](robotcode-logo.svg)
810

911
This workshop covers installation, setup, project structuring, python project managers, `robot.toml` configuration, key features, utilizing CLI tools, integrating CI/CD processes, and collaborating with distributed teams.
1012

@@ -16,41 +18,241 @@ Participants will gain hands-on experience and learn best practices to enhance t
1618

1719
## Key Topics
1820

19-
1. Installation of RobotCode:
21+
1. **Installation of RobotCode:**
2022
- Step-by-step guide to installing the RobotCode Extension and CLI tools.
23+
- Install the VSCode extension and create your python `.venv`.
2124

22-
2. Project Setup with RobotCode:
25+
2. **Project Setup with RobotCode:**
2326
- Creating a new example project.
27+
- Create virtual python environments to separate system interpreter and development venv.
28+
- This helps with different projects regarding different dependencies.
29+
- Separation of projects.
30+
- Creating a `requirements.txt` with all project dependencies.
31+
- Put the project's dependencies into it.
32+
- `robotframework-tidy` helps with linting your project.
33+
- `Developer: Reload Window` after installing `.venv` for RobotCode to get the new environment.
34+
- `Log` vs. `Log To Console`
35+
- Log is preferred as you have everything in one place (Debug Console).
2436
- Configuring the project environment and RobotCode settings.
37+
- Debug Settings:
38+
- `Debug: Group Output` helps with more debug information
39+
- `"robotcode.debug.groupOutput": true,`
40+
- `Debug: Output Timestamps` shows you the execution timestamps
41+
- `"robotcode.debug.outputTimestamps": true`
42+
- Put the Debug Settings in the `.vscode/settings.json` for local settings.
43+
- Comment in the settings for overwriting them quickly.
44+
- `"robotcode.run.openOutputAfterRun": "log"` if you want to auto open the log/report after each run.
45+
- Debug Python Code:
46+
- `"robotcode.debug.attachPython": true`
47+
- Devcontainer:
48+
- Helps with creating a standardized environment with fixed versions for testers/developers to have the same environment.
49+
- Make ports public if you want to display `log.html` and it does not work out of the box.
50+
- Debugging Tips:
51+
- Use Variable Scopes.
52+
- Change Variable Values in the debug menu by overwriting them.
53+
- In the Debug Console, you can use Robot Framework Keywords from Commandline.
54+
- In Debug watches, you can add expressions.
55+
- `#exprmode` enables/disables python expression mode (toggle).
56+
- Use the breakpoint toggles to enable different breakpoint modes.
57+
- Features:
58+
- Find Library Keywords by typing `LibraryName` + `.` and scroll the keywords.
59+
- Variables are sorted by the distance in autocompletion.
60+
- Local scope is closest, then Suite scope, then global scope.
61+
- Explorer View:
62+
- Select `Keywords` Dropdown.
63+
- View Keyword-Documentation.
64+
- Insert Keywords or Drag & Drop them.
65+
- Search within Library-Keywords (F3).
66+
- Debug Logs:
67+
- RobotCode Log: Logging of RobotCode Details.
68+
- RobotCode Language Server Log: Logging of Language Server Details.
69+
- Helps with your own debugging or reporting issues with detailed information.
2570
- Structuring the project for scalability and maintainability.
71+
- Simple Projects:
72+
- Create a `/resources` directory with `*.resource` files for Robot Framework Keywords.
73+
- This will add `/resources` to the PYTHON_PATH.
74+
- Create a `/lib` directory with `*.py` files for python keywords.
75+
- This will add `/lib` to the PYTHON_PATH.
76+
- This way you can add `.resource` and `.py` keyword files **without** using the absolute file path.
77+
- When using different folder names/structures for your project, you need to add the folder paths to your PYTHON_PATH for usage without the full directory path.
78+
- TIP: Use `settings.json` for your personal local changes and do not commit to your Git-Repo!
79+
- These settings are for your personal preference.
80+
- Enable/Disable "RobotCode Play Buttons" -> Settings-RobotCode-Test Explorer-Enable/Disable.
2681
- Using Python project managers for efficient dependency management.
82+
- Project managers help you with:
83+
- Managing dependencies.
84+
- Managing execution and development environments.
85+
- Creating virtual environments.
86+
- EXAMPLE: [hatch](https://hatch.pypa.io/latest/)
87+
- Follows the PEP standard.
88+
- Gives you the opportunity to create test matrices to e.g. run multiple virtual environments in parallel.
2789
- Best practices in project setup and organization.
90+
- Use a python package manager to organize your project and set it up in a standardized way.
91+
- Integrate [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for versioning your project and automatically create a `Changelog.md`.
2892

29-
3. Exploring RobotCode Features:
93+
3. **Exploring RobotCode Features:**
3094
- Overview of general features that enhance productivity.
95+
- RobotFramework Notebook:
96+
- File -> New File -> RobotFramework Notebook.
97+
- First Version included in VSCode supporting `*.robot` Files and Markdown.
98+
- Uses the REPL, so there are no `*** Settings ***` or `*** Variables ***` sections.
99+
- Helping with Business Analyst Files such as RPA procedures.
100+
- Robotcode REPL (Read-Evaluate-Print-Loop):
101+
- Install (if not yet): `pip install robotcode-repl`.
102+
- In CLI: use `robotcode repl`.
103+
- Type Keywords and Expressions that are directly evaluated.
31104
- Introduction to new and advanced features.
32105

33-
4. Using `robot.toml` Configuration:
106+
4. **Using `robot.toml` Configuration:**
34107
- Understanding general configuration settings.
108+
- `robot.toml` supports all possible configurations from [toml.io](https://toml.io/en/).
109+
- Helps with interaction towards Robot Framework through its CLI API.
110+
- **Every** CLI argument from Robot Framework has a configuration analog in `robot.toml`.
111+
- There are different ways of defining values in the toml file.
35112
- Creating configuration profiles for different environments.
113+
- `robotcode config files` shows you all the `robot.toml` configuration files.
114+
- `robot.toml` files exist for the user space and project space.
115+
- Settings in the project space overwrite user space and local space overwrites project space.
116+
- All configurations for Python = `pyproject.toml`.
117+
- All configurations for Robot Framework = `robot.toml`.
118+
- Local Configuration for overwriting `robot.toml` = `.robot.toml`.
119+
- This file is not meant to be pushed to Git.
120+
- Hierarchy of the files:
121+
- Default user space.
122+
- Project space.
123+
- Local space.
124+
- `robotcode config root` gives you the root directory, which is dependent on the position of the `robot.toml` file.
125+
- `robotcode config info` gives you information on the config files.
126+
- `robotcode profiles show` shows you the configuration with your selected profiles.
127+
- Run Robot Framework files with specific profiles: `robotcode -p profile_a -p profile_b robot`.
128+
- `[variables]` at the root level of the `robot.toml` file are used by all profiles.
129+
- EXCEPT: using profiles with `[profiles.profile_a.variables]`.
130+
- All variables in here are specific to the profile and ignore the root-level `[variables]`.
131+
- When using `[profiles.profile_a.extend-variables]` the root-level variables are extended, meaning:
132+
- Root-level existing variables are replaced, if specified again.
133+
- Root-level existing variables are taken into the profile, if not again specified.
134+
- Profile-specific variables are included as well.
135+
- `robotcode debug`.
136+
- `robotcode analyze` is a static code analyzer for your project.
137+
- Analyzer Errors, Warnings, and Hints can be ignored by commenting `# robotcode: ignore[KeywordNotFound]`.
138+
- This ignoring is indentation dependent!!
139+
- Resetting the settings can be done by `robotcode: reset[KeywordNotFound]`.
140+
- Configure within `robot.toml`:
141+
142+
```toml
143+
[tool.robotcode-analyze.modifiers]
144+
ignore=[KeywordNotFound]
145+
```
146+
36147
- Splitting configuration into multiple files for modularity.
37148

38-
5. Command Line Interface (CLI) Tools:
149+
5. **Command Line Interface (CLI) Tools:**
39150
- Retrieving valuable information about your project.
151+
- `robotcode` will give you all commands with descriptions.
152+
- `robotcode discover` will give information about Suites, Test Cases.
153+
- `robotcode discover all .` to look for whole project information.
154+
- Filter test cases with robot options.
155+
- e.g `include/exclude` tags etc.
156+
- `--format` Option for printing results in a wanted format e.g. json for reuse in different projects.
157+
- Excludes all files that are ignored within [.gitignore](http://_vscodecontentref_/0).
158+
- Alternative: create `.robotignore` for excluding it from `robotcode discover` and speed up the discovery process or exclude local files for personal usage.
40159
- Analyzing your project to identify improvements.
160+
- `robotcode analyze`.
41161
- Running tests directly from the command line.
42162
- Implementing git hooks to streamline your development workflow.
43163
- Best practices for effective CLI usage.
44164

45-
6. Integrating CI/CD Processes:
165+
6. **Integrating CI/CD Processes:**
46166
- Executing tests within a CI/CD pipeline.
167+
- Use `robot.toml` profiles to run CI settings on a local machine.
168+
- Ensure the CI process is low in complexity and mimics the steps done on the local machine as closely as possible.
47169
- Debugging test runs in CI/CD environments.
48170
- Best practices for continuous integration and deployment.
171+
- Keep the CI pipeline simple and maintainable.
172+
- Use the same `robot.toml` profiles for both local and CI environments to ensure consistency.
173+
- Automate as much as possible to reduce manual intervention and errors.
49174

50-
7. Collaborating with Distributed Teams:
175+
7. **Collaborating with Distributed Teams:**
51176
- Structuring and packaging Robot Framework projects for team collaboration.
52177
- Sharing and utilizing resources and libraries across multiple teams and projects.
53178
- Best practices for working in distributed development environments.
179+
- Step-by-step guide on building your resource files from `src/demo` via Hatch to create a `.wheel` file:
180+
1. Ensure you have Hatch installed:
181+
182+
```sh
183+
pip install hatch
184+
```
185+
186+
2. Navigate to your project directory:
187+
188+
```sh
189+
cd /path/to/your/project
190+
```
191+
192+
3. Create a `pyproject.toml` file in the root of your project with the following content:
193+
194+
```toml
195+
[build-system]
196+
requires = ["hatchling"]
197+
build-backend = "hatchling.build"
198+
199+
[project]
200+
name = "your_project_name"
201+
version = "0.1.0"
202+
description = "Your project description"
203+
readme = "README.md"
204+
requires-python = ">=3.7"
205+
license = {text = "MIT"}
206+
207+
[tool.hatch.build.targets.wheel]
208+
packages = ["src/demo"]
209+
```
210+
211+
4. Build the `.wheel` file:
212+
213+
```sh
214+
hatch build
215+
```
216+
217+
5. The `.wheel` file will be created in the `dist` directory. This file can then be uploaded to any package registry or distributed to other teams in different ways.
218+
- Integrate this process into the CI pipeline, e.g., with every new release:
219+
- Add the following steps to your CI configuration:
220+
221+
```yaml
222+
jobs:
223+
build:
224+
runs-on: ubuntu-latest
225+
steps:
226+
- uses: actions/checkout@v2
227+
- name: Set up Python
228+
uses: actions/setup-python@v2
229+
with:
230+
python-version: '3.x'
231+
- name: Install Hatch
232+
run: pip install hatch
233+
- name: Build wheel
234+
run: hatch build
235+
- name: Upload wheel to registry
236+
run: |
237+
twine upload dist/*.whl
238+
```
239+
240+
- Commands for participants to try the distribution with Hatch themselves:
241+
242+
1. Navigate to your project directory:
243+
244+
```sh
245+
cd /path/to/your/project
246+
```
247+
248+
2. Create a `pyproject.toml` file as described above.
249+
3. Build the `.wheel` file:
250+
251+
```sh
252+
hatch build
253+
```
254+
255+
4. Distribute the `.wheel` file as needed.
54256

55257
## Who Should Attend
56258

@@ -60,7 +262,7 @@ Participants will gain hands-on experience and learn best practices to enhance t
60262

61263
## Methodology
62264

63-
The workshop combines lectures, live demonstrations, and hands-on exercises.
265+
The workshop combines lectures, live demonstrations, and hands-on exercises.
64266

65267
## Prerequisites
66268

demo/tests/01_simple/test.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Test Print
1313
Test Return
1414
[Documentation] Print from mylib.py
1515
${str} Return Something
16-
Log To Console ${str}
16+
Log ${str}
1717

1818
Test Resource
1919
[Documentation] Print from myrsc.resource

0 commit comments

Comments
 (0)