mirror of
https://github.com/block/buzz.git
synced 2026-11-03 07:51:22 +00:00
Address the review of the flake check port (99b21e4fb). An integration-only Playwright selection no longer fails flake-select: Playwright exits 1 with a lone "No tests found" error when the file filters match nothing in the smoke project, which listPlaywright now reads as an empty selection, as buzz-app's listBrowser does. Listed journeys are deduplicated, since a looped test() declaration is listed once per iteration, and a selection over 250 journeys skips the Playwright lane with a note: the smoke lane runs ~150 journey-runs per shard in ~11 minutes, so 250 journey-runs per shard across ten shards is what fits the 45-minute timeout after setup and the E2E build. Rust entries now carry the file and the test's in-file module path (`crates/.../auth.rs::tests::name`). repeatRust runs one cargo invocation per package with target flags derived from the path (src/** builds --lib --bins, tests/<stem>.rs builds --test <stem>), so a buzz-relay change no longer compiles every test target of the crate. It lists candidates by in-file path, prefers the test whose full name the file's path predicts, and falls back to every suffix match only when nothing matches (a `#[path]` module), so a same-named test in another module is no longer repeated for a change it never saw. The rust-cache bust knob moves into the shared key (`unit-tests-sherpa-cache-v1`) in both the Unit Tests and flake-rust jobs, since rust-cache ignores `key` once shared-key is set; the contract script checks both and the flake restore's save-if, and the regression harness covers both. flake-select installs desktop dependencies only when a spec changed. Changed .rs files without test functions get a summary row, test.fail() declarations count as tests, a captured nextest 0.9.136 list/JUnit pair pins the classname contract, and CONTRIBUTING lists what the lanes deliberately do not repeat. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
177 lines
4.6 KiB
Bash
Executable File
177 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
known_good='e18b497796c12c097a38f9edb9d0641fb99eee32'
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
mkdir -p "$tmp/.github/workflows"
|
|
cp "$root"/.github/workflows/*.yml "$tmp/.github/workflows/"
|
|
for workflow in "$root"/.github/workflows/*.yaml; do
|
|
[[ -e "$workflow" ]] || continue
|
|
cp "$workflow" "$tmp/.github/workflows/"
|
|
done
|
|
cp "$root/renovate.json" "$tmp/renovate.json"
|
|
|
|
run_contract() {
|
|
BUZZ_RUST_CACHE_CONTRACT_ROOT="$tmp" "$root/scripts/test-rust-cache-contract.sh"
|
|
}
|
|
|
|
expect_failure() {
|
|
local expected=$1
|
|
local output
|
|
if output=$(run_contract 2>&1); then
|
|
echo "expected rust cache contract failure containing: $expected" >&2
|
|
exit 1
|
|
fi
|
|
if [[ "$output" != *"$expected"* ]]; then
|
|
printf 'unexpected rust cache contract error:\n%s\n' "$output" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
write_cache_workflow() {
|
|
cat > "$tmp/.github/workflows/new-cache-user.yaml"
|
|
}
|
|
|
|
run_contract >/dev/null
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Bad digest
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
|
|
YAML
|
|
expect_failure 'restored rust-cache v2.9.2'
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Mutable tag
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: Swatinem/rust-cache@v2
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Expression ref
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: Swatinem/rust-cache@${{ matrix.cache-ref }}
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Spaced key
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses : Swatinem/rust-cache@v2
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Flow mapping
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- { uses: Swatinem/rust-cache@v2 }
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
|
|
write_cache_workflow <<'YAML'
|
|
name: Quoted key
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- "uses": Swatinem/rust-cache@v2
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
rm "$tmp/.github/workflows/new-cache-user.yaml"
|
|
|
|
mkdir -p "$tmp/.github/actions/cache"
|
|
cat > "$tmp/.github/actions/cache/action.yml" <<'YAML'
|
|
name: Unsafe cache wrapper
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- { uses: Swatinem/rust-cache@v2 }
|
|
YAML
|
|
write_cache_workflow <<'YAML'
|
|
name: Local cache wrapper
|
|
on: workflow_dispatch
|
|
jobs:
|
|
cache:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: ./.github/actions/cache
|
|
YAML
|
|
expect_failure 'rust-cache must stay on the v2.9.1 digest'
|
|
|
|
cat > "$tmp/.github/actions/cache/action.yml" <<YAML
|
|
name: Safe preferred cache wrapper
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: Swatinem/rust-cache@$known_good
|
|
YAML
|
|
cat > "$tmp/.github/actions/cache/action.yaml" <<'YAML'
|
|
name: Unreachable stale cache wrapper
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: Swatinem/rust-cache@v2
|
|
YAML
|
|
run_contract >/dev/null
|
|
rm -rf "$tmp/.github/actions" "$tmp/.github/workflows/new-cache-user.yaml"
|
|
|
|
cp "$root/.github/workflows/_ci-flake.yml" "$tmp/flake.orig"
|
|
python3 - "$tmp/.github/workflows/_ci-flake.yml" <<'PY'
|
|
import pathlib
|
|
import sys
|
|
|
|
path = pathlib.Path(sys.argv[1])
|
|
workflow = path.read_text()
|
|
needle = " shared-key: unit-tests-sherpa-cache-v1\n save-if: false\n"
|
|
if workflow.count(needle) != 1:
|
|
raise SystemExit("expected one flake-rust cache restore key")
|
|
path.write_text(workflow.replace(needle, " shared-key: unit-tests\n save-if: false\n"))
|
|
PY
|
|
expect_failure 'flake-rust rust-cache action must restore with.shared-key unit-tests-sherpa-cache-v1'
|
|
mv "$tmp/flake.orig" "$tmp/.github/workflows/_ci-flake.yml"
|
|
|
|
python3 - "$tmp/.github/workflows/_ci-rust.yml" <<'PY'
|
|
import pathlib
|
|
import sys
|
|
|
|
path = pathlib.Path(sys.argv[1])
|
|
workflow = path.read_text()
|
|
needle = " shared-key: unit-tests-sherpa-cache-v1\n save-if:"
|
|
replacement = " save-if:"
|
|
if workflow.count(needle) != 1:
|
|
raise SystemExit("expected one Unit Tests cache generation key")
|
|
workflow = workflow.replace(needle, replacement)
|
|
job = " unit-tests:\n"
|
|
if workflow.count(job) != 1:
|
|
raise SystemExit("expected one Unit Tests job")
|
|
workflow = workflow.replace(job, job + " env:\n shared-key: unit-tests-sherpa-cache-v1\n", 1)
|
|
path.write_text(workflow)
|
|
PY
|
|
expect_failure 'rust-cache action must keep with.shared-key set to unit-tests-sherpa-cache-v1'
|
|
|
|
echo "rust cache contract regressions passed"
|