Skip to content

Commit c29794b

Browse files
authored
Merge pull request #273 from truthixify/fix-ci
fixing ci
2 parents 0de3424 + 1dcd6c5 commit c29794b

File tree

5 files changed

+144
-64
lines changed

5 files changed

+144
-64
lines changed

.github/workflows/CI.yaml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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"

contracts/.github/workflows/CI.yaml

Lines changed: 0 additions & 53 deletions
This file was deleted.

contracts/assetsup_contract/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#![no_std]
2-
use soroban_sdk::{contract, contracttype, contractimpl, Address, Env};
2+
use soroban_sdk::{Address, Env, contract, contractimpl, contracttype};
33

44
#[contracttype]
55
#[derive(Clone, Debug, Eq, PartialEq)]
66
pub enum DataKey {
7-
Admin
7+
Admin,
88
}
99

1010
#[contract]
1111
pub struct AssetUpContract;
1212

1313
#[contractimpl]
1414
impl AssetUpContract {
15-
pub fn initialize(env: Env, admin: Address){
15+
pub fn initialize(env: Env, admin: Address) {
1616
admin.require_auth();
1717

1818
if env.storage().persistent().has(&DataKey::Admin) {
@@ -26,4 +26,4 @@ impl AssetUpContract {
2626
}
2727
}
2828

29-
mod tests;
29+
mod tests;
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
#![cfg(test)]
32

43
extern crate std;
54

6-
use soroban_sdk::{testutils::{Address as _,}, Address, Env};
75
use crate::{AssetUpContract, AssetUpContractClient};
6+
use soroban_sdk::{Address, Env, testutils::Address as _};
87

98
/// Setup test environment with contract and addresses
109
pub fn setup_test_environment() -> (Env, AssetUpContractClient<'static>, Address) {
@@ -13,9 +12,9 @@ pub fn setup_test_environment() -> (Env, AssetUpContractClient<'static>, Address
1312

1413
let contract_id = env.register(AssetUpContract, ());
1514
let client = AssetUpContractClient::new(&env, &contract_id);
16-
15+
1716
let admin = Address::generate(&env);
18-
17+
1918
(env, client, admin)
2019
}
2120

@@ -28,11 +27,10 @@ fn test_initialize() {
2827
assert_eq!(admin, saved_admin);
2928
}
3029

31-
3230
#[test]
3331
#[should_panic()]
3432
fn test_initialize_panic() {
3533
let (_env, client, admin) = setup_test_environment();
3634
client.initialize(&admin);
3735
client.initialize(&admin);
38-
}
36+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mod initialize;
1+
mod initialize;

0 commit comments

Comments
 (0)