Fork me on GitHub
#leiningen
<
2019-02-01
>
andrea.crotti09:02:21

I noticed something quite strange

andrea.crotti09:02:18

I've added another profile :circleci [:test {:env {:environment "circleci"}}] to simply override on env varialble in the profile circleci, and this never picks it up: lein with-profile circleci test and keeps on thinking that you passed the test profile

andrea.crotti09:02:40

however lein with-profile circleci db migrate for example works perfectly fine and picks up my change

andrea.crotti09:02:55

is there something special about the test command?

mikerod14:02:52

@andrea.crotti not 100% I follow what you’re trying but perhaps try doing lein with-profile +circleci test

mikerod14:02:24

Although I don’t have a strong reason to suspect that’s the problem if you are just thinking the :test profile isn’t loading or something.

mikerod14:02:00

You can play around with lein with-profile circleci pprint as well I believe to see things perhaps clearer

andrea.crotti14:02:17

I tried +circleci and it's the same

andrea.crotti14:02:36

@mikerod lein with-profile works with any command, but not with test

andrea.crotti14:02:46

which seems to force loading just the test profile

mikerod14:02:09

That shouldn’t be the case.

mikerod14:02:48

Seems strange to me. Unless it is loading test profile over your composite profile.

mikerod15:02:10

So undoing the override you are attempting

mikerod15:02:37

You can try pulling whatever environment stuff you want to alter out to a separate profile. And refer to that in circleci and if you want a default test to include it, just add it with a with-profile (can alias to make it less typing)

andrea.crotti15:02:17

ok it is loading the circleci profile as well

andrea.crotti15:02:26

but it's not overriding an :env variable

andrea.crotti15:02:35

so if I create .new env variable that's picked up

andrea.crotti15:02:23

and with +circleci it's the same, so I guess overriding env variables just doesn't work

andrea.crotti15:02:37

which probably makes sense I just have to find another way

mikerod15:02:37

So my thought is that you have a composite profile test+circleci and it may work fine on its own

mikerod15:02:57

But during the test tasks, lein is adding test profile to whatever else you specify

mikerod15:02:18

So you get test+circleci, test

andrea.crotti15:02:42

yes but the content of :env is not merged the way I thought it would

mikerod15:02:55

So the merge is being merged over.

andrea.crotti15:02:57

new config goes there but existing config doensn't get overridden

mikerod15:02:08

But if you have bigger problems with merging. That’s a separate issue. Hah

andrea.crotti15:02:08

I already found another way though

andrea.crotti15:02:10

so not a big deal

mikerod15:02:09

Just FYI most profile data in lein is merged just via a generic merging fn it has. Maps merge mostly the same as clj merge, but certain collection types have special merge-with semantics. Like vectors (sequentials ? I think) are concatenated and maps are “deep” merged I think. I can’t remember exactly without looking though.

mikerod15:02:52

You can use metadata like ^:replace on certain structures to influence this merging behavior too.