-
Notifications
You must be signed in to change notification settings - Fork 123
112 lines (97 loc) · 3.58 KB
/
ci.yml
File metadata and controls
112 lines (97 loc) · 3.58 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
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. 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
# --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