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

Refactor ci flow #166

Merged
merged 3 commits into from
May 6, 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
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/commit_verify"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/commit_verify/derive"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/single_use_seals"
schedule:
interval: "weekly"
39 changes: 13 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# NOTE: Dont use nix here, everything should be based on the ubuntu-latest
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Default build
- name: Latest Ubuntu build check
uses: actions-rs/cargo@v1
with:
command: check
Expand All @@ -38,21 +39,12 @@ jobs:
- all
steps:
- uses: actions/checkout@v2
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Feature ${{ matrix.feature }}
uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features --features=${{ matrix.feature }}
- name: Defaults + ${{ matrix.feature }}
uses: actions-rs/cargo@v1
with:
command: check
args: --features=${{ matrix.feature }}
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Check feature ${{ matrix.feature }} only
run: nix develop .#stable -c cargo check --no-default-features --features=${{ matrix.feature }}
- name: Check feature ${{ matrix.feature }} with defaults
run: nix develop .#stable -c cargo check --features=${{ matrix.feature }}
platforms:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -61,6 +53,7 @@ jobs:
os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, windows-2019, windows-2022 ]
steps:
- uses: actions/checkout@v2
# NOTE: Dont use nix in platform checks everything should based on the host system
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
Expand All @@ -76,16 +69,10 @@ jobs:
strategy:
fail-fast: false
matrix:
toolchain: [ nightly, beta, stable, 1.69.0 ]
toolchain: [ nightly, beta, stable, msrv ]
steps:
- uses: actions/checkout@v2
- name: Install rust ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: All features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --all-features
run: nix develop ".#${{ matrix.toolchain }}" -c cargo check --workspace --all-targets --all-features
40 changes: 12 additions & 28 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,23 @@ jobs:
codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, llvm-tools-preview
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
run: nix develop .#codecov -c cargo build --release
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
run: nix develop .#codecov -c cargo test --all-features --no-fail-fast --tests
- name: Install grcov
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
run: nix develop .#codecov -c cargo install grcov
- name: Generate coverage
run: grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov
run: nix develop .#codecov -c grcov . --binary-path target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../**' --ignore '/*' -o coverage.lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./coverage.lcov
flags: rust
fail_ci_if_error: true
# TODO: set true when CODECOV_TOKEN is set
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49 changes: 14 additions & 35 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rustc nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
name: Formatting
with:
command: fmt
args: --all -- --check
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Formatting
run: nix develop .#nightly -c cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rustc stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- uses: actions-rs/cargo@v1
name: Clippy
with:
command: clippy
args: --workspace --all-features --all-targets -- -D warnings
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Clippy
run: nix develop .#stable -c cargo clippy --workspace --all-features --all-targets -- -D warnings
doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install rustc nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rust-docs
- uses: actions-rs/cargo@v1
name: Doc
with:
command: doc
args: --workspace --all-features
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Doc
run: nix develop .#nightly -c cargo doc --workspace --all-features
12 changes: 3 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Build & test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features --no-fail-fast
run: nix develop .#stable -c cargo test --workspace --all-features --no-fail-fast
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ version = "0.11.0-beta.5"
authors = ["Dr Maxim Orlovsky <[email protected]>"]
homepage = "https://github.com/LNP-BP"
repository = "https://github.com/LNP-BP/client_side_validation"
rust-version = "1.69" # Due to TOML in amplify dependency
rust-version = "1.69.0" # Due to TOML in amplify dependency
edition = "2021"
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion commit_verify/src/mpc/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl MerkleProof {
/// Returns the root of the merkle path.
///
/// If the MPC proof contains only a single message returns None
pub fn merkle_root(&self) -> Option<MerkleHash> { self.path.get(0).copied() }
pub fn merkle_root(&self) -> Option<MerkleHash> { self.path.first().copied() }

/// Convolves the proof with the `message` under the given `protocol_id`,
/// producing [`Commitment`].
Expand Down
85 changes: 85 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};

flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, rust-overlay, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};

cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);

stableWithLlvm = pkgs.rust-bin.nightly.latest.default.override {
extensions = [ "rustfmt" "llvm-tools-preview" ];
targets = [ ];
};
in
with pkgs;
{
devShells = rec {
default = msrv;

msrv = mkShell {
buildInputs = [
rust-bin.stable."${cargoToml.workspace.package."rust-version"}".default
];
};

stable = mkShell {
buildInputs = [
rust-bin.stable.latest.default
];
};

beta = mkShell {
buildInputs = [
rust-bin.beta.latest.default
];
};

nightly = mkShell {
buildInputs = [
rust-bin.nightly.latest.default
];
};

codecov = mkShell {
buildInputs = [
stableWithLlvm
];
CARGO_INCREMENTAL = "0";
RUSTFLAGS = "-Cinstrument-coverage";
RUSTDOCFLAGS = "-Cinstrument-coverage";
};
};
}
);
}
Loading