Skip to content

Commit 54fa330

Browse files
authored
Merge pull request #523 from AmbireTech/improve-ci-checks
Improve CI checks
2 parents 9625da4 + 0f42897 commit 54fa330

File tree

53 files changed

+225
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+225
-170
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,66 @@
11
on: [push, pull_request]
22

3+
# Stops the running workflow of previous pushes
4+
concurrency:
5+
group: ${{ github.ref }}
6+
cancel-in-progress: true
7+
38
name: Continuous Integration
49

510
jobs:
6-
ci-flow:
7-
name: cargo make ci-flow - Tests, clippy & rustfmt
11+
lint-rustfmt:
12+
name: Running lint - rustfmt
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
submodules: true
18+
- uses: actions-rs/toolchain@v1
19+
with:
20+
# No need to add `toolchain`, it will use `rust-toolchain` file instead
21+
profile: minimal
22+
components: rustfmt
23+
- uses: davidB/rust-cargo-make@v1
24+
- name: Rustfmt
25+
# we don't use the check-format-ci-flow because it requires nightly (cargo-make)
26+
run: cargo make check-format-flow
27+
lint-clippy:
28+
name: Running lint - clippy
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
submodules: true
34+
- uses: actions-rs/toolchain@v1
35+
with:
36+
# No need to add `toolchain`, it will use `rust-toolchain` file instead
37+
profile: minimal
38+
components: clippy
39+
- uses: davidB/rust-cargo-make@v1
40+
- name: Run Clippy
41+
# we don't use the clippy-ci-flow because it requires nightly (cargo-make)
42+
run: cargo make clippy-flow
43+
check-docs:
44+
name: Rustdoc build check
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
with:
49+
submodules: true
50+
- uses: actions-rs/toolchain@v1
51+
with:
52+
# No need to add `toolchain`, it will use `rust-toolchain` file instead
53+
profile: minimal
54+
components: rust-docs
55+
- name: Build docs with no features
56+
run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --no-default-features
57+
- name: Build docs with --all-features
58+
run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --all-features
59+
test-flow:
60+
name: cargo make ci-flow - Tests
861
runs-on: ubuntu-latest
962
steps:
10-
- uses: actions/checkout@v2
63+
- uses: actions/checkout@v3
1164
with:
1265
submodules: true
1366
# Runs all services needed for testing
@@ -19,9 +72,7 @@ jobs:
1972
- uses: actions-rs/toolchain@v1
2073
with:
2174
# No need to add `toolchain`, it will use `rust-toolchain` file instead
22-
profile: default
23-
override: true
24-
components: clippy, rustfmt
75+
profile: minimal
2576
- uses: davidB/rust-cargo-make@v1
2677
- name: Run `cargo make ci-flow`
2778
# Running cargo make doesn't successfully start `ganache`

.github/workflows/docs.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ jobs:
1010
name: Deploy docs on gh-pages
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
with:
1515
submodules: true
16+
- uses: actions-rs/toolchain@v1
17+
with:
18+
# Use nightly to build the docs with `--cfg docsrs`
19+
toolchain: nightly
20+
profile: minimal
21+
components: rust-docs
1622
- name: Build docs
17-
run: cargo doc --no-deps
23+
run: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --workspace
1824
- name: Prepare /docs & index file
1925
run: |
2026
rm -rf ./docs

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: startsWith(github.event.ref, 'refs/tags/validator-v')
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
with:
1515
submodules: true
1616
# See https://github.community/t/how-to-get-just-the-tag-name/16241/10

Makefile.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[env]
22
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
3-
CARGO_MAKE_CLIPPY_ARGS = "--all-features -- -D warnings"
3+
CARGO_MAKE_CLIPPY_ARGS = "--all-features --no-deps -- -D warnings"
44
CARGO_MAKE_RUN_TOML_FORMAT = "true"
55
CARGO_MAKE_RUN_CHECK_FORMAT = "true"
66
CARGO_MAKE_RUN_CLIPPY = "true"
77

88
[tasks.dev-test-flow]
99
dependencies = [
10-
"format-flow",
1110
"format-toml-conditioned-flow",
12-
"clippy",
11+
"format-flow",
12+
"clippy-flow",
1313
"pre-build",
1414
"build",
1515
"post-build",

adapter/Makefile.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ extend = "../Makefile.toml"
44
description = "Development testing flow will first format the code, and than run cargo build and test"
55
category = "Development"
66
dependencies = [
7-
"format-flow",
87
"format-toml-conditioned-flow",
8+
"format-flow",
9+
"clippy-flow",
910
"pre-build",
1011
"build",
1112
"post-build",
@@ -15,14 +16,13 @@ dependencies = [
1516
]
1617

1718
[tasks.test]
18-
# run tests in release because of slow unlock time of Ethereum adapter (i.e. keystore decryption)
19-
args = ["test", "--release", "--all-features"]
19+
args = ["test", "--all-features"]
2020

2121
[tasks.ganache-up]
2222
# `--renew-anon-volumes` is required to make sure that the snapshot used for the `ganache` instances is reloaded.
2323
script = '''
2424
docker-compose -f ../docker-compose.harness.yml up --renew-anon-volumes -d ganache-1 ganache-1337 \
25-
&& sleep 10
25+
&& sleep 6
2626
'''
2727

2828
[tasks.ganache-down]

adapter/src/dummy.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use primitives::{
1414
use std::collections::HashMap;
1515

1616
#[doc(inline)]
17-
pub use self::deposit::Deposits;
17+
pub use self::deposit::{Deposits, Key};
1818

1919
pub type Adapter<S> = crate::Adapter<Dummy, S>;
2020

@@ -66,8 +66,6 @@ impl Dummy {
6666
depositor: Address,
6767
deposit: D,
6868
) {
69-
use deposit::Key;
70-
7169
let key = Key::from_chain_of(channel_context, depositor);
7270
match deposit.into() {
7371
Some(deposit) => {
@@ -261,6 +259,7 @@ mod deposit {
261259
use primitives::{Address, ChainId, ChainOf, Channel, ChannelId};
262260
use std::sync::Arc;
263261

262+
/// The Key for deposits that are unique for retrieving a Dummy deposit.
264263
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
265264
pub struct Key {
266265
channel_id: ChannelId,

adapter/src/ethereum/client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ mod test {
619619
async fn multi_chain_deposit_from_config() -> Result<(), Box<dyn std::error::Error>> {
620620
let config = GANACHE_CONFIG.clone();
621621

622-
let mut channel_1 = DUMMY_CAMPAIGN.channel.clone();
622+
let mut channel_1 = DUMMY_CAMPAIGN.channel;
623623
let channel_1_token = GANACHE_INFO_1.tokens["Mocked TOKEN 1"].clone();
624624
channel_1.token = channel_1_token.address;
625625

@@ -699,11 +699,10 @@ mod test {
699699
.expect("Should have Ganache #1 already in config");
700700

701701
assert!(
702-
ganache_1
702+
!ganache_1
703703
.tokens
704704
.values()
705-
.find(|existing_token| { existing_token.address == token.info.address })
706-
.is_none(),
705+
.any(|existing_token| { existing_token.address == token.info.address }),
707706
"The deployed token address should not have existed previously in the config!"
708707
);
709708

adapter/src/ethereum/ewt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl Token {
139139

140140
let token_parts = token.splitn(3, '.').collect::<Vec<_>>();
141141
let ((header_encoded, payload_encoded), signature_encoded) = token_parts
142-
.get(0)
142+
.first()
143143
.zip(token_parts.get(1))
144144
.zip(token_parts.get(2))
145145
.ok_or(EwtVerifyError::InvalidToken)?;
@@ -236,7 +236,7 @@ mod test {
236236
// Eth
237237
chain_id: ChainId::new(1),
238238
};
239-
let wallet = eth_adapter.state.wallet.clone();
239+
let wallet = eth_adapter.state.wallet;
240240
let token = Token::sign(&wallet, payload).expect("failed to generate ewt signature");
241241
let expected = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFVEgifQ.eyJpZCI6IjB4ODA2OTA3NTE5NjlCMjM0Njk3ZTkwNTllMDRlZDcyMTk1YzM1MDdmYSIsImVyYSI6MTAwMDAwLCJhZGRyZXNzIjoiMHhhQ0JhREEyZDU4MzBkMTg3NWFlM0QyZGUyMDdBMTM2M0IzMTZEZjJGIiwiY2hhaW5faWQiOjF9.GxF4XDXMx-rRty5zQ7-0nx2VlX51R_uEs_7OfA5ezDcyryUS06IWqVgGIfu4chhRJFP7woZ1YJpARNbCE01nWxwB";
242242
assert_eq!(token.as_str(), expected, "generated wrong ewt signature");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"address":"0e45891a570af9e5a962f181c219468a6c9eb4e1","crypto":{"cipher":"aes-128-ctr","ciphertext":"639873e843cdf99a0c09cf24ee56569f35b4ebffeb054bf2b181f5c21545acee","cipherparams":{"iv":"281838b5a67842e79f8abe5cfb252567"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f2843ca233d543de6b545660b76f5a310ed30b50a0fbde7d6806d7fb53266711"},"mac":"9e73a152fcd224bfedf4625311ab625504a8a44f920d12bdc37884bead529941"},"id":"b757f415-d9f5-4c5e-b0ef-27a3b664d699","version":3}
1+
{"address":"0e45891a570af9e5a962f181c219468a6c9eb4e1","crypto":{"cipher":"aes-128-ctr","ciphertext":"7855c754157c4d6f3e46d9a6b4ad36e345f93ae7a82a961ef2b480055b5d7de1","cipherparams":{"iv":"e7bde7b532173c194994be8bd4035a21"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"8e6e57cc562375d521ecbb9691dc920c4afd1cf6b8a8569a81ba95b7dc46be4a"},"mac":"5aec65224313526d20fd15f3746c8677abc07ffe0eb2f0137d8acead8db8568d"},"id":"252fedc0-53ea-453a-9ce7-1940b4dcdc8f","version":3}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"address":"0e880972a4b216906f05d67eeaaf55d16b5ee4f1","crypto":{"cipher":"aes-128-ctr","ciphertext":"a6517c853f41d70892195c2d49b6bf9cb70b28714df9148a2115422582ed71a7","cipherparams":{"iv":"29a072ed18b810e36461a4dafa3b8816"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"4647c8d015db3c67db397f291c13440b5a657f391470d02568c797d22252ee19"},"mac":"b9a6db84659a13b0d895418a9cff0a2b7b5f671ece4ea5c58b3c6cb403ad5a13"},"id":"be2aa04b-63d8-48ac-8d3b-3ed09a9d88b1","version":3}
1+
{"address":"0e880972a4b216906f05d67eeaaf55d16b5ee4f1","crypto":{"cipher":"aes-128-ctr","ciphertext":"8fc0abf80cd0c5c80322a323ae01fd6d9dfe310a7b2efa001bf7902cd63c6897","cipherparams":{"iv":"bd65e4a245eca4829f82de94676e427e"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"4203bb6a0822bfbb3597bfb755658bc14c9cb2044e8122f88e19b9f811a87393"},"mac":"80b81fcd0a677b59e53c709e155983ea9671f26f3a96394ee6d108797aab6cad"},"id":"22eb2ffb-2ffa-465d-b20c-234263ed0f56","version":3}

0 commit comments

Comments
 (0)