Skip to content
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

Allow env file with "bazel test" #955

Open
pgr0ss opened this issue Feb 22, 2016 · 18 comments
Open

Allow env file with "bazel test" #955

pgr0ss opened this issue Feb 22, 2016 · 18 comments
Labels
help wanted Someone outside the Bazel team could own this not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request

Comments

@pgr0ss
Copy link
Contributor

pgr0ss commented Feb 22, 2016

Currently, you can pass environment variables one at a time with --test_env. It would be nice to be able to pass an entire file of env variables to bazel test with something like:

bazel test --test_env_file=.env //...

env are becoming semi-standard, and lots of tools understand how to read them. For example:

This improvement would allow people to use their existing env files with bazel.

@philwo philwo added type: feature request P2 We'll consider working on this in future. (Assignee optional) labels Feb 26, 2016
@philwo
Copy link
Member

philwo commented Feb 26, 2016

I think this sounds like a nice feature request. It would probably have to be implemented in StandaloneTestStrategy.

@ulfjack Do you think this is reasonable? If yes, I'd like to assign this to @hermione521 or @meteorcloudy.

@ulfjack
Copy link
Contributor

ulfjack commented Feb 26, 2016

What features does .env support? What charset does it use? Does it require unescaping (i.e., can you escape newline characters)?

@pgr0ss
Copy link
Contributor Author

pgr0ss commented Feb 26, 2016

@ulfjack I'm not sure if your questions are targeted at me, but I'll do my best.

What features does .env support?

I don't understand the question. If you are asking about bazel features, I think it's reasonable to accept it wherever you accept --test_env. If you are asking why it's necessary at all, I would like to use the same .env file for bazel as for my other tools, rather than having to write out separate --test_env commands for each variable. It's becoming increasingly common to rely on environment variables for configuration (e.g. http://12factor.net/config).

What charset does it use?

I'm not sure. I would guess it's generally tool specific. Or maybe UTF-8?

Does it require unescaping (i.e., can you escape newline characters)?

Does --test-env support it? We could probably use the same logic?

@ulfjack
Copy link
Contributor

ulfjack commented Feb 29, 2016

What's the format of an .env file?

@pgr0ss
Copy link
Contributor Author

pgr0ss commented Feb 29, 2016

@ulfjack They look like:

VAR1=foo
VAR2=bar

In general, it's the same format as if it were shell commands so you can source the file.

@ulfjack
Copy link
Contributor

ulfjack commented Mar 1, 2016

Ok, that sounds reasonable.

@philwo It will be a bit tricky to support this with our internal remote build system, though.

@damienmg damienmg modified the milestone: 0.6 Jun 14, 2016
@damienmg damienmg modified the milestones: 1.0, 0.6 Jul 25, 2017
@Globegitter
Copy link

I think that would be great to not just to have --test_env_file= but also --action_env_file=.

@dollith
Copy link

dollith commented May 14, 2018

Truly awesome feature if implemented!

@meisterT meisterT removed this from the 1.0 milestone May 12, 2020
@aiuto aiuto added help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team and removed P2 We'll consider working on this in future. (Assignee optional) category: misc > testing help wanted Someone outside the Bazel team could own this labels May 14, 2020
@aiuto
Copy link
Contributor

aiuto commented May 14, 2020

We don't have a team for "all execution" so I am assigning to both Exec teams.
I lowered the priority because no one is actively working on this. The first step would be an explicit design for this.

@kamok
Copy link

kamok commented Mar 16, 2021

So as of now, we're still unable to pass in and .env files into bazel test right?

@GeorgeWillaman
Copy link

Any updates on this, or is it still help wanted?

@ShreeM01 ShreeM01 added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 16, 2023
@ShreeM01
Copy link
Contributor

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@ShreeM01 ShreeM01 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
@peakschris
Copy link

Can this be reopened? It would be a very useful feature.

@ShreeM01 ShreeM01 reopened this Apr 2, 2023
@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Apr 3, 2023
Copy link

github-actions bot commented Jun 7, 2024

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 7, 2024
@peakschris
Copy link

not stale

@brentleyjones brentleyjones added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels Jun 7, 2024
@meisterT meisterT added untriaged team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team labels Jun 13, 2024
@liushuai05
Copy link

liushuai05 commented Sep 6, 2024

Excuse me, what progress has been made with this feature? My project uses golang's goravel framework. This framework must use the.env file. I tried to use --action_env and --test_env to add parameters, but it seems that it does not work properly in this framework

@meteorcloudy meteorcloudy added help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Sep 9, 2024
@meteorcloudy
Copy link
Member

Unfortunately, the Bazel team doesn't have capacity to implement this feature. If anyone from the community wants to contribute, a PR will be very welcomed!

@liushuai05
Copy link

Unfortunately, the Bazel team doesn't have capacity to implement this feature. If anyone from the community wants to contribute, a PR will be very welcomed!

非常感谢能收到您的回复,我这边已经得到解决了,我采用的方案是使用export将env文件中的内容加载到Linux环境变量中 然后再进行go run 幸运的是我使用的框架支持环境变量替代env文件使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Someone outside the Bazel team could own this not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request
Projects
None yet
Development

No branches or pull requests