Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI actions #32

Merged
merged 8 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"
clippy-all = "clippy --all-targets -- -D warnings"
schema = "run --bin -schema"
75 changes: 75 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Check Build and Tests

on:
push:
branches: [ main ]
pull_request:

workflow_dispatch:

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.76.0
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

# - name: Generate Schema
# uses: actions-rs/cargo@v1
# with:
# command: schema
# args: --locked

# - name: Schema Changes
# # fails if any changes not committed
# run: git diff --exit-code schema

test:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.76.0
target: wasm32-unknown-unknown
override: true

- name: Run unit tests
uses: actions-rs/cargo@v1
with:
command: test
args: --locked
env:
RUST_BACKTRACE: 1

- name: Compile WASM contract
uses: actions-rs/cargo@v1
with:
command: wasm
args: --locked
env:
RUSTFLAGS: "-C link-arg=-s"
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Contracts

on:
release:
types: [published]
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install cargo-run-script
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-run-script
- name: Run cargo optimize
uses: actions-rs/cargo@v1
with:
command: run-script
args: optimize
- name: Get release ID
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload optimized wasm
uses: svenstaro/[email protected]

with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./artifacts/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Neutron Contracts

[![Check Set-Up & Build](https://github.com/timewave-computer/valence-services/actions/workflows/check.yml/badge.svg)](https://github.com/timewave-computer/valence-services/actions/workflows/check.yml)

## Code ids

- auctions manager = `1762`
Expand Down
14 changes: 7 additions & 7 deletions contracts/services/rebalancer/src/rebalance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ pub fn execute_system_rebalance(

for res in configs {
let Ok((account, config)) = res else {
continue;
};
continue;
};

last_addr = Some(account.clone());

Expand All @@ -131,7 +131,7 @@ pub fn execute_system_rebalance(
cycle_period,
);
let Ok((config, msg)) = rebalance_res else {
continue
continue;
};

// Rebalacing does edit some config fields that are needed for future rebalancing
Expand Down Expand Up @@ -264,7 +264,7 @@ pub(crate) fn set_auction_min_amounts(
to_sell: &mut Vec<TargetHelper>,
min_amount_limits: &mut Vec<(String, Uint128)>,
) -> Result<(), ContractError> {
for mut sell_token in to_sell {
for sell_token in to_sell {
match min_amount_limits
.iter()
.find(|min_amount| min_amount.0 == sell_token.target.denom)
Expand Down Expand Up @@ -606,7 +606,7 @@ fn generate_trades_msgs(

// This is the main loop where we match to_sell tokens with to_buy tokens
to_sell.into_iter().for_each(|mut token_sell| {
to_buy.iter_mut().for_each(|mut token_buy| {
to_buy.iter_mut().for_each(|token_buy| {
// If we already bought all we need for this token we continue to next buy token
if token_buy.value_to_trade.is_zero() {
return;
Expand Down Expand Up @@ -673,7 +673,7 @@ fn generate_trades_msgs(
token_buy.value_to_trade = Decimal::zero();

let Ok(msg) = construct_msg(deps, auction_manager, pair, coin) else {
return
return;
};
msgs.push(msg);
} else {
Expand All @@ -689,7 +689,7 @@ fn generate_trades_msgs(
token_sell.value_to_trade = Decimal::zero();

let Ok(msg) = construct_msg(deps, auction_manager, pair, coin) else {
return
return;
};

msgs.push(msg);
Expand Down
1 change: 0 additions & 1 deletion contracts/services_manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ pub fn query(deps: Deps, _env: Env, msg: ServicesManagerQueryMsg) -> StdResult<B
cosmwasm_std::Order::Ascending,
)
.take(limit)
.map(|item| item.map(|(name, addr)| (name, addr)))
.collect::<StdResult<Vec<(String, Addr)>>>()?;

to_json_binary(&services)
Expand Down
2 changes: 1 addition & 1 deletion packages/valence-macros/src/macros_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn merge_variants(
}),
) = (&mut left.data, right.data)
{
variants.extend(to_add.into_iter());
variants.extend(to_add);

quote! { #left }.into()
} else {
Expand Down
8 changes: 3 additions & 5 deletions packages/valence-package/src/signed_decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,9 @@ impl<'de> de::Visitor<'de> for SignedDecimalVisitor {
{
match SignedDecimal::from_str(v) {
Ok(d) => Ok(d),
Err(e) => {
return Err(E::custom(format!(
"Error parsing signed decimal '{v}': {e}"
)))
}
Err(e) => Err(E::custom(format!(
"Error parsing signed decimal '{v}': {e}"
))),
}
}
}
Expand Down
Loading