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

Bazelmod documentation and code examples. #2713

Merged
merged 61 commits into from
Jul 12, 2024

Conversation

marvin-hansen
Copy link
Contributor

@marvin-hansen marvin-hansen commented Jun 24, 2024

This PR provides documentation of Bazelmod and several code examples that addresses a number of issues related to Bazelmod.

Preview of the documentation: https://github.com/marvin-hansen/rules_rust/blob/main/docs/crate_universe_bzlmod.md

First and foremost it paves the way for a meaningful update the Bazelmod documentation that references these and existing code examples. This touches at least the following issues:

The compile_opt example addresses or resolves:

The musl_cross_compilling example addresses or resolves

The oci_container does not relate to any open issue,
although the tokio example in it gives a nice end to end example so
this definitely helps those looking for something non-trivial.

The proto example addresses or resolves:

Formalities

  • I've signed the CLA
  • I've signed all commits

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@UebelAndre UebelAndre self-requested a review June 24, 2024 20:46
@marvin-hansen
Copy link
Contributor Author

marvin-hansen commented Jun 26, 2024

Updated the crate_universe_bzlmod.md documentation.

This PR updates both, the example folder and the doc folder. Although in the doc folder, it only
updates the newly created crate_universe_bzlmod.md file and filled the blanks with some content.

Note, the documentation references some of the code examples in this PR, specifically the dependency vendoring example.

Please review.

@marvin-hansen marvin-hansen changed the title More Bazelmod code examples. Bazelmod documentation and code examples. Jun 26, 2024
Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

I haven't finished going through all the examples but could you update the presubmit yaml to make sure the examples are built and regression tested?

So far this is looking amazing though!

docs/crate_universe_bzlmod.md Outdated Show resolved Hide resolved
@marvin-hansen
Copy link
Contributor Author

marvin-hansen commented Jun 27, 2024

@UebelAndre I'm looking at the presubmit.yaml and how the other examples are build. I've to look closer into regression testing because I don't think I've added much yet.

Also, I need a bit of time to figure this out because I've stopped using GH actions a long time ago. The good news is, the same config used in the examples builds on my CI (BuildBuddy on Ubuntu 20.04) and the way I understand this pre-sub config is that the bzlmd job also runs on ubuntu 20.04 so I hope this is just a matter of time.

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen
Copy link
Contributor Author

marvin-hansen commented Jun 27, 2024

Looks like this was a lot easier than I though.

  • All bazelmod examples build on CI
  • All linter errors are fixed.
  • Added a Readme to the OCI example and the compiler optimization example.

The only remaining CI issue seems to be related to a git detached file that prevents the doc build.

I have no idea how that happened, but would you please take a look how to fix the doc build?

Doc build: https://buildkite.com/bazel/rules-rust-rustlang/builds/11570#019058a0-1986-4b05-bafc-6ed8ce8443c7

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! I had one last question and seems like the docs job is out of date? Maybe you just need to run https://github.com/bazelbuild/rules_rust/blob/0.46.0/docs/update_docs.sh

examples/bzlmod/oci_container/README.md Outdated Show resolved Hide resolved
Updated all dependencies.
Updated Readme.

Added sysroot for Intel/AMD to ensure the example works on Apple Silicon / Arm systems,

Moved sysroot into MODULE.bazel.

Added cross compile build and test to CI.

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Removed WORKSPACE file.
Updated Readme.

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen
Copy link
Contributor Author

For all practical purpose, it's best to exclude the MUSL example from this PR, merge it, and then then move on. I can re-add the example anytime after the toolchain issue has been resolved.

I've tried quite a few things to resolve the MUSL issue, but to no avail.

The way I see it is, that the toolchain resolution touches quite a few sensitive code blocks and somehow it's not so easy
to separate resolution on linux x86_64 for different ABI's. At least I could not find a way that resolves the issue and wthat isn't breaking something else along the way. However, I suggested a possible alternative in the MUSL toolchain resolution issue, but that needs more research. Therefore I suggest to remove the MUSL example, merge this PR, and then take it from there.

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This is generally looking great, thanks so much for taking the time to put it all together!

I agree we should probably remove the musl example until we resolve #2726 but would love to re-add it after then!

examples/bzlmod/compile_opt/README.md Outdated Show resolved Hide resolved
examples/bzlmod/cross_compile/README.md Outdated Show resolved Hide resolved
examples/bzlmod/musl_cross_compiling/README.md Outdated Show resolved Hide resolved
examples/bzlmod/musl_cross_compiling/README.md Outdated Show resolved Hide resolved
examples/bzlmod/proto/.DS_Store Outdated Show resolved Hide resolved
examples/bzlmod/oci_container/README.md Outdated Show resolved Hide resolved
marvin-hansen and others added 7 commits July 8, 2024 13:40
Good.

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
@marvin-hansen
Copy link
Contributor Author

Please let me know if you want any further changes.

Otherwise, build is green.

Copy link
Contributor Author

@marvin-hansen marvin-hansen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Contributor Author

@marvin-hansen marvin-hansen left a comment

Choose a reason for hiding this comment

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

Green. Good to go?

@marvin-hansen
Copy link
Contributor Author

@UebelAndre Would you please take a final look and decide whether to merge?

That would make the Bazelmod docs available online and allow to close a number of related issues.

Thank you

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@UebelAndre UebelAndre added this pull request to the merge queue Jul 12, 2024
Merged via the queue into bazelbuild:main with commit c177ccc Jul 12, 2024
3 checks passed
fmeum referenced this pull request in bazel-contrib/toolchains_llvm Jul 19, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| rules_rust | bazel_dep | minor | `0.47.1` -> `0.48.0` |
| [rules_rust](https://github.com/bazelbuild/rules_rust) |
http_archive | minor | `0.47.1` -> `0.48.0` |

---

### Release Notes

<details>
<summary>bazelbuild/rules_rust (rules_rust)</summary>

###
[`v0.48.0`](https://github.com/bazelbuild/rules_rust/releases/tag/0.48.0)

[Compare
Source](https://github.com/bazelbuild/rules_rust/compare/0.47.1...0.48.0)

### 0.48.0

#### Bzlmod

```python
bazel_dep(name = "rules_rust", version = "0.48.0")
```

#### WORKSPACE

```python
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_rust",
    integrity = "sha256-Weev1uz2QztBlDA88JX6A1N72SucD1V8lBsaliM0TTg=",
    urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.48.0/rules_rust-v0.48.0.tar.gz"],
)
```

Additional documentation can be found at:
https://bazelbuild.github.io/rules_rust/#setup

#### What's Changed

- Add support for shared test-only modules by
[@&#8203;IvanIsCoding](https://github.com/IvanIsCoding) in
[https://github.com/bazelbuild/rules_rust/pull/2734](https://github.com/bazelbuild/rules_rust/pull/2734)
- Bazelmod documentation and code examples. by
[@&#8203;marvin-hansen](https://github.com/marvin-hansen) in
[https://github.com/bazelbuild/rules_rust/pull/2713](https://github.com/bazelbuild/rules_rust/pull/2713)
- Add support for --wrap-extern-fns to bindgen rules by
[@&#8203;hlopko](https://github.com/hlopko) in
[https://github.com/bazelbuild/rules_rust/pull/2743](https://github.com/bazelbuild/rules_rust/pull/2743)
- Pass toolchain param in ctx.action.run in bindgen by
[@&#8203;hlopko](https://github.com/hlopko) in
[https://github.com/bazelbuild/rules_rust/pull/2745](https://github.com/bazelbuild/rules_rust/pull/2745)
- Make it possible to not specify clang binary in bindgen by
[@&#8203;hlopko](https://github.com/hlopko) in
[https://github.com/bazelbuild/rules_rust/pull/2746](https://github.com/bazelbuild/rules_rust/pull/2746)
- Make rustfmt toolchain optional in bindgen by
[@&#8203;hlopko](https://github.com/hlopko) in
[https://github.com/bazelbuild/rules_rust/pull/2744](https://github.com/bazelbuild/rules_rust/pull/2744)
- Fix collecting cc deps in collect_deps by
[@&#8203;mvukov](https://github.com/mvukov) in
[https://github.com/bazelbuild/rules_rust/pull/2699](https://github.com/bazelbuild/rules_rust/pull/2699)
- Support incompatible enable proto toolchain resolution by
[@&#8203;illicitonion](https://github.com/illicitonion) in
[https://github.com/bazelbuild/rules_rust/pull/2741](https://github.com/bazelbuild/rules_rust/pull/2741)
- Release 0.48.0 by
[@&#8203;illicitonion](https://github.com/illicitonion) in
[https://github.com/bazelbuild/rules_rust/pull/2750](https://github.com/bazelbuild/rules_rust/pull/2750)

#### New Contributors

- [@&#8203;IvanIsCoding](https://github.com/IvanIsCoding) made their
first contribution in
[https://github.com/bazelbuild/rules_rust/pull/2734](https://github.com/bazelbuild/rules_rust/pull/2734)
- [@&#8203;marvin-hansen](https://github.com/marvin-hansen) made their
first contribution in
[https://github.com/bazelbuild/rules_rust/pull/2713](https://github.com/bazelbuild/rules_rust/pull/2713)
- [@&#8203;mvukov](https://github.com/mvukov) made their first
contribution in
[https://github.com/bazelbuild/rules_rust/pull/2699](https://github.com/bazelbuild/rules_rust/pull/2699)

**Full Changelog**:
bazelbuild/rules_rust@0.47.1...0.48.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/toolchains_llvm).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Aug 18, 2024
Somehow in PR #2713, the bazelmod docs that I wrote went missing.

This PR restores the bazelmod docs.

Should be easy to review.

---------

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
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.

4 participants