Skip to content

Added CI for single toolchain channel workspaces #1712

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

Merged
merged 4 commits into from
Jan 4, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ aspects_flags: &aspects_flags
- "--config=clippy"
min_rust_version_shell_commands: &min_rust_version_shell_commands
- sed -i 's|^rust_register_toolchains(|rust_register_toolchains(versions = ["1.59.0"],\n|' WORKSPACE.bazel
nightly_flags: &nightly_flags
- "--//rust/toolchain/channel=nightly"
nightly_aspects_flags: &nightly_aspects_flags
- "--//rust/toolchain/channel=nightly"
- "--config=rustfmt"
- "--config=clippy"
single_rust_channel_targets: &single_rust_channel_targets
- "--"
- "//..."
Expand Down Expand Up @@ -219,9 +225,48 @@ tasks:
name: "Min Rust Version With Aspects"
platform: ubuntu2004
shell_commands: *min_rust_version_shell_commands
build_flags: *aspects_flags
build_targets: *single_rust_channel_targets
test_flags: *aspects_flags
test_targets: *single_rust_channel_targets
ubuntu2004_stable_toolchain:
name: "Only Stable Toolchain"
platform: ubuntu2004
# Test rules while only registering a nightly toolchain
shell_commands:
- sed -i 's|^rust_register_toolchains(|load("//rust/private:common.bzl", "DEFAULT_RUST_VERSION")\nrust_register_toolchains(versions = [DEFAULT_RUST_VERSION],\n|' WORKSPACE.bazel
build_targets: *single_rust_channel_targets
test_targets: *single_rust_channel_targets
ubuntu2004_stable_with_aspects:
name: "Only Stable Toolchain With Aspects"
platform: ubuntu2004
# Test rules while only registering a nightly toolchain
shell_commands:
- sed -i 's|^rust_register_toolchains(|load("//rust/private:common.bzl", "DEFAULT_RUST_VERSION")\nrust_register_toolchains(versions = [DEFAULT_RUST_VERSION],\n|' WORKSPACE.bazel
build_flags: *aspects_flags
build_targets: *single_rust_channel_targets
test_flags: *aspects_flags
test_targets: *single_rust_channel_targets
ubuntu2004_nightly_toolchain:
name: "Only Nightly Toolchain"
platform: ubuntu2004
# Test rules while only registering a nightly toolchain
shell_commands:
- sed -i 's|^rust_register_toolchains(|load("//rust/private:common.bzl", "DEFAULT_NIGHTLY_ISO_DATE")\nrust_register_toolchains(versions = ["nightly/" + DEFAULT_NIGHTLY_ISO_DATE],\n|' WORKSPACE.bazel
build_flags: *nightly_flags
build_targets: *single_rust_channel_targets
test_flags: *nightly_flags
test_targets: *single_rust_channel_targets
ubuntu2004_nightly_with_aspects:
name: "Only Nightly Toolchain With Aspects"
platform: ubuntu2004
# Test rules while only registering a nightly toolchain
shell_commands:
- sed -i 's|^rust_register_toolchains(|load("//rust/private:common.bzl", "DEFAULT_NIGHTLY_ISO_DATE")\nrust_register_toolchains(versions = ["nightly/" + DEFAULT_NIGHTLY_ISO_DATE],\n|' WORKSPACE.bazel
build_flags: *nightly_aspects_flags
build_targets: *single_rust_channel_targets
test_flags: *nightly_aspects_flags
test_targets: *single_rust_channel_targets
ubuntu2004_rolling_with_aspects:
name: "Rolling Bazel Version With Aspects"
bazel: "rolling"
Expand Down
3 changes: 1 addition & 2 deletions test/cargo_build_script/tools_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub fn test_tool_exec() {
let tool_path = env!("TOOL_PATH");
assert!(
tool_path.contains("-exec-"),
"tool_path did not contain '-exec-': {}",
tool_path
"tool_path did not contain '-exec-'",
Copy link
Collaborator Author

@UebelAndre UebelAndre Dec 23, 2022

Choose a reason for hiding this comment

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

Same as #1712 (comment)

);
}
3 changes: 1 addition & 2 deletions test/process_wrapper/rustc_quit_on_rmeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ mod test {
]);
assert!(
!out_content.contains("should not be in output"),
"output should not contain 'should not be in output' but did: {}",
out_content
"output should not contain 'should not be in output' but did",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this change is related to rust-lang/rust-clippy#10055

Unfortunately #[allow(clippy::uninlined_format_args] cannot be used here without requiring we raise our min supported Rust version above 1.59.0

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can rustversion::attr be used here? https://crates.io/crates/rustversion

(I don't know the answer - I know rustversion can be used for conditional attrs on structs, and can't be used for conditional enabling of features - I'm not sure how allows fit in :))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it'd be appropriate to add a new external dependency just for this. It seems it'll be fixed in a future nightly release so I think it's an acceptable trade off for now. If I can remember it I'll add them back in the future

);
}

Expand Down
2 changes: 1 addition & 1 deletion test/rustfmt/rustfmt_failure_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cd "${BUILD_WORKSPACE_DIRECTORY}"
function check_build_result() {
local ret=0
echo -n "Testing ${2}... "
(bazel test //test/rustfmt:"${2}" &> /dev/null) || ret="$?" && true
(bazel test //test/rustfmt:"${2}") || ret="$?" && true
if [[ "${ret}" -ne "${1}" ]]; then
echo "FAIL: Unexpected return code [saw: ${ret}, want: ${1}] building target //test/rustfmt:${2}"
echo " Run \"bazel test //test/rustfmt:${2}\" to see the output"
Expand Down