diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a38607c..c4306cbc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,15 @@ name: Build on: push: - branches: [ master ] + branches: + - master + tags: + - 'v[0-9]+\.*' pull_request: - branches: [ master ] + branches: + - master + - develop + - 'v[0-9]+.[0-9]+' env: CARGO_TERM_COLOR: always @@ -14,60 +20,48 @@ jobs: 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: Default build - uses: actions-rs/cargo@v1 - with: - command: check - args: --workspace + - uses: dtolnay/rust-toolchain@stable + - run: cargo check --workspace + no-default: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo check --workspace --no-default-features features: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - feature: - - stl - - serde + feature: [ chrono, stl, serde ] steps: - uses: actions/checkout@v4 - - 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 }} + - uses: dtolnay/rust-toolchain@stable + - name: Feature ${{matrix.feature}} + run: cargo check --workspace --no-default-features --features=${{matrix.feature}} + - name: Feature ${{matrix.feature}} + run: cargo check --workspace --features=${{matrix.feature}} platforms: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, windows-2019, windows-2022 ] + os: [ ubuntu-22.04, ubuntu-latest, macos-13, macos-latest, windows-2019, windows-latest ] 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 + - uses: dtolnay/rust-toolchain@stable + - name: Platform ${{matrix.os}} + run: cargo check --workspace --all-features # we skip test targets here to be sure that the main library can be built toolchains: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - toolchain: [ nightly, beta, stable, msrv ] + toolchain: [ nightly, beta, stable, 1.75.0 ] steps: - uses: actions/checkout@v4 - - name: Install Nix - uses: cachix/install-nix-action@v26 - - name: Check rgb-core - run: nix develop ".#${{ matrix.toolchain }}" -c cargo check --workspace --all-targets --all-features + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{matrix.toolchain}} + - name: Toolchain ${{matrix.toolchain}} + run: cargo +${{matrix.toolchain}} check --workspace --all-targets --all-features diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 238fae7d..3711d7ad 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -2,9 +2,15 @@ name: Codecov on: push: - branches: [ master ] + branches: + - master + tags: + - 'v[0-9]+\.*' pull_request: - branches: [ master ] + branches: + - master + - develop + - 'v[0-9]+.[0-9]+' env: CARGO_TERM_COLOR: always @@ -14,22 +20,21 @@ jobs: 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 - - 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 + - uses: dtolnay/rust-toolchain@nightly + with: + components: llvm-tools-preview + - uses: taiki-e/install-action@cargo-llvm-cov + - uses: taiki-e/install-action@nextest + - name: Collect coverage data (including doctests) + run: | + cargo +nightly llvm-cov --no-report nextest --workspace --all-features + cargo +nightly llvm-cov --no-report --doc --workspace --all-features + cargo +nightly llvm-cov report --doctests --lcov --output-path lcov.info + - name: Upload coverage data 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 }} + files: lcov.info + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 105d63c3..fb630fb0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,10 +1,11 @@ name: Lints on: - push: - branches: [ master ] pull_request: - branches: [ master ] + branches: + - master + - develop + - 'v[0-9]+.[0-9]+' env: CARGO_TERM_COLOR: always @@ -14,23 +15,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Nix - uses: cachix/install-nix-action@v26 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt - name: Formatting - run: nix develop .#nightly -c cargo fmt --all -- --check + run: cargo +nightly fmt --all -- --check clippy: runs-on: ubuntu-latest steps: - 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 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - name: Formatting + run: cargo clippy --workspace --all-features --all-targets -- -D warnings doc: runs-on: ubuntu-latest steps: - 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 + - uses: dtolnay/rust-toolchain@nightly + with: + components: rust-docs + - name: Formatting + run: cargo +nightly doc --workspace --all-features diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4a2886e..9821d00e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,27 +2,38 @@ name: Tests on: push: - branches: [ master ] + branches: + - master + tags: + - 'v[0-9]+\.*' pull_request: - branches: [ master ] + branches: + - master + - develop + - 'v[0-9]+.[0-9]+' env: CARGO_TERM_COLOR: always jobs: testing: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-13, macos-latest, windows-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 + - uses: dtolnay/rust-toolchain@stable + - name: Test ${{matrix.os}} + run: cargo test --workspace --all-features --no-fail-fast wasm-testing: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Nix - uses: cachix/install-nix-action@v26 + - uses: dtolnay/rust-toolchain@nightly + - uses: jetli/wasm-pack-action@v0.4.0 + - name: Add wasm32 target + run: rustup target add wasm32-unknown-unknown - name: Test in headless Chrome - run: nix develop .#wasm -c wasm-pack test --headless --chrome + run: wasm-pack test --headless --chrome diff --git a/Cargo.toml b/Cargo.toml index 1bcac934..9f20e772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ version = "0.11.0-beta.6" authors = ["Dr Maxim Orlovsky "] homepage = "https://github.com/BP-WG" repository = "https://github.com/BP-WG/bp-core" -rust-version = "1.70.0" # Due to strict encoding +rust-version = "1.75.0" # Due to amplify edition = "2021" license = "Apache-2.0" diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 89a9d709..00000000 --- a/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -# This image uses cargo-chef to build the application in order to compile -# the dependencies apart from the main application. This allows the compiled -# dependencies to be cached in the Docker layer and greatly reduce the -# build time when there isn't any dependency changes. -# -# https://github.com/LukeMathWalker/cargo-chef - -ARG SRC_DIR=/usr/local/src/bp-core -ARG BUILDER_DIR=/srv/bp-core - -# Base image -FROM rust:1.59.0-slim-bullseye as chef - -ARG SRC_DIR -ARG BUILDER_DIR - -RUN rustup default stable -RUN rustup update -RUN cargo install cargo-chef --locked - -WORKDIR $SRC_DIR - -# Cargo chef step that analyzes the project to determine the minimum subset of -# files (Cargo.lock and Cargo.toml manifests) required to build it and cache -# dependencies -FROM chef AS planner - -COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder - -ARG SRC_DIR -ARG BUILDER_DIR - -COPY --from=planner "${SRC_DIR}/recipe.json" recipe.json - -# Build dependencies - this is the caching Docker layer -RUN cargo chef cook --release --recipe-path recipe.json --target-dir "${BUILDER_DIR}" - -# Copy all files and build application -COPY . . -RUN cargo build --release --target-dir "${BUILDER_DIR}" --bins --all-features - -# Final image with binaries -FROM debian:bullseye-slim as final - -ARG BUILDER_DIR -ARG DATA_DIR=/var/lib/bp -ARG BIN_DIR=/usr/local/bin -ARG USER=bp - -RUN adduser --home "${DATA_DIR}" --shell /bin/bash --disabled-login \ - --gecos "${USER} user" ${USER} - -COPY --from=builder --chown=${USER}:${USER} \ - "${BUILDER_DIR}/release" "${BIN_DIR}" - -WORKDIR "${BIN_DIR}" - -# Remove build artifacts in order to keep only the binaries -RUN rm -rf */ *.d .[^.] .??* - -USER ${USER} diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 0da39090..00000000 --- a/flake.lock +++ /dev/null @@ -1,85 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1713714899, - "narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "6143fc5eeb9c4f00163267708e26191d1e918932", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1713838472, - "narHash": "sha256-lCdDz6/YgyXdFRHall3P+dCETRpfz3Pi9eREnA9RX6k=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "28a9436d356181603fb0d333565431c3d952f299", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 1d9499be..00000000 --- a/flake.nix +++ /dev/null @@ -1,81 +0,0 @@ -{ - 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); - - nightlyWithWasm = pkgs.rust-bin.nightly.latest.default.override { - extensions = [ ]; - targets = [ "wasm32-unknown-unknown" ]; - }; - - 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 - ]; - }; - - wasm = mkShell { - buildInputs = [ - nightlyWithWasm - chromedriver - wasm-pack - ]; - }; - - codecov = mkShell { - buildInputs = [ - stableWithLlvm - ]; - CARGO_INCREMENTAL = "0"; - RUSTFLAGS = "-Cinstrument-coverage"; - RUSTDOCFLAGS = "-Cinstrument-coverage"; - }; - }; - } - ); -}