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

Add BUILD_TARGET environment variable to all build actions #11216

Closed
Qinusty opened this issue Apr 24, 2020 · 3 comments
Closed

Add BUILD_TARGET environment variable to all build actions #11216

Qinusty opened this issue Apr 24, 2020 · 3 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request

Comments

@Qinusty
Copy link
Contributor

Qinusty commented Apr 24, 2020

Description of the feature request:

Currently bazel adds TEST_TARGET as an environment variable to all test actions which is great for tracking down targets causing failures within actions executed remotely. Tracking down the related target for a failed build action is much harder.

Feature requests: what underlying problem are you trying to solve with this feature?

It is currently quite awkward to trace a failed build action back to the target which created it.

Have you found anything relevant by searching the web?

The test-encyclopedia details TEST_TARGET but I haven't found anything for other actions.

@aiuto aiuto added type: documentation (cleanup) team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team untriaged and removed type: documentation (cleanup) labels Apr 24, 2020
@jmmv jmmv added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc and removed team-Local-Exec Issues and PRs for the Execution (Local) team team-Remote-Exec Issues and PRs for the Execution (Remote) team labels May 14, 2020
@janakdr
Copy link
Contributor

janakdr commented Sep 17, 2020

Could you expand a bit on the use case here? Within a Bazel invocation, Bazel should print out enough information to identify the failing rule. This is for the case of debugging failed actions on the remote execution server?

I don't think that currently build actions have any environment variables set, so this would be a completely new thing. I think that a two-line hacky change to AbstractAction to set env to

    this.env = env.addFixedVariables(ImmutableMap.of("BUILD_TARGET", getPrimaryOutput().getExecPathString()));

would work. This seems to work for genrules and Starlark, but not for tests, which is maybe fine. I'm open to a PR implementing this, but we will have to think about how to limit this: I think we'd only want a very few such variables. Note that we could easily bork remote caching if we weren't careful.

As a current workaround, if the relevant rules are Starlark, you could manually add the action label to the command line, perhaps?

@janakdr janakdr added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Sep 17, 2020
@github-actions
Copy link

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 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 26, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants