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

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths:
- test/determinism/**

jobs:
check:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- ubuntu-24.04-arm
- windows-latest

runs-on: ${{ matrix.os }}
name: Check (${{ matrix.os }})

steps:
- uses: actions/checkout@v4
with:
clean: true

- uses: bazel-contrib/setup-bazel@0.14.0
with:
bazelisk-cache: true
repository-cache: true

- name: Choose a work directory (unix)
if: runner.os != 'Windows'
shell: bash
run: |
echo "WORK_DIR=$RUNNER_TEMP/r" >> "$GITHUB_ENV"

- name: Choose a work directory (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
"WORK_DIR=C:\r" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

- name: Run tests (unix)
continue-on-error: true
run: >-
bazel run
--compilation_mode=opt
//test/determinism:tester
-- test
--output="${{ github.workspace }}/results.json"
--work-dir="${{ env.WORK_DIR }}"

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

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

if [[ "$(cat results.json)" != "[]"* ]]; then
exit 1
fi

- name: Summarize (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
if (-not (Test-Path results.json)) { exit 1 }

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

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

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

- name: Archive output base (windows)
if: runner.os == 'Windows' && always()
shell: pwsh
run: |
if (Test-Path "${{ env.WORK_DIR }}\o") {
Compress-Archive -Path "${{ env.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.228",
"rtra__serde_json-1.0.149",
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 @@ -42,6 +43,7 @@ def rules_rust_test_deps(is_bzlmod = False):
direct_deps.extend(generated_inputs_in_external_repo())
direct_deps.extend(rust_analyzer_test_crate_repositories())
direct_deps.extend(vscode_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
Loading