Skip to content

Commit

Permalink
Big overhaul after RoboCon
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmackaij committed May 26, 2022
1 parent a3d8c82 commit cd9db9a
Show file tree
Hide file tree
Showing 29 changed files with 526 additions and 838 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ dist/
.vscode

# log files
/logs
logs
17 changes: 13 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This repo demonstrates how poetry can be used to distribute Robot Framework reso
The cornerstone for `poetry` is the `pyproject.toml` file.
This file holds the information needed to ensure a suitable Python version is used when creating the virtual environment for the repo, which dependencies should be installed in that virtual environment, etc.
It also provides the information needed when you want to build and distribute the code in the repo; things like the version number, the author(s) and / or maintainers, a description of the project, etc.
> The install instructions for poetry can be found [here](https://python-poetry.org/docs/master/#installation)
## A minimal `pyproject.toml` file
Let's take a look at a (close to) minimal `pyproject.toml` file:
Expand Down Expand Up @@ -40,6 +41,10 @@ The `packages`, like `version`, may not be used but it is required and it's a go
In this example, the `src` (short for source) folder holds the `RobotFrameworkResources` package to be included in the distribution.
But even if you don't need to distribute your project, it's a good idea to have a folder at the root of the repo that makes it clear where the main content of your repo can be found to separate that from supporting files such as configuration files (e.g. `pyproject.toml` and `poetry.lock`) and documentation (e.g. `README.md`).

> Note that this repo does not use a `src` folder but instead demonstrates three different ways of how you could structure your repo.
> The `flat` structure is the most basic, while `nested` and `split` are increasingly complex.
> Refer to the `pyproject.toml` of the repo to see how to include these different ways of organizing the project into a distribution.
The `include` is not part of a minimum `pyproject.toml` configuration but I've included it here since we'll need to define it if we want to make a Robot Framework Resource distribution.
By default only Python files (e.g. `.py` and related extensions) are included when building a distribution.
To include files with other extensions, such as `.resource` or `.robot`, we need to specify them.
Expand Down Expand Up @@ -109,13 +114,15 @@ If the repo being published is a private repo, only those with access to the rep
After a Robot Framework resource package how been published and added to a repo, its Keywords and / or Variables can be used by importing them in the `*** Settings ***`:
```robotframework
*** Settings ***
Resource RobotFrameworkResources/keywords/Web.resource
Resource Flat/Keywords.resource
*** Test Cases ***
Can open website
Open main site
Can Get Url
${url}= Get Main Site Url
```
In this example project, `/keywords/Web.resource` imports `/variables/Urls.resource` so the variables in `Urls.resource` are also available.
In this example project, `Keywords.resource` imports `Variables.resource` so the variables are also available.

> For examples for the different repo structures, refer to the test suites in the `tests` folder.
## The `[tool.poetry.dev-dependencies]` section and `invoke`
In addition to the `[tool.poetry.dependencies]` section, `poetry` also supports the `[tool.poetry.dev-dependencies]` section that can be used to define which supporting packages can (or should) be used when working on the project.
Expand Down Expand Up @@ -173,3 +180,5 @@ poetry run robot --variable ROOT:${WORKSPACE} ${WORKSPACE}/Suites/
```
> The `--removed-untracked` flag is mostly a precaution.
This will remove all packages from the (virtual) environment that are not in the `poetry.lock` file.

----
7 changes: 7 additions & 0 deletions flat/Flat/Keywords.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*** Settings ***
Resource ./Variables.resource


*** Keywords ***
Get Main Site Url
RETURN ${MAIN_URL}
2 changes: 2 additions & 0 deletions flat/Flat/Variables.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*** Variables ***
${MAIN_URL}= https://robotframework.org/
File renamed without changes.
7 changes: 7 additions & 0 deletions nested/Nested/Keywords/API.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*** Settings ***
Resource Nested/Variables/Global.resource


*** Keywords ***
Get Robot Framework Icon Url
RETURN ${ICON_URL}
7 changes: 7 additions & 0 deletions nested/Nested/Keywords/Web.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*** Settings ***
Resource Nested/Variables/Global.resource


*** Keywords ***
Get Poetry Talk Url
RETURN ${POETRY_TALK_URL}
3 changes: 3 additions & 0 deletions nested/Nested/Variables/Global.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*** Variables ***
${ICON_URL} https://robocon.io/dist/img/RF-white.svg
${POETRY_TALK_URL} https://robocon.io/?talk=project-and-package-management-poetry-for-robots
File renamed without changes.
Loading

0 comments on commit cd9db9a

Please sign in to comment.