Skip to content

bazel: Add @envoy_repo target with VERSION AND PATH#17293

Merged
lizan merged 4 commits intoenvoyproxy:mainfrom
phlax:bazel-versions
Sep 14, 2021
Merged

bazel: Add @envoy_repo target with VERSION AND PATH#17293
lizan merged 4 commits intoenvoyproxy:mainfrom
phlax:bazel-versions

Conversation

@phlax
Copy link
Copy Markdown
Member

@phlax phlax commented Jul 12, 2021

Signed-off-by: Ryan Northey ryan@synca.io

Commit Message: bazel: Add versions.bzl
Additional Description:

this allows the version to be used in bazel rules in ways that the normal VERSION file cannot

Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

@phlax phlax changed the title [WIP] bazel: Add versions.bzl bazel: Add versions.bzl Jul 12, 2021
@phlax phlax marked this pull request as ready for review July 12, 2021 13:57
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Jul 12, 2021

cc @htuch

@phlax phlax requested a review from htuch July 12, 2021 13:57
@github-actions
Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Aug 24, 2021
@phlax phlax added no stalebot Disables stalebot from closing an issue and removed stale stalebot believes this issue/PR has not been touched recently labels Aug 24, 2021
@phlax phlax force-pushed the bazel-versions branch 3 times, most recently from 83769ea to 248f814 Compare September 5, 2021 06:28
@phlax phlax changed the title bazel: Add versions.bzl bazel: Add @envoy_repo target with VERSION AND PATH Sep 5, 2021
@phlax
Copy link
Copy Markdown
Member Author

phlax commented Sep 5, 2021

@lizan @htuch this is a second attempt at resolving this, and, as suggested, uses a repository_rule

it also adds a PATH variable, which is only useful for local tasks, but means we can set up jobs like code_formatting without needing to pass the (absolute) path to the repo. Its also useful for generating data from bazel queries, as genquery is pretty constrained (no recursion, limited syntax)

@phlax phlax force-pushed the bazel-versions branch 2 times, most recently from 8b2a963 to 49e6d7f Compare September 5, 2021 10:29
@phlax phlax removed the no stalebot Disables stalebot from closing an issue label Sep 5, 2021
Signed-off-by: Ryan Northey <ryan@synca.io>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will defer to @lizan for review and merge.

bazel/repo.bzl Outdated
```starlark

load("@envoy_repo//:version.bzl", "VERSION")
load("@envoy_repo//:path.bzl", "PATH")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you plan to use this for? I'm afraid this is an anti-pattern because wherever you pull this in rules/targets it invalidates cache across different builds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for tooling such as code_format where it needs to run across the whole repo, or where it needs to make bazel queries which imply access to the repo (ie not genqueriable)

i get that using the path in bazel is a bit of an anti-pattern, not least because its only relevant to the local machine, but we have quite a few rules that rely on having access to the repo, and currently that has to be passed around (as an absolute url), so i think from a pattern pov this would be preferable to what we do now

im not sure if iiuc the point about invalidating caches, but i dont think running dep check or code formatting tools is going to have any negative lateral effects, and afaict using this with them everything is cached correctly

Copy link
Copy Markdown
Member Author

@phlax phlax Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as an example - here is some WIP code to run a bazel query from other tools:

https://github.com/envoyproxy/envoy/pull/17992/files#diff-7a7d58af3edfdbe7825cd20fb6a29494ae293d40fe25e2b9774a4aac8ee27dcfR22-R30

the tools updated in the linked PR dont currently use bazel - ie they are currently run as scripts

if i shift them to bazel then, like with several others, we need to add a path to be able to run the bazel queries

the tools that need a path are a pita to run as you always have to type ${PWD} in addtion to any args, and it increases their code/complexity having to handle the path arg. This would eliminate that for these cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps i could add something to the comment to clarify any situations where there are some adverse effect from using the PATH other than for rbe

Copy link
Copy Markdown
Member

@lizan lizan Sep 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is this should not be exported in a .bzl file as Starlark, for the tooling we only need the py_library?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to understand further what you might mean here.

im wondering if you mean we dont need the ".bzl" part for the PATH, but we could keep the python part and only expose it to python targets

as im working mostly with python that would wfm

ill update with this change and then hopefully (if that was your meaning) we can get this landed today

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered the trick we do in

descriptor_path = r.Rlocation(
?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that gives the path within the sandbox, not the repo, iiuc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i see, you can get the file path from the symlink that way

tbh, i think this is much more explicit - retrieving the repo metadata will be possible with the @envoy_repo target - which can provide version as well as path

see https://github.com/envoyproxy/envoy/pull/18021/files#diff-615ebb7b91831a9c7da2a3835e8b7c1ef89c9d2e72777cc229e128f6c8229214R51 and https://github.com/envoyproxy/envoy/pull/18021/files#diff-7a7d58af3edfdbe7825cd20fb6a29494ae293d40fe25e2b9774a4aac8ee27dcfR22 for an example

possibly the envoy_repo namespace can also provide data mappings as in #17998

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of @envoy_repo for things like version, I just wonder if we can pair it back to that and we don't need to do path this way.

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #17293 was synchronize by phlax.

see: more, trace.

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Sep 7, 2021
@phlax phlax force-pushed the bazel-versions branch 2 times, most recently from 4c1b176 to d1b7cf4 Compare September 7, 2021 10:25
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 10, 2021

/lgtm deps

@repokitteh-read-only repokitteh-read-only bot removed the deps Approval required for changes to Envoy's external dependencies label Sep 10, 2021
@htuch
Copy link
Copy Markdown
Member

htuch commented Sep 10, 2021

LGTM will leave for @lizan to approve/merge.

@phlax
Copy link
Copy Markdown
Member Author

phlax commented Sep 13, 2021

@lizan any chance of a gtm on this, it unblocks several other prs

@lizan lizan merged commit 1c6e047 into envoyproxy:main Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants