Skip to content

feat: enforce and test aggregate holder share bps invariant #1077

feat: enforce and test aggregate holder share bps invariant

feat: enforce and test aggregate holder share bps invariant #1077

Workflow file for this run

name: CI
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
workflow_dispatch:
inputs:
toolchain:
description: "Rust toolchain version"
required: true
default: "1.79.0"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
toolchain: stable
# Treat every clippy warning as a hard error in CI.
# Mirrors the #![deny(clippy::...)] attributes in src/lib.rs so local and
# remote checks are identical. Developers must run:
# cargo fmt --all -- --check
# cargo clippy --all-targets --all-features -- -D warnings
# before pushing. See docs/clippy-format-gate-hardening.md for details.
RUSTFLAGS: "-D warnings"
jobs:
# ── 1. Format gate ────────────────────────────────────────────────────────
fmt:
name: Format check (cargo fmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable + rustfmt)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
# Hard failure: unformatted code blocks the PR.
# Auto-commit is intentionally removed — contributors must format locally.
# Local command: cargo fmt --all -- --check
- name: Check formatting
run: cargo fmt --all -- --check
# ── 2. Clippy gate ────────────────────────────────────────────────────────
clippy:
name: Clippy lint check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable + clippy)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-clippy-
# -D warnings: every warning is a hard error.
# --all-targets: includes tests, benches, examples.
# --all-features: exercises feature-gated code paths.
# Local command: cargo clippy --all-targets --all-features -- -D warnings
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# ── 3. Event-sunset table validation ─────────────────────────────────────
# Ensures every entry in docs/EVENT_SUNSET.yaml has a non-null sunset_epoch
# and that docs/EVENT_SUNSET.json is in sync with the YAML source of truth.
#
# How to fix failures:
# a) If "VALIDATION ERRORS" → add sunset_epoch to the offending entry in
# docs/EVENT_SUNSET.yaml.
# b) If "JSON is stale" → run `python3 scripts/generate_event_sunset_json.py`
# locally and commit the regenerated docs/EVENT_SUNSET.json.
# c) If Python tests fail → fix the generator logic in
# scripts/generate_event_sunset_json.py.
event_sunset:
name: Event-sunset table validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install pyyaml
- name: Run unit tests for the sunset generator
run: python3 -m unittest scripts/test_event_sunset.py -v
# Validates that:
# 1. Every deprecated topic has a non-null sunset_epoch.
# 2. No duplicate topic names exist.
# 3. docs/EVENT_SUNSET.json exactly matches what the generator
# would produce from the current docs/EVENT_SUNSET.yaml.
- name: Check EVENT_SUNSET.json is up-to-date with YAML
run: python3 scripts/generate_event_sunset_json.py --check
# ── 4. Build + test ───────────────────────────────────────────────────────
test:
name: Build and test
runs-on: ubuntu-latest
needs: [fmt, clippy]
steps:
- uses: actions/checkout@v4
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml', '**/src/**') }}
restore-keys: |
${{ runner.os }}-cargo-test-
- name: Build
run: cargo build --release
- name: Check storage layout JSON drift
run: cargo test --test storage_layout_json storage_layout_json_matches_checked_in_docs -- --exact --test-threads=1
# Verify indexer/event_sunset.json is in sync with docs/EVENT_SUNSET.yaml.
# The generator validates every entry has a non-zero sunset_epoch and no
# chained deprecations. Run locally: python3 scripts/gen_event_sunset.py
- name: Check event sunset JSON drift
run: python3 scripts/gen_event_sunset.py --check
# Validate the event sunset JSON is also covered by the Rust integration
# test (tests/event_sunset_json.rs).
- name: Test event sunset JSON (Rust integration)
run: cargo test --test event_sunset_json -- --test-threads=1
# --test-threads=1 keeps Soroban test output deterministic.
# Local command: cargo test -- --test-threads=1
- name: Test
run: cargo test -- --test-threads=1
env:
RUST_BACKTRACE: full