1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ env :
10+ CARGO_TERM_COLOR : always
11+
12+ defaults :
13+ run :
14+ working-directory : contracts # 👈 all cargo commands run in contracts/
15+
16+ jobs :
17+ format :
18+ name : Format Check
19+ runs-on : ubuntu-latest
20+ steps :
21+ - uses : actions/checkout@v4
22+ - name : Install Rust toolchain
23+ uses : dtolnay/rust-toolchain@stable
24+ with :
25+ components : rustfmt
26+ - name : Check formatting
27+ run : cargo fmt --all -- --check
28+
29+ clippy :
30+ name : Clippy Lint
31+ runs-on : ubuntu-latest
32+ steps :
33+ - uses : actions/checkout@v4
34+ - name : Install Rust toolchain
35+ uses : dtolnay/rust-toolchain@stable
36+ with :
37+ components : clippy
38+ - name : Cache cargo registry
39+ uses : actions/cache@v4
40+ with :
41+ path : |
42+ ~/.cargo/registry
43+ ~/.cargo/git
44+ contracts/target
45+ key : ${{ runner.os }}-cargo-${{ hashFiles('contracts/Cargo.lock') }}
46+ restore-keys : |
47+ ${{ runner.os }}-cargo-
48+ - name : Run clippy
49+ run : cargo clippy --all-targets --all-features -- -D warnings
50+
51+ test :
52+ name : Test Suite
53+ runs-on : ubuntu-latest
54+ steps :
55+ - uses : actions/checkout@v4
56+ - name : Install Rust toolchain
57+ uses : dtolnay/rust-toolchain@stable
58+ - name : Cache cargo registry
59+ uses : actions/cache@v4
60+ with :
61+ path : |
62+ ~/.cargo/registry
63+ ~/.cargo/git
64+ contracts/target
65+ key : ${{ runner.os }}-cargo-test-${{ hashFiles('contracts/Cargo.lock') }}
66+ restore-keys : |
67+ ${{ runner.os }}-cargo-test-
68+ ${{ runner.os }}-cargo-
69+ - name : Run tests
70+ run : cargo test --all --verbose
71+
72+ build :
73+ name : Build Check
74+ runs-on : ubuntu-latest
75+ steps :
76+ - uses : actions/checkout@v4
77+ - name : Install Rust toolchain
78+ uses : dtolnay/rust-toolchain@stable
79+ - name : Cache cargo registry
80+ uses : actions/cache@v4
81+ with :
82+ path : |
83+ ~/.cargo/registry
84+ ~/.cargo/git
85+ contracts/target
86+ key : ${{ runner.os }}-cargo-build-${{ hashFiles('contracts/Cargo.lock') }}
87+ restore-keys : |
88+ ${{ runner.os }}-cargo-build-
89+ ${{ runner.os }}-cargo-
90+ - name : Build all crates
91+ run : cargo build --all --verbose
92+
93+ wasm-check :
94+ name : WASM Compatibility Check
95+ runs-on : ubuntu-latest
96+ steps :
97+ - uses : actions/checkout@v4
98+ - name : Install Rust toolchain
99+ uses : dtolnay/rust-toolchain@stable
100+ with :
101+ targets : wasm32-unknown-unknown
102+ - name : Cache cargo registry
103+ uses : actions/cache@v4
104+ with :
105+ path : |
106+ ~/.cargo/registry
107+ ~/.cargo/git
108+ contracts/target
109+ key : ${{ runner.os }}-cargo-wasm-${{ hashFiles('contracts/Cargo.lock') }}
110+ restore-keys : |
111+ ${{ runner.os }}-cargo-wasm-
112+ ${{ runner.os }}-cargo-
113+ - name : Build for WASM target
114+ run : cargo build --all --target wasm32-unknown-unknown --verbose
115+
116+ ci-success :
117+ name : CI Success
118+ runs-on : ubuntu-latest
119+ needs : [format, clippy, test, build, wasm-check]
120+ if : always()
121+ defaults :
122+ run :
123+ working-directory : .
124+ steps :
125+ - name : Check all jobs
126+ run : |
127+ if [[ "${{ needs.format.result }}" != "success" || \
128+ "${{ needs.clippy.result }}" != "success" || \
129+ "${{ needs.test.result }}" != "success" || \
130+ "${{ needs.build.result }}" != "success" || \
131+ "${{ needs.wasm-check.result }}" != "success" ]]; then
132+ echo "One or more CI jobs failed"
133+ exit 1
134+ fi
135+ echo "All CI jobs passed successfully"
0 commit comments