Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Configuration file support #5337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pekkaklarck opened this issue Feb 11, 2025 · 5 comments
Open

Configuration file support #5337

pekkaklarck opened this issue Feb 11, 2025 · 5 comments

Comments

@pekkaklarck
Copy link
Member

pekkaklarck commented Feb 11, 2025

Robot Framework should get support for configuration files. Configuration files should be loaded automatically (unless disabled) and allow specifying same settings that can be given from the command line. This would make it possible to, for example, to automatically enable the RPA mode, specify listeners that should always be used, and so on. This would be especially useful with features that require more complex configuration such as custom settings (#4409).

The main reason Robot currently doesn't support configuration files is that it has its own argument file concept that has many of the same benefits. Argument files aren't loaded automatically, though, and them being a Robot-only solution means that you cannot have all project configuration in one place.

Although the basic idea is clear, there are lot of design decisions to be made:

  1. What format? Python has pretty much standardized to TOML as configuration syntax and I rather strongly believe we should use that too. tomllib is only available starting from Python 3.11, but we can require people using older Python versions to install a backport if they want to use config files.
  2. Should we support the standard pyproject.toml or a custom robot.toml? I believe we should support both. Actual settings should also be exactly the same regardless the file, but the top level table structure is naturally different.
  3. Where should we look for configuration files? My understanding is that pyproject.toml should be only looked from the current directory, but with our robot.toml it would probably make sense to support system wide, user wide, project wide, and custom configuration so that the latter ones have precedence over earlier ones. System wide and user wide configs would be loaded from an OS specific configuration file locations, project wide configuration from the current directory, and custom configs could be given using a command like option like --config path/to/custom.toml. There should also be a way to disable loading configuration files automatically.
  4. How should each command line option be supported in a configuration file? It's probably best to return to this when implementation starts. This is an important topic, because making changes later causes backwards compatibility problems.
@rinatagishev
Copy link

What is this configuration for?
tests filtering?
variables setting or referencing variables file?
binding other configs, including configs based on existing variables?

@LucianCrainic
Copy link
Contributor

Hello @pekkaklarck any updates on this ? Will there be a toml / yaml file for configuration settings ? What purpose will it serve ?

@pekkaklarck
Copy link
Member Author

I finally updated the description so hopefully it now answers your questions @rinatagishev and @LucianCrainic.

While updating the description I realized now many design decisions there are to be made and how much getting all this implemented does. In addition to the support for finding and loading configuration files, we need to integrate it with the current code for parsing command line options and handling settings internally. Unfortunately most of the current code is pretty bad, and I believe we should rewrite it as part of this project. That allows us to design this properly, but it also increases the development effort.

My current thinking is that this is so big task that it's better to move it to RF 8.0 scope. Doing this in a major release would also help a little if we needed to make some backwards incompatible changes. If you feel that this should be implemented earlier, please comment this issue. In that case you need to be prepared to help with the design and implementation work, though.

@Noordsestern
Copy link
Member

Not sure if you are aware:

Robotcode introduced robot.toml more than a year ago and the configs are pretty well used. It even supports execution profiles and IDE integration of the configs: https://robotcode.io/01_about/#configure-your-robot-framework-environment-with-robot-toml

Maybe, the efforts could be less when adopting the approach of Robotcode. That would save design and implementation efforts.

Until then, users can already use configuration files by utilizing Robotcode.

@jyligehc
Copy link

jyligehc commented Apr 7, 2025

Hi Pekka,
This feature sounds a good idea.

Your point 3 sounds good and, in fact, it pretty much follows what is being done in invoke (tool also being used in Robot development process).

https://docs.pyinvoke.org/en/stable/concepts/configuration.html#config-hierarchy
Points 3-7 in the documentation.

In point 5 the configuration could come from pyproject.toml if robot.toml is not found.
It could try to search these from the current directory and its parent directories.

I also think that while configuration is being processed it would be quite easy to handle environment variables and including them as one source of configuration as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants