Skip to content

Commit 0bbad0e

Browse files
committed
Added determinism inspection workflow
1 parent f5b7135 commit 0bbad0e

99 files changed

Lines changed: 14942 additions & 1 deletion

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: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Determinism
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, synchronize]
7+
paths:
8+
- test/determinism/**
9+
10+
jobs:
11+
check:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os:
16+
- macos-latest
17+
- ubuntu-latest
18+
- ubuntu-24.04-arm
19+
- windows-latest
20+
21+
runs-on: ${{ matrix.os }}
22+
name: Check (${{ matrix.os }})
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
clean: true
28+
29+
- uses: bazel-contrib/setup-bazel@0.14.0
30+
with:
31+
bazelisk-cache: true
32+
repository-cache: true
33+
34+
- name: Choose a work directory (unix)
35+
if: runner.os != 'Windows'
36+
shell: bash
37+
run: |
38+
echo "WORK_DIR=$RUNNER_TEMP/r" >> "$GITHUB_ENV"
39+
40+
- name: Choose a work directory (windows)
41+
if: runner.os == 'Windows'
42+
shell: pwsh
43+
run: |
44+
"WORK_DIR=C:\r" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
45+
46+
- name: Run tests (unix)
47+
continue-on-error: true
48+
run: >-
49+
bazel run
50+
--compilation_mode=opt
51+
//test/determinism:tester
52+
-- test
53+
--output="${{ github.workspace }}/results.json"
54+
--work-dir="${{ env.WORK_DIR }}"
55+
56+
- name: Summarize (unix)
57+
if: runner.os != 'Windows'
58+
shell: bash
59+
run: |
60+
if [[ ! -f results.json ]]; then
61+
exit 1
62+
fi
63+
64+
{
65+
echo '<details>'
66+
echo
67+
echo '```json'
68+
cat results.json
69+
echo
70+
echo '```'
71+
echo
72+
echo '</details>'
73+
} >> "$GITHUB_STEP_SUMMARY"
74+
75+
if [[ "$(cat results.json)" != "[]"* ]]; then
76+
exit 1
77+
fi
78+
79+
- name: Summarize (windows)
80+
if: runner.os == 'Windows'
81+
shell: pwsh
82+
run: |
83+
if (-not (Test-Path results.json)) { exit 1 }
84+
85+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '<details>'
86+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ''
87+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```json'
88+
Get-Content -Path results.json | Add-Content -Path $env:GITHUB_STEP_SUMMARY
89+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ''
90+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```'
91+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ''
92+
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '</details>'
93+
94+
$content = Get-Content -Path results.json -Raw
95+
if (-not $content.StartsWith('[]')) { exit 1 }
96+
97+
- name: Archive output base (unix)
98+
if: runner.os != 'Windows' && always()
99+
shell: bash
100+
run: |
101+
if [[ -d "${{ env.WORK_DIR }}/o" ]]; then
102+
tar -czf output-base.tar.gz -C "${WORK_DIR}" o
103+
fi
104+
105+
- name: Archive output base (windows)
106+
if: runner.os == 'Windows' && always()
107+
shell: pwsh
108+
run: |
109+
if (Test-Path "${{ env.WORK_DIR }}\o") {
110+
Compress-Archive -Path "${{ env.WORK_DIR }}\o" -DestinationPath output-base.zip
111+
}
112+
113+
- name: Upload output base artifact
114+
if: always()
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: output-base-${{ matrix.os }}
118+
path: |
119+
output-base.tar.gz
120+
output-base.zip
121+
if-no-files-found: ignore

MODULE.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ use_repo(
6666
"buildkite_config",
6767
"generated_inputs_in_external_repo",
6868
"libc",
69+
"rrtd",
70+
"rrtd__anyhow-1.0.100",
71+
"rrtd__blake3-1.8.2",
72+
"rrtd__clap-4.5.50",
73+
"rrtd__serde-1.0.228",
74+
"rrtd__serde_json-1.0.145",
75+
"rrtd__tempfile-3.23.0",
76+
"rrtd__tokio-1.48.0",
77+
"rrtd__tracing-0.1.41",
78+
"rrtd__tracing-subscriber-0.3.20",
79+
"rrtd__walkdir-2.5.0",
6980
"rtra",
7081
"rtra__serde-1.0.228",
7182
"rtra__serde_json-1.0.149",

test/cargo_build_script/compile_data/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
pub fn test_compile_data() {
33
let data = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", env!("DATA")));
44

5-
assert_eq!("La-Li-Lu-Le-Lo\n", data);
5+
assert_eq!("La-Li-Lu-Le-Lo", data.trim());
66
}

test/deps.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5+
load("//test/determinism/3rdparty/crates:crates.bzl", determinism_test_crate_repositories = "crate_repositories")
56
load("//test/generated_inputs:external_repo.bzl", "generated_inputs_in_external_repo")
67
load("//test/load_arbitrary_tool:load_arbitrary_tool_test.bzl", "load_arbitrary_tool_test")
78
load("//test/rust_analyzer/3rdparty/crates:crates.bzl", rust_analyzer_test_crate_repositories = "crate_repositories")
@@ -42,6 +43,7 @@ def rules_rust_test_deps(is_bzlmod = False):
4243
direct_deps.extend(generated_inputs_in_external_repo())
4344
direct_deps.extend(rust_analyzer_test_crate_repositories())
4445
direct_deps.extend(vscode_test_crate_repositories())
46+
direct_deps.extend(determinism_test_crate_repositories())
4547

4648
maybe(
4749
http_archive,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load("//crate_universe:defs.bzl", "crate", "crates_vendor")
2+
3+
crates_vendor(
4+
name = "crates_vendor",
5+
cargo_lockfile = "Cargo.Bazel.lock",
6+
mode = "remote",
7+
packages = {
8+
"anyhow": crate.spec(version = "1.0.97"),
9+
"blake3": crate.spec(version = "1.6.1"),
10+
"clap": crate.spec(
11+
features = [
12+
"derive",
13+
"env",
14+
],
15+
version = "4.5.32",
16+
),
17+
"serde": crate.spec(
18+
features = ["derive"],
19+
version = "1.0.219",
20+
),
21+
"serde_json": crate.spec(version = "1.0.140"),
22+
"tempfile": crate.spec(version = "3.19.0"),
23+
"tokio": crate.spec(
24+
features = ["full"],
25+
version = "1.44.1",
26+
),
27+
"tracing": crate.spec(version = "0.1.41"),
28+
"tracing-subscriber": crate.spec(version = "0.3.19"),
29+
"walkdir": crate.spec(version = "2.5.0"),
30+
},
31+
# `rrtd` == `rules_rust_test_determinism`
32+
repository_name = "rrtd",
33+
tags = ["manual"],
34+
)

0 commit comments

Comments
 (0)