-
Notifications
You must be signed in to change notification settings - Fork 208
162 lines (139 loc) · 5.84 KB
/
Copy pathci.yml
File metadata and controls
162 lines (139 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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