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

chore: Allow Bazel commands to run in repository subdirectories #13523

Merged

Conversation

vktng
Copy link
Contributor

@vktng vktng commented Aug 5, 2022

Signed-off-by: Krisztián Varga krisztian.varga@tngtech.com

Summary

Since #12987 was merged, the bazel commands will only work in the magma folder, because the cache setup was reworked to use a relative path: bazel/bazelrcs/cache.bazelrc
This PR changes the path to use the workspace root.

Test Plan

Try using Bazel in subdirectories.
For example: cd $MAGMA_ROOT/lte/gateway && bazel build //:buildifier

Additional Information

  • This change is backwards-breaking

@vktng vktng added the bazel changes for the Bazelification effort label Aug 5, 2022
@vktng vktng self-assigned this Aug 5, 2022
@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Aug 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions github-actions bot added the component: agw Access gateway-related issue label Aug 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

feg-workflow

    2 files  203 suites   39s ⏱️
374 tests 374 ✔️ 0 💤 0
388 runs  388 ✔️ 0 💤 0

Results for commit ece6839.

@vktng vktng force-pushed the fix_bazel_cannot_run_outside_magma_folder branch from ece6839 to 4768d45 Compare August 5, 2022 14:09
@pull-request-size pull-request-size bot added size/XS Denotes a PR that changes 0-9 lines. and removed size/L Denotes a Pull Request that changes 100-499 lines. labels Aug 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

dp-workflow

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit 265e881.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

agw-workflow

615 tests   611 ✔️  4m 24s ⏱️
    2 suites      4 💤
    2 files        0

Results for commit 265e881.

♻️ This comment has been updated with latest results.

.bazelrc Outdated
@@ -48,7 +48,7 @@ run:remote_caching_ro --remote_download_toplevel

# Import the bazel caching config, with default disk cache,
# which in CI gets overwritten by the remote caching config.
import bazel/bazelrcs/cache.bazelrc
import /var/cache/cache.bazelrc
Copy link
Contributor

Choose a reason for hiding this comment

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

We could also use import %workspace%/bazel/bazelrcs/cache.bazelrc, see https://docs.bazel.build/versions/main/guide.html#imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a really clean solution, the other PR setting up symbolic links is not even needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to replace all links by %workspace%/.bazel-cache/ etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried %workspace%/.bazel-cache/ and it works fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, good to know. Then we might refactor the mechanics at some point to get rid of all the linking. But for now let us just keep it as it is as this is a larger refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I stand corrected:
workspace_not_working_bazel_cache
But it might work with a little more thought put into it.

Signed-off-by: Krisztián Varga <krisztian.varga@tngtech.com>
@vktng vktng force-pushed the fix_bazel_cannot_run_outside_magma_folder branch from 4768d45 to 265e881 Compare August 9, 2022 10:14
@vktng vktng marked this pull request as ready for review August 9, 2022 10:32
@vktng vktng requested review from a team and LKreutzer August 9, 2022 10:32
Copy link
Contributor

@LKreutzer LKreutzer left a comment

Choose a reason for hiding this comment

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

Tested locally

@LKreutzer LKreutzer merged commit 3e23773 into magma:master Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel changes for the Bazelification effort component: agw Access gateway-related issue size/XS Denotes a PR that changes 0-9 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bazel commands only work in the magma directory
3 participants