Skip to content

Commit

Permalink
Merge pull request #1 from yanganto/ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
dr-orlovsky authored May 23, 2024
2 parents b37aac5 + c7eba7c commit 32d85b8
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 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: Latest Ubuntu build check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace
no-default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Latest Ubuntu build check no features
run: nix develop .#stable -c cargo check --workspace --no-default-features
features:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
feature:
- esplora_blocking
- log
- serde
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- 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:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, windows-2019, windows-2022 ]
steps:
- uses: actions/checkout@v4
# NOTE: Dont use nix in platform checks everything should based on the host system
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build with all features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --all-features
toolchains:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [ nightly, beta, stable, msrv ]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Check rgb-interfaces
run: nix develop ".#${{ matrix.toolchain }}" -c cargo check --workspace --all-targets --all-features
35 changes: 35 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Codecov

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Build
run: nix develop .#codecov -c cargo build --release
- name: Test
run: nix develop .#codecov -c cargo test --all-features --no-fail-fast --tests
- name: Install grcov
run: nix develop .#codecov -c cargo install grcov
- name: Generate coverage
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@v4
with:
files: ./coverage.lcov
flags: rust
# TODO: set true when CODECOV_TOKEN is set
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lints

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- 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@v4
- 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@v4
- 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
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v26
- name: Build & test
run: nix develop .#stable -c cargo test --workspace --all-features --no-fail-fast --tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
*.swp

/dep_test
default_*.profraw
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ categories = ["cryptography::cryptocurrencies"]
authors = ["Dr Maxim Orlovsky <[email protected]>"]
homepage = "https://github.com/RGB-WG"
repository = "https://github.com/RGB-WG/rgb-interfaces"
rust-version = "1.67"
rust-version = "1.75.0" # rgb-std
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
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.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";
};
};
}
);
}

0 comments on commit 32d85b8

Please sign in to comment.