Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pmikolajczyk41 committed Jun 19, 2023
1 parent aea3bd4 commit 08f069a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/rust-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Builds unit test binary and run unit tests, runs static rust code analysis and code formatting

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:


jobs:
main:
name: Run check, test and lints
runs-on: [self-hosted, Linux, X64, large]
env:
CARGO_INCREMENTAL: 0
RUSTC_WRAPPER: sccache
steps:
- name: Checkout Source code
uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v1
with:
targets: wasm32-unknown-unknown
components: clippy rustfmt

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

- name: Run Linter
uses: actions-rs/cargo@v1
env:
# https://github.com/mozilla/sccache/issues/966
RUSTC_WRAPPER: ""
RUSTC_WORKSPACE_WRAPPER: sccache
with:
command: clippy
args: --all-targets -- --no-deps -D warnings

- name: Run Unit Test Suite
uses: actions-rs/cargo@v1
with:
command: test
11 changes: 11 additions & 0 deletions drink-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ pub enum CliCommand {
#[clap(alias = "e")]
Exit,
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn verify_cli() {
use clap::CommandFactory;
CliCommand::command().debug_assert()
}
}
4 changes: 2 additions & 2 deletions drink-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sp_runtime::AccountId32;

mod cli;

const CONTRACT_DIR: &'static str = "../example/";
const CONTRACT_DIR: &str = "../example/";

fn main() {
let mut sandbox = Sandbox::new();
Expand All @@ -21,7 +21,7 @@ fn main() {
.read_line(&mut user_input)
.expect("Failed to get user input");

let cli_command = match CliCommand::try_parse_from(&["", user_input.trim()]) {
let cli_command = match CliCommand::try_parse_from(["", user_input.trim()]) {
Ok(cli_command) => cli_command,
Err(_) => {
eprintln!("Invalid command");
Expand Down
6 changes: 6 additions & 0 deletions drink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ impl Display for CallResult {
}
}

impl Default for Sandbox {
fn default() -> Self {
Self::new()
}
}

impl Sandbox {
pub fn new() -> Self {
let mut storage = frame_system::GenesisConfig::default()
Expand Down

0 comments on commit 08f069a

Please sign in to comment.