Skip to content

Commit 15944a7

Browse files
Merge branch 'main' into patrick/bazel9
2 parents 0255245 + ca4915c commit 15944a7

153 files changed

Lines changed: 7329 additions & 7718 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/determinism.yaml

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@ name: Determinism
22

33
on:
44
workflow_dispatch:
5-
pull_request:
6-
types: [opened, synchronize]
7-
paths:
8-
- test/determinism/**
5+
inputs:
6+
commit:
7+
description: "Git commit or branch to test (defaults to main)"
8+
required: false
9+
default: "main"
910

1011
jobs:
1112
check:
1213
strategy:
1314
fail-fast: false
1415
matrix:
15-
include:
16-
- os: macos-latest
17-
work_dir: ${{ env.RUNNER_TEMP }}/r
18-
- os: ubuntu-latest
19-
work_dir: ${{ env.RUNNER_TEMP }}/r
20-
- os: windows-latest
21-
work_dir: C:\r
16+
os:
17+
- macos-latest
18+
- ubuntu-latest
19+
- ubuntu-24.04-arm
20+
- windows-latest
2221

2322
runs-on: ${{ matrix.os }}
2423
name: Check (${{ matrix.os }})
@@ -28,15 +27,47 @@ jobs:
2827
with:
2928
clean: true
3029

31-
- name: Run tests
32-
continue-on-error: true
30+
- name: Choose a work directory (unix)
31+
if: runner.os != 'Windows'
32+
shell: bash
33+
run: |
34+
echo "WORK_DIR=$RUNNER_TEMP/r" >> "$GITHUB_ENV"
35+
36+
- name: Choose a work directory (windows)
37+
if: runner.os == 'Windows'
38+
shell: pwsh
3339
run: |
34-
bazel run \
35-
--compilation_mode=opt \
36-
//test/determinism:tester \
37-
-- test \
38-
--output="${{ github.workspace }}/results.json" \
39-
--work-dir="${{ matrix.work_dir }}"
40+
'WORK_DIR=C:\r' | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
41+
42+
- name: Run tests (unix)
43+
if: runner.os != 'Windows'
44+
continue-on-error: true
45+
shell: bash
46+
run: >-
47+
bazel run
48+
--compilation_mode=opt
49+
//test/determinism:tester
50+
--
51+
test
52+
--url=${{ format('{0}/{1}.git', github.server_url, github.repository) }}
53+
--commit=${{ inputs.commit }}
54+
--output="${{ github.workspace }}/results.json"
55+
--work-dir="${WORK_DIR}"
56+
57+
- name: Run tests (windows)
58+
if: runner.os == 'Windows'
59+
continue-on-error: true
60+
shell: pwsh
61+
run: >-
62+
bazel run
63+
--compilation_mode=opt
64+
//test/determinism:tester
65+
'--'
66+
test
67+
--url=${{ format('{0}/{1}.git', github.server_url, github.repository) }}
68+
--commit=${{ inputs.commit }}
69+
--output="${{ github.workspace }}/results.json"
70+
--work-dir="$env:WORK_DIR"
4071
4172
- name: Summarize (unix)
4273
if: runner.os != 'Windows'
@@ -83,16 +114,16 @@ jobs:
83114
if: runner.os != 'Windows' && always()
84115
shell: bash
85116
run: |
86-
if [[ -d "${{ matrix.work_dir }}/o" ]]; then
87-
tar -czf output-base.tar.gz -C "${{ matrix.work_dir }}" o
117+
if [[ -d "${WORK_DIR}/o" ]]; then
118+
tar -czf output-base.tar.gz -C "${WORK_DIR}" o
88119
fi
89120
90121
- name: Archive output base (windows)
91122
if: runner.os == 'Windows' && always()
92123
shell: pwsh
93124
run: |
94-
if (Test-Path "${{ matrix.work_dir }}\o") {
95-
Compress-Archive -Path "${{ matrix.work_dir }}\o" -DestinationPath output-base.zip
125+
if (Test-Path "$env:WORK_DIR\o") {
126+
Compress-Archive -Path "$env:WORK_DIR\o" -DestinationPath output-base.zip
96127
}
97128
98129
- name: Upload output base artifact
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Release Runfiles
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- rust/runfiles/Cargo.toml
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
validation:
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- uses: actions/checkout@v4
20+
# TODO: Unfortunately it's not obvious how to restrict `workflow_dispatch` to a particular branch
21+
# so this step ensures releases are always done off of `main`.
22+
- name: Ensure branch is 'main'
23+
run: |
24+
git fetch origin &> /dev/null
25+
branch="$(git rev-parse --abbrev-ref HEAD)"
26+
if [[ "${branch}" != "main" ]]; then
27+
echo "The release branch must be main. Got '${branch}'' instead." >&2
28+
exit 1
29+
else
30+
echo "Branch is '${branch}'"
31+
fi
32+
builds:
33+
needs: validation
34+
runs-on: ubuntu-22.04
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Install rust toolchains for host
38+
run: |
39+
# Detect the current version of rust
40+
version="$(grep 'DEFAULT_RUST_VERSION =' ./rust/private/common.bzl | grep -o '[[:digit:].]\+')"
41+
rustup override set "${version}"
42+
rustup update stable && rustup default stable
43+
- name: Publish to crates.io
44+
run: cargo publish --token ${CRATES_TOKEN}
45+
working-directory: ./rust/runfiles
46+
env:
47+
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

MODULE.bazel

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ internal_deps = use_extension("//rust/private:internal_extensions.bzl", "i")
2121
use_repo(
2222
internal_deps,
2323
"rrra",
24-
"rrra__anyhow-1.0.71",
25-
"rrra__camino-1.1.9",
26-
"rrra__clap-4.3.11",
27-
"rrra__env_logger-0.10.0",
28-
"rrra__itertools-0.11.0",
29-
"rrra__log-0.4.19",
30-
"rrra__serde-1.0.171",
31-
"rrra__serde_json-1.0.102",
24+
"rrra__anyhow-1.0.102",
25+
"rrra__camino-1.2.2",
26+
"rrra__clap-4.6.0",
27+
"rrra__env_logger-0.11.10",
28+
"rrra__itertools-0.14.0",
29+
"rrra__log-0.4.29",
30+
"rrra__serde-1.0.228",
31+
"rrra__serde_json-1.0.149",
3232
"rules_rust_tinyjson",
3333
)
3434

@@ -112,7 +112,7 @@ use_repo(
112112
"cui__cargo-lock-10.1.0",
113113
"cui__cargo-platform-0.1.9",
114114
"cui__cargo_metadata-0.19.2",
115-
"cui__cargo_toml-0.22.1",
115+
"cui__cargo_toml-0.22.3",
116116
"cui__cfg-expr-0.18.0",
117117
"cui__clap-4.5.37",
118118
"cui__crates-index-3.7.0",
@@ -134,7 +134,7 @@ use_repo(
134134
"cui__tempfile-3.19.1",
135135
"cui__tera-1.20.0",
136136
"cui__textwrap-0.16.2",
137-
"cui__toml-0.8.21",
137+
"cui__toml-0.9.5",
138138
"cui__tracing-0.1.41",
139139
"cui__tracing-subscriber-0.3.19",
140140
"cui__url-2.5.4",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
2-
let contents = std::fs::read_to_string("cargo/tests/cargo_build_script/run_from_exec_root/data.txt")
3-
.expect("Failed to read data file");
2+
let contents =
3+
std::fs::read_to_string("cargo/tests/cargo_build_script/run_from_exec_root/data.txt")
4+
.expect("Failed to read data file");
45
println!("cargo:rustc-env=DATA={}", contents);
56
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load(":transitive_data_test.bzl", "transitive_cbs_data_test_suite")
2+
3+
transitive_cbs_data_test_suite(
4+
name = "transitive_cbs_data_test_suite",
5+
)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""Tests documenting that cargo_build_script `data` files currently act as both
2+
compile_data and runtime data -- they appear in Rustc compile action inputs for
3+
both the direct library and transitive dependents.
4+
5+
See https://github.com/bazelbuild/rules_rust/issues/3609 for context."""
6+
7+
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
8+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
9+
load("//cargo:defs.bzl", "cargo_build_script")
10+
load("//rust:defs.bzl", "rust_library")
11+
12+
def _cbs_data_in_rustc_inputs_impl(ctx):
13+
env = analysistest.begin(ctx)
14+
target = analysistest.target_under_test(env)
15+
16+
rustc_action = None
17+
for action in target.actions:
18+
if action.mnemonic == "Rustc":
19+
rustc_action = action
20+
break
21+
22+
asserts.false(env, rustc_action == None, "Expected a Rustc action")
23+
24+
# cargo_build_script `data` currently flows into BuildInfo.compile_data
25+
# via script_data, so it appears in Rustc action inputs for both the
26+
# direct dependent and transitive dependents. This documents that
27+
# CBS `data` effectively acts as both compile_data and data today.
28+
data_inputs = [i for i in rustc_action.inputs.to_list() if "cbs_data_dep.txt" in i.path]
29+
asserts.true(
30+
env,
31+
len(data_inputs) > 0,
32+
"Expected CBS data file to appear in Rustc action inputs (CBS data currently acts as compile_data)",
33+
)
34+
35+
return analysistest.end(env)
36+
37+
cbs_data_in_rustc_inputs_test = analysistest.make(
38+
_cbs_data_in_rustc_inputs_impl,
39+
)
40+
41+
def _define_test_targets():
42+
write_file(
43+
name = "cbs_data_dep_file",
44+
out = "cbs_data_dep.txt",
45+
content = ["data for build script", ""],
46+
newline = "unix",
47+
)
48+
49+
write_file(
50+
name = "build_rs_src",
51+
out = "build.rs",
52+
content = ["fn main() {}", ""],
53+
newline = "unix",
54+
)
55+
56+
cargo_build_script(
57+
name = "build_script",
58+
srcs = [":build.rs"],
59+
data = [":cbs_data_dep.txt"],
60+
edition = "2021",
61+
)
62+
63+
write_file(
64+
name = "lib_src",
65+
out = "lib.rs",
66+
content = ["pub fn hello() {}", ""],
67+
newline = "unix",
68+
)
69+
70+
rust_library(
71+
name = "lib",
72+
srcs = [":lib.rs"],
73+
deps = [":build_script"],
74+
edition = "2021",
75+
)
76+
77+
write_file(
78+
name = "bin_src",
79+
out = "bin.rs",
80+
content = ["extern crate lib;", ""],
81+
newline = "unix",
82+
)
83+
84+
rust_library(
85+
name = "bin",
86+
srcs = [":bin.rs"],
87+
deps = [":lib"],
88+
edition = "2021",
89+
)
90+
91+
def transitive_cbs_data_test_suite(name):
92+
"""Entry-point macro called from the BUILD file.
93+
94+
Args:
95+
name (str): Name of the macro.
96+
"""
97+
_define_test_targets()
98+
99+
cbs_data_in_rustc_inputs_test(
100+
name = "cbs_data_in_lib_compile_inputs_test",
101+
target_under_test = ":lib",
102+
)
103+
104+
cbs_data_in_rustc_inputs_test(
105+
name = "cbs_data_in_bin_compile_inputs_test",
106+
target_under_test = ":bin",
107+
)
108+
109+
native.test_suite(
110+
name = name,
111+
tests = [
112+
":cbs_data_in_lib_compile_inputs_test",
113+
":cbs_data_in_bin_compile_inputs_test",
114+
],
115+
)

crate_universe/3rdparty/crates/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.cargo-lock-10.1.0.bazel

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.cargo_toml-0.22.1.bazel renamed to crate_universe/3rdparty/crates/BUILD.cargo_toml-0.22.3.bazel

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crate_universe/3rdparty/crates/BUILD.crates-index-3.7.0.bazel

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)