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

Moved rust extension rules into a separate rules_rust_ext workspace. #3007

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
150 changes: 89 additions & 61 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ default_macos_targets: &default_macos_targets
default_windows_targets: &default_windows_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "//..."
- "-//test/proto/..."
- "-//test/unit/pipelined_compilation/..."
default_windows_no_runfiles_targets: &default_windows_no_runfiles_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
Expand All @@ -43,7 +42,6 @@ default_windows_no_runfiles_targets: &default_windows_no_runfiles_targets
- "-//crate_universe/..."
- "-//test/chained_direct_deps:mod3_doc_test"
- "-//test/out_dir_in_tests:demo_lib_doc_test"
- "-//test/proto/..."
- "-//test/rustc_env_files:output_test"
- "-//test/test_env_launcher:test"
- "-//test/test_env:test_manifest_dir"
Expand All @@ -59,9 +57,6 @@ crate_universe_vendor_example_targets: &crate_universe_vendor_example_targets
- "//vendor_local_pkgs:crates_vendor"
- "//vendor_remote_manifests:crates_vendor"
- "//vendor_remote_pkgs:crates_vendor"
crate_universe_unnamed_vendor_example_targets: &crate_universe_unnamed_vendor_example_targets
- "//vendor_remote_manifests:crates_vendor"
- "//vendor_remote_pkgs:crates_vendor"
coverage_validation_post_shell_commands: &coverage_validation_post_shell_commands
- |
grep -q '^SF:.*\.rs$' bazel-out/_coverage/_coverage_report.dat \
Expand Down Expand Up @@ -238,12 +233,9 @@ tasks:
build_flags:
- "--enable_bzlmod"
build_targets:
- "//bindgen/3rdparty:bindgen"
- "//crate_universe:cargo_bazel_bin"
- "//proto/prost/private:prost_runtime"
- "//tools/runfiles"
- "//util/import"
- "//wasm_bindgen/3rdparty:wasm_bindgen"
ubuntu2004_clang:
name: With Clang
platform: ubuntu2004
Expand Down Expand Up @@ -378,12 +370,8 @@ tasks:
name: Rust-Analyzer Tests
platform: ubuntu2004
run_targets:
- "//tools/rust_analyzer:gen_rust_project"
- "//test/rust_analyzer:rust_analyzer_test"
rust_analyzer_integration_test:
name: Rust-Analyzer Integration Test
platform: ubuntu2004
run_targets:
- "@rules_rust//tools/rust_analyzer:gen_rust_project"
examples_rust_analyzer_integration_test:
name: Rust-Analyzer Integration Test
platform: ubuntu2004
Expand Down Expand Up @@ -474,11 +462,6 @@ tasks:
windows_targets: &windows_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "//..."
# The proto rules do not work on windows
- "-//proto/..."
# The bindgen rules are currently broken on windows
# https://github.com/bazelbuild/rules_rust/issues/2009
- "-//bindgen/..."
build_targets: *windows_targets
test_targets: *windows_targets
crate_universe_examples_ubuntu2004:
Expand All @@ -491,16 +474,6 @@ tasks:
test_targets:
- "//..."
build_flags: *aspects_flags
crate_universe_unnamed_examples_ubuntu2004:
name: Crate Universe Unnamed Examples
platform: ubuntu2004
working_directory: examples/crate_universe_unnamed
run_targets: *crate_universe_unnamed_vendor_example_targets
build_targets:
- "//..."
test_targets:
- "//..."
build_flags: *aspects_flags
crate_universe_rbe_ubuntu2004:
name: Crate Universe Examples
platform: rbe_ubuntu2004
Expand All @@ -514,19 +487,6 @@ tasks:
test_targets:
- "//..."
build_flags: *aspects_flags
crate_universe_unnamed_rbe_ubuntu2004:
name: Crate Universe Unnamed Examples
platform: rbe_ubuntu2004
working_directory: examples/crate_universe_unnamed
shell_commands:
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
run_targets: *crate_universe_unnamed_vendor_example_targets
build_targets:
- "//..."
test_targets:
- "//..."
build_flags: *aspects_flags
crate_universe_examples_macos:
name: Crate Universe Examples
platform: macos_arm64
Expand All @@ -537,16 +497,6 @@ tasks:
test_targets:
- "//..."
build_flags: *aspects_flags
crate_universe_unnamed_examples_macos:
name: Crate Universe Unnamed Examples
platform: macos_arm64
working_directory: examples/crate_universe_unnamed
run_targets: *crate_universe_unnamed_vendor_example_targets
build_targets:
- "//..."
test_targets:
- "//..."
build_flags: *aspects_flags
# See https://github.com/bazelbuild/rules_rust/issues/2186 about re-enabling these.
# crate_universe_examples_windows:
# name: Crate Universe Examples
Expand All @@ -557,16 +507,6 @@ tasks:
# build_targets:
# - "//..."
# test_targets:
# - "//..."
# crate_universe_unnamed_examples_windows:
# name: Crate Universe Unnamed Examples
# platform: windows
# working_directory: examples/crate_universe_unnamed
# run_targets: *crate_universe_unnamed_vendor_example_targets
# build_flags: *aspects_flags
# build_targets:
# - "//..."
# test_targets:
# - "//..."
cc_common_link_ubuntu2004:
name: Build via cc_common.link
Expand Down Expand Up @@ -884,6 +824,94 @@ tasks:
- "--compile_one_dependency"
build_targets:
- "tools/rust_analyzer/main.rs"
extensions_linux:
name: Extensions
platform: ubuntu2004
working_directory: extensions
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
coverage_targets:
- "//..."
extensions_macos:
name: Extensions
platform: macos_arm64
working_directory: extensions
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
coverage_targets:
- "//..."
extensions_windows:
name: Extensions
platform: windows
working_directory: extensions
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
coverage_targets:
- "//..."
extensions_linux_rbe:
name: Extensions
platform: rbe_ubuntu2004
working_directory: extensions
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
coverage_targets:
- "//..."
# extensions_examples_linux:
# name: Extension Examples
# platform: ubuntu2004
# working_directory: extensions/examples
# build_targets:
# - "//..."
# test_targets:
# - "//..."
# coverage_targets:
# - "//..."
# extensions_examples_macos:
# name: Extension Examples
# platform: macos_arm64
# working_directory: extensions/examples
# build_targets:
# - "//..."
# test_targets:
# - "//..."
# coverage_targets:
# - "//..."
# extensions_examples_windows:
# name: Extension Examples
# platform: windows
# working_directory: extensions/examples
# build_targets:
# - "//..."
# test_targets:
# - "//..."
# coverage_targets:
# - "//..."
# extensions_examples_linux_rbe:
# name: Extension Examples
# platform: rbe_ubuntu2004
# working_directory: extensions/examples
# build_targets:
# - "//..."
# test_targets:
# - "//..."
# coverage_targets:
# - "//..."

buildifier:
version: latest
Expand Down
5 changes: 3 additions & 2 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.direnv
bzlmod
crate_universe/private/bootstrap
docs
examples
crate_universe/private/bootstrap
extensions
test/aliased_toolchains
test/bzlmod_repo_mapping
test/cc_common_link
test/no_std
.direnv
2 changes: 1 addition & 1 deletion .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"integrity": "**leave this alone**",
"strip_prefix": "",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-v{VERSION}.tar.gz"
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{VERSION}.tar.gz"
}
12 changes: 6 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
**/*Cargo.Bazel.lock linguist-generated
**/cargo-bazel-lock.json linguist-generated
bindgen/3rdparty/crates/** linguist-generated
crate_universe/3rdparty/crates/** linguist-generated
crate_universe/test_data/metadata/*/metadata.json linguist-generated
examples/bzlmod/hello_world/third-party/crates/** linguist-generated
examples/crate_universe_unnamed/vendor_remote_manifests/crates/** linguist-generated
examples/crate_universe_unnamed/vendor_remote_pkgs/crates/** linguist-generated
examples/crate_universe/vendor_external/crates/** linguist-generated
examples/crate_universe/vendor_local_manifests/crates/** linguist-generated
examples/crate_universe/vendor_local_pkgs/crates/** linguist-generated
examples/crate_universe/vendor_remote_manifests/crates/** linguist-generated
examples/crate_universe/vendor_remote_pkgs/crates/** linguist-generated
examples/crate_universe_unnamed/vendor_remote_manifests/crates/** linguist-generated
examples/crate_universe_unnamed/vendor_remote_pkgs/crates/** linguist-generated
examples/sys/basic/3rdparty/crates/** linguist-generated
examples/sys/complex/3rdparty/crates/** linguist-generated
proto/prost/private/3rdparty/crates/** linguist-generated
proto/protobuf/3rdparty/crates/** linguist-generated
extensions/bindgen/3rdparty/crates/** linguist-generated
extensions/prost/private/3rdparty/crates/** linguist-generated
extensions/proto/protobuf/3rdparty/crates/** linguist-generated
extensions/wasm_bindgen/3rdparty/crates/** linguist-generated
tools/rust_analyzer/3rdparty/crates/** linguist-generated
util/import/3rdparty/crates/** linguist-generated
wasm_bindgen/3rdparty/crates/** linguist-generated
23 changes: 21 additions & 2 deletions .github/release_notes.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# {version}

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

## Bzlmod

```python
Expand All @@ -13,8 +15,25 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_rust",
integrity = "sha256-{sha256_base64}",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-v{version}.tar.gz"],
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-{version}.tar.gz"],
)
```

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

### Bzlmod

```python
bazel_dep(name = "rules_rust_ext", version = "{version}")
```

### WORKSPACE

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_rust",
integrity = "sha256-{ext_sha256_base64}",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust_ext-{version}.tar.gz"],
)
```
44 changes: 41 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,57 @@ jobs:
- name: Create the rules archive
run: |
# Update urls and sha256 values
bazel ${BAZEL_STARTUP_FLAGS[@]} run //crate_universe/tools/urls_generator -- --artifacts-dir="${ARTIFACTS_DIR}" --url-prefix="${URL_PREFIX}"
bazel ${BAZEL_STARTUP_FLAGS[@]} run //crate_universe/tools/urls_generator \
-- --artifacts-dir="${ARTIFACTS_DIR}" --url-prefix="${URL_PREFIX}"

bazel clean

# Build an archive of the repo contents.
# `examples/bzlmod` is included for the BCR presubmit; it must appear before --exclude="examples"
tar -czf ${{ github.workspace }}/.github/rules_rust.tar.gz -C ${{ github.workspace }} --exclude=".git" --exclude=".github" --exclude="crate_universe/target" examples/bzlmod --exclude="examples" .
tar -czf ${{ github.workspace }}/.github/rules_rust.tar.gz \
-C ${{ github.workspace }} \
--exclude=".git" --exclude=".github" \
--exclude="crate_universe/target" \
examples/bzlmod \
--exclude="examples" \
--exclude="extensions" \
.

# Save the sha256 checksum of the distro archive to the environment
sha256_base64="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_rust.tar.gz | awk '{ print $1 }' | xxd -r -p | base64)"
echo "ARCHIVE_SHA256_BASE64=${sha256_base64}" >> $GITHUB_ENV
env:
CARGO_BAZEL_GENERATOR_URL: file://${{ github.workspace }}/crate_universe/target/artifacts/x86_64-unknown-linux-gnu/cargo-bazel
ARTIFACTS_DIR: ${{ github.workspace }}/crate_universe/target/artifacts
URL_PREFIX: https://github.com/${{ github.repository_owner }}/rules_rust/releases/download/${{ env.RELEASE_VERSION }}
- name: Create the rules extensions archive
run: |
# Build an archive of the repo contents.
tar -czf ${{ github.workspace }}/.github/rules_rust_ext.tar.gz \
-C ${{ github.workspace }}/extensions \
--exclude="examples" \
.

# Save the sha256 checksum of the distro archive to the environment
sha256_base64="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_rust_ext.tar.gz | awk '{ print $1 }' | xxd -r -p | base64)"
echo "ARCHIVE_EXT_SHA256_BASE64=${sha256_base64}" >> $GITHUB_ENV
# Upload the artifact in case creating a release fails so all artifacts can then be manually recovered.
- uses: actions/upload-artifact@v3
with:
name: "rules_rust.tar.gz"
path: ${{ github.workspace }}/.github/rules_rust.tar.gz
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: "rules_rust_ext.tar.gz"
path: ${{ github.workspace }}/.github/rules_rust_ext.tar.gz
if-no-files-found: error
- name: Generate release notes
run: |
# Generate the release notes
sed 's#{version}#${{ env.RELEASE_VERSION }}#g' ${{ github.workspace }}/.github/release_notes.template \
| sed 's#{sha256_base64}#${{ env.ARCHIVE_SHA256_BASE64 }}#g' \
| sed 's#{ext_sha256_base64}#${{ env.ARCHIVE_EXT_SHA256_BASE64 }}#g' \
> ${{ github.workspace }}/.github/release_notes.txt
- name: Create release
uses: softprops/action-gh-release@v1
Expand All @@ -169,10 +197,20 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: rules_rust-v${{ env.RELEASE_VERSION }}.tar.gz
asset_name: rules_rust-${{ env.RELEASE_VERSION }}.tar.gz
asset_path: ${{ github.workspace }}/.github/rules_rust.tar.gz
asset_content_type: application/gzip

- name: "Upload the rules extensions archive"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: rules_rust_ext-${{ env.RELEASE_VERSION }}.tar.gz
asset_path: ${{ github.workspace }}/.github/rules_rust_ext.tar.gz
asset_content_type: application/gzip

# There must be a upload action for each platform triple we create
- name: "Upload aarch64-apple-darwin"
uses: actions/upload-release-asset@v1
Expand Down
Loading
Loading