robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[ENHANCEMENT, `robot.toml`] Make `no-status-rc` accept conditions (like `enabled` does)

Open Noordsestern opened this issue 7 months ago • 3 comments

Gude!

I have a profile that I'd like to active in CI environment:

[profiles.ci]
enabled = { if = "environ.get('CI') == 'true'" }
no-status-rc = { if = "environ.get('CI_COMMIT_REF_NAME') == 'main'" }

The profile is automatically enabled when the environment variable CI is set. Which is awesome. Now depending on the branch ci is working on, want the status-rc to be returned or not.

Now, I can duplicate the CI-job, but it would be very convenient when boolean configurtions (like no-status-rc) would accept conditions just like enabled.

Background: feature branches must fail an be reviewed before being merged. Test runs on main must not fail the pipeline, as their results are reported in test reporting tool.

Regards

Noordsestern avatar Jul 31 '25 11:07 Noordsestern

Yes, I can see that I need to make a plan for whether to implement this as a Condition or as a BoolExpression, since it's a flag and can also have the values ON, OFF, DEFAULT.

What do you mean by duplicating the CI job?

I think something like this could also work:

[profiles.ci-main]
enabled = { if = "environ.get('CI') == 'true' and environ.get('CI_COMMIT_REF_NAME') == 'main'" }
no-status-rc = true

[profiles.ci-branch]
enabled = { if = "environ.get('CI') == 'true' and environ.get('CI_COMMIT_REF_NAME') != 'main'" }
no-status-rc = false

d-biehl avatar Jul 31 '25 11:07 d-biehl

Just had a similar idea after i had posted about duplicating the job 😬

#######
# CI related profiles
#######

[profiles.ci]
enabled = { if = "environ.get('CI', False)" }
inherits = ["headless", "only-on-main", "never-on-main"]

[profiles.only-on-main]
hidden=true
enabled = { if = "environ.get('CI_COMMIT_REF_NAME') == 'main'" }
no-status-rc = true

[profiles.never-on-main]
hidden=true
enabled = { if = "environ.get('CI_COMMIT_REF_NAME') != 'main'" }
no-status-rc = false

What I did not take in to account is that I still have to provide ci on commandline. I had expected the enabled properties being evaluated automatically.

So above config works when executing robotcode -p ci ...... in pipeline. It automatically detects which one of the other 2 profiles must be enabled.

Noordsestern avatar Jul 31 '25 12:07 Noordsestern

You have to use the default-profiles setting.

https://robotcode.io/03_reference/config#default-profiles

d-biehl avatar Jul 31 '25 18:07 d-biehl