Skip to content
Open
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
99 changes: 99 additions & 0 deletions .github/workflows/determinism.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Determinism

on:
workflow_dispatch:

jobs:
check:
strategy:
fail-fast: false
matrix:
# Create a job for each target triple
include:
- os: macos-latest
work_dir: "${{ runner.temp }}/r"
- os: ubuntu-latest
work_dir: "${{ runner.temp }}/r"
- os: windows-latest
work_dir: "C:/r"
runs-on: ${{ matrix.os }}
name: Check (${{ matrix.os }})
steps:
- uses: actions/checkout@master
with:
clean: true

- name: Run tests
continue-on-error: true
run:
bazel run
--compilation_mode=opt
'//test/determinism:tester'
'--'
test
--output=${{ github.workspace }}/results.json
--work-dir=${{ matrix.work_dir }}

- name: Summarize (unix)
if: runner.os != 'Windows'
run: |
if [[ ! -f results.json ]]; then
exit 1
fi

echo '<details>' >> ${GITHUB_STEP_SUMMARY}
echo '' >> ${GITHUB_STEP_SUMMARY}
echo '```json' >> ${GITHUB_STEP_SUMMARY}
cat results.json >> ${GITHUB_STEP_SUMMARY}
echo '' >> ${GITHUB_STEP_SUMMARY}
echo '```' >> ${GITHUB_STEP_SUMMARY}
echo '' >> ${GITHUB_STEP_SUMMARY}
echo '</details>' >> ${GITHUB_STEP_SUMMARY}

if [[ "$(cat results.json)" != "[]"* ]]; then
exit 1
fi
- name: Summarize (windows)
if: runner.os == 'Windows'
run: |
if (-not (Test-Path results.json)) {
exit 1
}

echo '<details>' >> $env:GITHUB_STEP_SUMMARY
echo '' >> $env:GITHUB_STEP_SUMMARY
echo '```json' >> $env:GITHUB_STEP_SUMMARY
Get-Content -Path results.json >> $env:GITHUB_STEP_SUMMARY
echo '' >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
echo '' >> $env:GITHUB_STEP_SUMMARY
echo '</details>' >> $env:GITHUB_STEP_SUMMARY

$content = Get-Content -Path results.json -Raw
if (-not $content.StartsWith('[]')) {
exit 1
}

- name: Archive output base (unix)
if: runner.os != 'Windows' && always()
run: |
if [[ -d "${{ matrix.work_dir }}/o" ]]; then
tar -czf output-base.tar.gz -C "${{ matrix.work_dir }}" o
fi

- name: Archive output base (windows)
if: runner.os == 'Windows' && always()
run: |
if (Test-Path "${{ matrix.work_dir }}\o") {
Compress-Archive -Path "${{ matrix.work_dir }}\o" -DestinationPath output-base.zip
}

- name: Upload output base artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: output-base-${{ matrix.os }}
path: |
output-base.tar.gz
output-base.zip
if-no-files-found: ignore
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ use_repo(
"buildkite_config",
"generated_inputs_in_external_repo",
"libc",
"rrtd",
"rrtd__anyhow-1.0.100",
"rrtd__blake3-1.8.2",
"rrtd__clap-4.5.50",
"rrtd__serde-1.0.228",
"rrtd__serde_json-1.0.145",
"rrtd__tempfile-3.23.0",
"rrtd__tokio-1.48.0",
"rrtd__tracing-0.1.41",
"rrtd__tracing-subscriber-0.3.20",
"rrtd__walkdir-2.5.0",
"rtra",
"rtra__serde-1.0.219",
"rtra__serde_json-1.0.143",
Expand Down
2 changes: 1 addition & 1 deletion test/cargo_build_script/compile_data/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
pub fn test_compile_data() {
let data = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/", env!("DATA")));

assert_eq!("La-Li-Lu-Le-Lo\n", data);
assert_eq!("La-Li-Lu-Le-Lo", data.trim());
}
2 changes: 2 additions & 0 deletions test/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//test/determinism/3rdparty/crates:crates.bzl", determinism_test_crate_repositories = "crate_repositories")
load("//test/generated_inputs:external_repo.bzl", "generated_inputs_in_external_repo")
load("//test/load_arbitrary_tool:load_arbitrary_tool_test.bzl", "load_arbitrary_tool_test")
load("//test/rust_analyzer/3rdparty/crates:crates.bzl", rust_analyzer_test_crate_repositories = "crate_repositories")
Expand Down Expand Up @@ -40,6 +41,7 @@ def rules_rust_test_deps(is_bzlmod = False):
direct_deps = load_arbitrary_tool_test()
direct_deps.extend(generated_inputs_in_external_repo())
direct_deps.extend(rust_analyzer_test_crate_repositories())
direct_deps.extend(determinism_test_crate_repositories())

maybe(
http_archive,
Expand Down
34 changes: 34 additions & 0 deletions test/determinism/3rdparty/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("//crate_universe:defs.bzl", "crate", "crates_vendor")

crates_vendor(
name = "crates_vendor",
cargo_lockfile = "Cargo.Bazel.lock",
mode = "remote",
packages = {
"anyhow": crate.spec(version = "1.0.97"),
"blake3": crate.spec(version = "1.6.1"),
"clap": crate.spec(
features = [
"derive",
"env",
],
version = "4.5.32",
),
"serde": crate.spec(
features = ["derive"],
version = "1.0.219",
),
"serde_json": crate.spec(version = "1.0.140"),
"tempfile": crate.spec(version = "3.19.0"),
"tokio": crate.spec(
features = ["full"],
version = "1.44.1",
),
"tracing": crate.spec(version = "0.1.41"),
"tracing-subscriber": crate.spec(version = "0.3.19"),
"walkdir": crate.spec(version = "2.5.0"),
},
# `rrtd` == `rules_rust_test_determinism`
repository_name = "rrtd",
tags = ["manual"],
)
Loading