Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into grpc-tonic-take2
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid committed Apr 29, 2021
2 parents 6b4b7d4 + 4d4218b commit cc60173
Show file tree
Hide file tree
Showing 581 changed files with 11,532 additions and 2,108 deletions.
159 changes: 110 additions & 49 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
default_linux_targets: &default_linux_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "@examples//..."
# TODO: Switch manual tag to platform constraint after bazel 4.0.
- "//test/versioned_dylib:versioned_dylib_test"
# Bindgen currently only has a working toolchain for 18.04
- "-@examples//ffi/rust_calling_c/simple/..."
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "@examples//..."
# TODO: Switch manual tag to platform constraint after bazel 4.0.
- "//test/versioned_dylib:versioned_dylib_test"
# Bindgen currently only has a working toolchain for 18.04
- "-@examples//ffi/rust_calling_c/simple/..."
tasks:
ubuntu1604:
build_targets: *default_linux_targets
Expand All @@ -25,77 +25,138 @@ tasks:
test_targets: *default_linux_targets
macos:
osx_targets: &osx_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "@examples//..."
# Skip tests for dylib support on osx, since we don't support it yet.
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
- "-@examples//ffi/rust_calling_c/simple/..."
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "@examples//..."
# Skip tests for dylib support on osx, since we don't support it yet.
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
- "-@examples//ffi/rust_calling_c/simple/..."
build_targets: *osx_targets
test_targets: *osx_targets
rbe_ubuntu1604:
test_targets:
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "//test/..."
- "@examples//..."
- "-//test/conflicting_deps:conflicting_deps_test"
# rust_doc_test is likely not fully sandboxed
- "-//test/chained_direct_deps:mod3_doc_test"
- "-@examples//fibonacci:fibonacci_doc_test"
- "-@examples//hello_lib:hello_lib_doc_test"
- "-//tools/runfiles:runfiles_doc_test"
- "-@examples//ffi/rust_calling_c/simple/..."
# See https://github.com/bazelbuild/bazel/issues/9987
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "//test/..."
- "@examples//..."
- "-//test/conflicting_deps:conflicting_deps_test"
# rust_doc_test is likely not fully sandboxed
- "-//test/chained_direct_deps:mod3_doc_test"
- "-@examples//fibonacci:fibonacci_doc_test"
- "-@examples//hello_lib:hello_lib_doc_test"
- "-//tools/runfiles:runfiles_doc_test"
- "-@examples//ffi/rust_calling_c/simple/..."
# See https://github.com/bazelbuild/bazel/issues/9987
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
windows:
build_flags:
- "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
- "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
windows_targets: &windows_targets
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "@examples//..."
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
- "-@examples//ffi/rust_calling_c/simple/..."
- "-@examples//hello_sys/..."
- "-@examples//complex_sys/..."
- "-@examples//proto/..."
- "-@examples//wasm/..."
- "--" # Allows negative patterns; hack for https://github.com/bazelbuild/continuous-integration/pull/245
- "..."
- "-//bindgen/..."
- "-//test/load_arbitrary_tool/..."
- "-//test/test_env/..."
- "-//test/proto/..."
- "-//tools/rust_analyzer/..."
- "-//tools/runfiles/..."
- "-//test/rustfmt/..."
- "@examples//..."
- "-@examples//ffi/rust_calling_c:matrix_dylib_test"
- "-@examples//ffi/rust_calling_c:matrix_dynamically_linked"
- "-@examples//ffi/rust_calling_c/simple/..."
- "-@examples//hello_sys/..."
- "-@examples//complex_sys/..."
- "-@examples//proto/..."
- "-@examples//wasm/..."
build_targets: *windows_targets
test_targets: *windows_targets
examples:
name: Examples
platform: ubuntu1804
working_directory: examples
test_targets:
- //...
- //...
docs_linux:
name: Docs
platform: ubuntu1804
working_directory: docs
build_targets:
- //...
docs_macos:
name: Docs
platform: macos
working_directory: docs
build_targets:
- //...
- //...
run_targets:
- "//:test_docs"
clippy_examples:
name: Clippy on Examples
platform: ubuntu1804
working_directory: examples
build_flags:
- "--aspects=@rules_rust//rust:rust.bzl%rust_clippy_aspect"
- "--output_groups=clippy_checks"
- "--aspects=@rules_rust//rust:rust.bzl%rust_clippy_aspect"
- "--output_groups=clippy_checks"
build_targets:
- //...
- //...
clippy_failure:
name: Negative Clippy Tests
platform: ubuntu1804
shell_commands:
- ./test/clippy/clippy_failure_test.sh

- ./test/clippy/clippy_failure_test.sh
ubuntu2004_clang:
name: Ubuntu 20.04 with Clang
platform: ubuntu2004
build_flags:
- "--repo_env=CC=clang"
# TODO(hlopko): Make this work (some tests were failing)
# - "--linkopt=-fuse-ld=lld"
build_targets: *default_linux_targets
test_targets: *default_linux_targets
crate_universe_examples_ubuntu2004:
name: Crate Universe Examples
platform: ubuntu2004
environment:
RULES_RUST_CRATE_UNIVERSE_BOOTSTRAP: true
working_directory: examples/crate_universe
build_targets:
- "//..."
test_targets:
- "//..."
crate_universe_rbe_ubuntu1604:
name: Crate Universe Examples
platform: rbe_ubuntu1604
environment:
RULES_RUST_CRATE_UNIVERSE_BOOTSTRAP: true
working_directory: examples/crate_universe
build_targets:
- "//..."
test_targets:
- "//..."
crate_universe_examples_macos:
name: Crate Universe Examples
platform: macos
environment:
RULES_RUST_CRATE_UNIVERSE_BOOTSTRAP: true
working_directory: examples/crate_universe
build_targets:
- "//..."
test_targets:
- "//..."
crate_universe_examples_windows:
name: Crate Universe Examples
platform: windows
environment:
RULES_RUST_CRATE_UNIVERSE_BOOTSTRAP: true
working_directory: examples/crate_universe
build_flags:
- "--enable_runfiles" # this is not enabled by default on windows and is necessary for the cargo build scripts
crate_universe_windows_targets: &crate_universe_windows_targets
- "//..."
# TODO: There are windows specific build issues in the generated
# dependencies. This should be fixed and all testing enabled.
- "-//has_aliased_deps/..."
- "-//uses_proc_macro/..."
- "-//uses_sys_crate/..."
build_targets: *crate_universe_windows_targets
# TODO: fix test targets in `crate_universe_windows_targets`
test_targets: *crate_universe_windows_targets
buildifier:
version: latest
warnings: "all"
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
docs
examples
examples/cargo_manifest_dir/external_crate
crate_universe/private/bootstrap
191 changes: 191 additions & 0 deletions .github/workflows/crate_universe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
name: Crate Universe CI+CD
on:
push:
branches:
- main
paths:
# Only run these jobs if rust code has changed since they're time consuming
- ".github/workflows/crate_universe.yaml"
- "crate_universe/**"

defaults:
run:
shell: bash

jobs:
build:
if: ${{ github.repository_owner == 'bazelbuild' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Create a job for each target triple
include:
- os: macos-10.15
env:
TARGET: "aarch64-apple-darwin"
EXTENSION: ""
- os: ubuntu-20.04
env:
TARGET: "aarch64-unknown-linux-gnu"
EXTENSION: ""
- os: macos-10.15
env:
TARGET: "x86_64-apple-darwin"
EXTENSION: ""
- os: ubuntu-20.04
env:
TARGET: "x86_64-pc-windows-gnu"
EXTENSION: ".exe"
- os: ubuntu-20.04
env:
TARGET: "x86_64-unknown-linux-gnu"
EXTENSION: ""
steps:
- uses: actions/checkout@v2
- run: |
# Install cross
if [[ "${RUNNER_OS}" == "macOS" ]]; then
curl --fail -Lo ~/cross.tar.gz https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-apple-darwin.tar.gz
else
curl --fail -Lo ~/cross.tar.gz https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz
fi
sudo tar -xf ~/cross.tar.gz -C /usr/local/bin/
sudo chmod +x /usr/local/bin/cross
if: matrix.os != 'windows-2019'
- run: |
# Install rust toolchains for host
# Detect the current version of rust
version="$(grep 'DEFAULT_RUST_VERSION =' ./rust/repositories.bzl | sed 's/DEFAULT_RUST_VERSION = "//' | sed 's/"//')"
rustup override set "${version}"
rustup update stable && rustup default stable
- run: |
# Setup macos build tooling
sudo xcode-select -s /Applications/Xcode_12.4.app/Contents/Developer/
# Set SDK environment variables
echo "SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)" >> $GITHUB_ENV
if: matrix.os == 'macOS-10.15'
- run: |
# Build binaries
./crate_universe/private/bootstrap/build.sh
env:
TARGET: "${{ matrix.env.TARGET }}"
- uses: actions/upload-artifact@v2
with:
name: "${{ matrix.env.TARGET }}"
path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/${{ matrix.env.TARGET }}
if-no-files-found: error
release:
if: ${{ github.repository_owner == 'bazelbuild' }}
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Save the git credentials so we can commit back to the repo
persist-credentials: true
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin
- run: |
# Ensure all files are executable
chmod +x ${{ github.workspace }}/crate_universe/private/bootstrap/bin/*/release/*
- run: |
# Write new defaults.bzl file
# Copy the new template
cp ${{ github.workspace }}/crate_universe/private/defaults.bzl.template ${{ github.workspace }}/crate_universe/private/defaults.bzl
# Replace the url
url="$(echo $URL | sed 's|releases/tag/|releases/download/|')/crate_universe_resolver-{host_triple}{extension}"
sed -i "s|{DEFAULT_URL_TEMPLATE}|${url}|" ${{ github.workspace }}/crate_universe/private/defaults.bzl
# Populate all sha256 values
TARGETS=(
aarch64-apple-darwin
aarch64-unknown-linux-gnu
x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu
)
for triple in ${TARGETS[@]}; do
if [[ "${triple}" == *"windows"* ]]; then
bin_name=crate_universe_resolver.exe
else
bin_name=crate_universe_resolver
fi
sha256="$(shasum --algorithm 256 ${{ github.workspace }}/crate_universe/private/bootstrap/bin/${triple}/release/${bin_name} | awk '{ print $1 }')"
sed -i "s|{${triple}--sha256}|${sha256}|" ${{ github.workspace }}/crate_universe/private/defaults.bzl
done
cat << EOF > ${{ github.workspace }}/tag_message.txt
From commit: ${GITHUB_SHA}
\`crate_universe_defaults.bzl\`:
\`\`\`python
$(cat ${{ github.workspace }}/crate_universe/private/defaults.bzl)
\`\`\`
EOF
env:
# This url should match ${{ steps.crate_universe_release.outputs.html_url }} but because this step runs before
# `crate_universe_release` we hard code the url to be what we expect the release URL to be.
URL: https://github.com/bazelbuild/rules_rust/releases/download/crate_universe-${{ github.run_number }}
- uses: actions/create-release@v1
id: crate_universe_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
tag_name: crate_universe-${{ github.run_number }}
release_name: crate_universe-${{ github.run_number }}
body_path: ${{ github.workspace }}/tag_message.txt
# There must be a upload action for each platform triple we create
- name: "Upload aarch64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.crate_universe_release.outputs.upload_url }}
asset_name: crate_universe_resolver-aarch64-apple-darwin
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/aarch64-apple-darwin/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload aarch64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.crate_universe_release.outputs.upload_url }}
asset_name: crate_universe_resolver-aarch64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/aarch64-unknown-linux-gnu/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload x86_64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.crate_universe_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-apple-darwin
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-apple-darwin/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload x86_64-pc-windows-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.crate_universe_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-pc-windows-gnu.exe
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-pc-windows-gnu/release/crate_universe_resolver.exe
asset_content_type: application/octet-stream
- name: "Upload x86_64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.crate_universe_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-unknown-linux-gnu/release/crate_universe_resolver
asset_content_type: application/octet-stream
Loading

0 comments on commit cc60173

Please sign in to comment.