micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

Do not set CLOUD environment for GitHub runners and/or any test environment

Open musketyr opened this issue 3 years ago • 5 comments

Feature description

We are starting to experiment with self-hosted GitHub runners and some tests are starting to fail because when running tests on GitHub Runners are hosts on EC2 therefore the CLOUD environment is deduced. From my point of view it would make sense not to deduce the additional environments within tests.

To get you into context, we are a having a couple of test/local implementations which are using @Requires(env = Environment.CLOUD) not to leak into production.

musketyr avatar Jul 27 '22 10:07 musketyr

So are you expecting Micronaut to detect that it's running on a "CI environment", in which case, it won't set the CLOUD environment?

How would we detect that an application is running "on GitHub runners and/or any test environment"? Seems a scope too broad.

alvarosanchez avatar Jul 27 '22 17:07 alvarosanchez

Indeed. I guess the most simplistic solution would be not to deduce additional environments once test environment is detected. At least the cloud ones.

musketyr avatar Jul 27 '22 17:07 musketyr

You can disable it using deduceEnvironment: Micronaut.build().deduceEnvironment(false).run(). I think we are going to remove automatic deduction in V4.

dstepanov avatar Jul 28 '22 07:07 dstepanov

thank you @dstepanov! is there something I can do for @MicronautTest test cases?

musketyr avatar Jul 28 '22 07:07 musketyr

Ah right, you have a test... The other way would be to disable it using a system property

dstepanov avatar Jul 28 '22 08:07 dstepanov